--- myodbc-3.51.15r409.orig/odbc.ini +++ myodbc-3.51.15r409/odbc.ini @@ -0,0 +1,45 @@ +; +; odbc.ini configuration for MyODBC and MyODBC 3.51 Drivers +; + +[ODBC Data Sources] + +myodbc = MySQL ODBC 2.50 Driver DSN +myodbc3 = MySQL ODBC 3.51 Driver DSN + + +[myodbc] +Driver = MySQL +Description = MySQL ODBC 2.50 Driver DSN +Server = localhost +Port = +User = root +Password = +Database = test +Option = 3 +Socket = + + +[myodbc3] +Driver = MySQL3 +Description = MySQL ODBC 3.51 Driver DSN +Server = localhost +Port = +User = root +Password = +Database = test +Option = 3 +Socket = + + +[Default] +Driver = MySQL +Description = MySQL ODBC 3.51 Driver DSN +Server = localhost +Port = +User = root +Password = +Database = test +Option = 3 +Socket = + --- myodbc-3.51.15r409.orig/driver/connect.c +++ myodbc-3.51.15r409/driver/connect.c @@ -34,6 +34,7 @@ * * ****************************************************************************/ +#include #include "myodbc3.h" #ifndef _UNIX_ --- myodbc-3.51.15r409.orig/driver/cursor.c +++ myodbc-3.51.15r409/driver/cursor.c @@ -763,8 +763,8 @@ { char buff[32]; - sprintf( buff, " LIMIT %lu", - (unsigned long)pStmt->stmt_options.rows_in_set ); + sprintf( buff, " LIMIT %u", + (unsigned int)pStmt->stmt_options.rows_in_set ); dynstr_append( dynQuery, buff ); } else --- myodbc-3.51.15r409.orig/driver/options.c +++ myodbc-3.51.15r409/driver/options.c @@ -325,7 +325,7 @@ } else { - dbc->login_timeout= (SQLUINTEGER) ValuePtr; + dbc->login_timeout= (SQLULEN) ValuePtr; MYODBCDbgReturnReturn(SQL_SUCCESS); } } --- myodbc-3.51.15r409.orig/test/my_blob.c +++ myodbc-3.51.15r409/test/my_blob.c @@ -28,7 +28,7 @@ SQLUINTEGER j= 0; SQLINTEGER l; SQLLEN cbValue; - char *blobbuf; + SQLCHAR *blobbuf; SQLUINTEGER blobbuf_size = 1024 * 1 * 6L; SQLUINTEGER blob_read; SQLPOINTER token; @@ -40,19 +40,19 @@ mycon(hdbc,rc); rc = SQLExecDirect(hstmt, - "DROP TABLE TBLOB", + (SQLCHAR *)"DROP TABLE TBLOB", SQL_NTS); rc = SQLTransact(NULL, hdbc, SQL_COMMIT); rc = SQLExecDirect(hstmt, - "CREATE TABLE TBLOB (I INTEGER NOT NULL PRIMARY KEY, B LONGBLOB)", + (SQLCHAR *)"CREATE TABLE TBLOB (I INTEGER NOT NULL PRIMARY KEY, B LONGBLOB)", SQL_NTS); mystmt(hstmt,rc); rc = SQLTransact(NULL, hdbc, SQL_COMMIT); mycon(hdbc,rc); cbValue = 0; - rc = SQLPrepare(hstmt, "INSERT INTO TBLOB VALUES (1, ?)", SQL_NTS); + rc = SQLPrepare(hstmt, (SQLCHAR *)"INSERT INTO TBLOB VALUES (1, ?)", SQL_NTS); mystmt(hstmt,rc); rc = SQLBindParameter(hstmt,SQL_PARAM_INPUT, 1, SQL_C_BINARY, SQL_LONGVARBINARY, blob_size, 0, NULL, 0, &cbValue); @@ -105,7 +105,7 @@ memset(blobbuf, ~0, 100); - rc = SQLPrepare(hstmt, "SELECT I, B FROM TBLOB WHERE I = 1", SQL_NTS); + rc = SQLPrepare(hstmt, (SQLCHAR *)"SELECT I, B FROM TBLOB WHERE I = 1", SQL_NTS); mystmt(hstmt,rc); start = clock(); @@ -147,12 +147,12 @@ size_t i; rc = SQLExecDirect(hstmt, - "DROP TABLE TBLOB", + (SQLCHAR *)"DROP TABLE TBLOB", SQL_NTS); rc = SQLTransact(NULL, hdbc, SQL_COMMIT); rc = SQLExecDirect(hstmt, - "CREATE TABLE TBLOB (I INTEGER NOT NULL PRIMARY KEY, B LONG VARCHAR NOT NULL)", + (SQLCHAR *)"CREATE TABLE TBLOB (I INTEGER NOT NULL PRIMARY KEY, B LONG VARCHAR NOT NULL)", SQL_NTS); mystmt(hstmt,rc); rc = SQLTransact(NULL, hdbc, SQL_COMMIT); @@ -171,14 +171,14 @@ mystmt(hstmt,rc); rc = SQLBindParameter(hstmt,SQL_PARAM_INPUT, 2, SQL_C_CHAR, SQL_LONGVARCHAR, 0, 0, blobbuf,cbValue, NULL); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt, "INSERT INTO TBLOB VALUES (1,?)", SQL_NTS); + rc = SQLExecDirect(hstmt, (SQLCHAR *)"INSERT INTO TBLOB VALUES (1,?)", SQL_NTS); mystmt(hstmt,rc); rc = SQLTransact(NULL, hdbc, SQL_COMMIT); mycon(hdbc,rc); memset(blobbuf, 1, (size_t)cbValue); rc = SQLFreeStmt(hstmt, SQL_RESET_PARAMS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt, "SELECT B FROM TBLOB WHERE I = 1", SQL_NTS); + rc = SQLExecDirect(hstmt, (SQLCHAR *)"SELECT B FROM TBLOB WHERE I = 1", SQL_NTS); mystmt(hstmt,rc); rc = SQLFetch(hstmt); mystmt(hstmt,rc); @@ -208,11 +208,11 @@ SQLCHAR data[255]; SQLPOINTER token; - SQLExecDirect(hstmt,"drop table t_putdata",SQL_NTS); - rc = SQLExecDirect(hstmt,"create table t_putdata(c1 int, c2 long varchar)",SQL_NTS); + SQLExecDirect(hstmt,(SQLCHAR *)"drop table t_putdata",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"create table t_putdata(c1 int, c2 long varchar)",SQL_NTS); mystmt(hstmt,rc); - rc = SQLPrepare(hstmt,"insert into t_putdata values(?,?)",SQL_NTS); + rc = SQLPrepare(hstmt,(SQLCHAR *)"insert into t_putdata values(?,?)",SQL_NTS); mystmt(hstmt,rc); rc = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT,SQL_C_LONG, @@ -245,7 +245,7 @@ SQLFreeStmt(hstmt, SQL_RESET_PARAMS); SQLFreeStmt(hstmt, SQL_CLOSE); - rc = SQLExecDirect(hstmt,"select c2 from t_putdata where c1= 10",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"select c2 from t_putdata where c1= 10",SQL_NTS); mystmt(hstmt,rc); rc = SQLFetch(hstmt); @@ -254,7 +254,7 @@ pcbLength= 0; rc = SQLGetData(hstmt, 1, SQL_C_CHAR, data, sizeof(data), &pcbLength); mystmt(hstmt,rc); - fprintf(stdout,"data: %s(%d)\n", data, pcbLength); + fprintf(stdout,"data: %s(%ld)\n", data, pcbLength); myassert(strcmp(data,"mysql - the open source database company")==0); myassert(pcbLength == 40); @@ -273,14 +273,14 @@ SQLCHAR data[255]; SQLPOINTER token; - SQLExecDirect(hstmt,"drop table t_putdata",SQL_NTS); - rc = SQLExecDirect(hstmt,"create table t_putdata(c1 int, c2 long varchar)",SQL_NTS); + SQLExecDirect(hstmt,(SQLCHAR *)"drop table t_putdata",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"create table t_putdata(c1 int, c2 long varchar)",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into t_putdata values(10,'venu')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into t_putdata values(10,'venu')",SQL_NTS); mystmt(hstmt,rc); - rc = SQLPrepare(hstmt,"update t_putdata set c2= ? where c1 = ?",SQL_NTS); + rc = SQLPrepare(hstmt,(SQLCHAR *)"update t_putdata set c2= ? where c1 = ?",SQL_NTS); mystmt(hstmt,rc); rc = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT,SQL_C_CHAR, @@ -313,7 +313,7 @@ SQLFreeStmt(hstmt, SQL_RESET_PARAMS); SQLFreeStmt(hstmt, SQL_CLOSE); - rc = SQLExecDirect(hstmt,"select c2 from t_putdata where c1= 10",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"select c2 from t_putdata where c1= 10",SQL_NTS); mystmt(hstmt,rc); rc = SQLFetch(hstmt); @@ -322,7 +322,7 @@ pcbLength= 0; rc = SQLGetData(hstmt, 1, SQL_C_CHAR, data, sizeof(data), &pcbLength); mystmt(hstmt,rc); - fprintf(stdout,"data: %s(%d)\n", data, pcbLength); + fprintf(stdout,"data: %s(%ld)\n", data, pcbLength); myassert(strcmp(data,"mysql - the open source database company")==0); myassert(pcbLength == 40); @@ -342,11 +342,11 @@ SQLCHAR data[255]; SQLPOINTER token; - SQLExecDirect(hstmt,"drop table t_putdata",SQL_NTS); - rc = SQLExecDirect(hstmt,"create table t_putdata(c1 int, c2 long varchar, c3 long varchar)",SQL_NTS); + SQLExecDirect(hstmt,(SQLCHAR *)"drop table t_putdata",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"create table t_putdata(c1 int, c2 long varchar, c3 long varchar)",SQL_NTS); mystmt(hstmt,rc); - rc = SQLPrepare(hstmt,"insert into t_putdata values(?,?,?)",SQL_NTS); + rc = SQLPrepare(hstmt,(SQLCHAR *)"insert into t_putdata values(?,?,?)",SQL_NTS); mystmt(hstmt,rc); rc = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT,SQL_C_LONG, @@ -390,7 +390,7 @@ SQLFreeStmt(hstmt, SQL_RESET_PARAMS); SQLFreeStmt(hstmt, SQL_CLOSE); - rc = SQLExecDirect(hstmt,"select c2,c3 from t_putdata where c1= 10",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"select c2,c3 from t_putdata where c1= 10",SQL_NTS); mystmt(hstmt,rc); rc = SQLFetch(hstmt); @@ -399,14 +399,14 @@ pcbLength= 0; rc = SQLGetData(hstmt, 1, SQL_C_CHAR, data, sizeof(data), &pcbLength); mystmt(hstmt,rc); - fprintf(stdout,"data: %s(%d)\n", data, pcbLength); + fprintf(stdout,"data: %s(%ld)\n", data, pcbLength); myassert(strcmp(data,"mysql - the open source database company")==0); myassert(pcbLength == 40); pcbLength= 0; rc = SQLGetData(hstmt, 2, SQL_C_CHAR, data, sizeof(data), &pcbLength); mystmt(hstmt,rc); - fprintf(stdout,"data: %s(%d)\n", data, pcbLength); + fprintf(stdout,"data: %s(%ld)\n", data, pcbLength); myassert(strcmp(data,"MySQL AB")==0); myassert(pcbLength == 8); @@ -422,16 +422,17 @@ DECLARE_TEST(t_putdata3) { SQLRETURN rc; - SQLINTEGER id, id1, id2, id3, resId; - SQLINTEGER resUTimeSec; - SQLINTEGER resUTimeMSec; - SQLINTEGER resDataLen; + SQLINTEGER id, id1, id2, id3; + SQLLEN resId; + SQLLEN resUTimeSec; + SQLLEN resUTimeMSec; + SQLLEN resDataLen; SQLLEN resData; - char buffer[]= "MySQL - The worlds's most popular open source database"; + SQLCHAR buffer[]= "MySQL - The worlds's most popular open source database"; const int MAX_PART_SIZE = 5; - char *pdata= 0, data[50]; + SQLCHAR data[50]; int commonLen= 20; ok_sql(hstmt, "DROP TABLE IF EXISTS t_putdata3"); @@ -494,7 +495,7 @@ ok_stmt(hstmt, SQLFreeStmt(hstmt, SQL_UNBIND)); ok_stmt(hstmt, SQLFreeStmt(hstmt, SQL_CLOSE)); - if (mysql_min_version(hdbc, "4.0", 3)) + if (mysql_min_version(hdbc, (SQLCHAR *)"4.0", 3)) { ok_sql(hstmt, "SELECT id, id1, id2, id3, CONVERT(b, CHAR) FROM t_putdata3"); @@ -539,11 +540,11 @@ SQLLEN length; const SQLINTEGER max_blob_size=1024*100; - SQLExecDirect(hstmt,"drop table t_blob",SQL_NTS); - rc = SQLExecDirect(hstmt,"create table t_blob(blb long varbinary)",SQL_NTS); + SQLExecDirect(hstmt,(SQLCHAR *)"drop table t_blob",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"create table t_blob(blb long varbinary)",SQL_NTS); mystmt(hstmt,rc); - rc = SQLPrepare(hstmt,"insert into t_blob values(?)",SQL_NTS); + rc = SQLPrepare(hstmt,(SQLCHAR *)"insert into t_blob values(?)",SQL_NTS); mystmt(hstmt,rc); if (!(data = (SQLCHAR *)calloc(max_blob_size,sizeof(SQLCHAR)))) @@ -562,7 +563,7 @@ fprintf(stdout,"inserting %d rows\n\n", max_blob_size / 1024); for (length=1024; length <= max_blob_size; length+= 1024) { - fprintf(stdout,"\r %d", length/1024); + fprintf(stdout,"\r %ld", length/1024); rc = SQLExecute(hstmt); mystmt(hstmt,rc); } @@ -570,7 +571,7 @@ SQLFreeStmt(hstmt,SQL_RESET_PARAMS); SQLFreeStmt(hstmt,SQL_CLOSE); - rc = SQLExecDirect(hstmt,"SELECT length(blb) FROM t_blob",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"SELECT length(blb) FROM t_blob",SQL_NTS); mystmt(hstmt,rc); rc = SQLBindCol(hstmt,1,SQL_C_LONG,&length,0,NULL); @@ -581,7 +582,7 @@ rc = SQLFetch(hstmt); mystmt(hstmt,rc); - fprintf(stdout,"row %d length: %d\n", i, length); + fprintf(stdout,"row %d length: %ld\n", i, length); myassert(length == i * 1024); } rc = SQLFetch(hstmt); @@ -604,14 +605,14 @@ SQLLEN row_count, length; SQLCHAR data[TEST_ODBC_TEXT_LEN+1]; - SQLExecDirect(hstmt,"drop table t_text_fetch",SQL_NTS); - rc = SQLExecDirect(hstmt,"create table t_text_fetch(t1 tinytext, \ + SQLExecDirect(hstmt,(SQLCHAR *)"drop table t_text_fetch",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"create table t_text_fetch(t1 tinytext, \ t2 text, \ t3 mediumtext, \ t4 longtext)",SQL_NTS); mystmt(hstmt,rc); - rc = SQLPrepare(hstmt,"insert into t_text_fetch values(?,?,?,?)",SQL_NTS); + rc = SQLPrepare(hstmt,(SQLCHAR *)"insert into t_text_fetch values(?,?,?,?)",SQL_NTS); mystmt(hstmt,rc); rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, @@ -643,44 +644,44 @@ SQLFreeStmt(hstmt, SQL_RESET_PARAMS); SQLFreeStmt(hstmt, SQL_CLOSE); - rc = SQLExecDirect(hstmt,"SELECT * FROM t_text_fetch",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"SELECT * FROM t_text_fetch",SQL_NTS); mystmt(hstmt,rc); row_count= 0; rc = SQLFetch(hstmt); while (rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO) { - fprintf(stdout,"row '%d' (lengths: \n", row_count); + fprintf(stdout,"row '%ld' (lengths: \n", row_count); rc = SQLGetData(hstmt,1,SQL_C_CHAR,(char *)data,TEST_ODBC_TEXT_LEN,&length); mystmt(hstmt,rc); - fprintf(stdout,"%d", length); + fprintf(stdout,"%ld", length); myassert(length == 255); rc = SQLGetData(hstmt,2,SQL_C_CHAR,(char *)data,TEST_ODBC_TEXT_LEN,&length); mystmt(hstmt,rc); - fprintf(stdout,",%d", length); + fprintf(stdout,",%ld", length); myassert(length == TEST_ODBC_TEXT_LEN/2); rc = SQLGetData(hstmt,3,SQL_C_CHAR,(char *)data,TEST_ODBC_TEXT_LEN,&length); mystmt(hstmt,rc); - fprintf(stdout,",%d", length); + fprintf(stdout,",%ld", length); myassert(length == (SQLINTEGER)(TEST_ODBC_TEXT_LEN/1.5)); rc = SQLGetData(hstmt,4,SQL_C_CHAR,(char *)data,TEST_ODBC_TEXT_LEN,&length); mystmt(hstmt,rc); - fprintf(stdout,",%d)", length); + fprintf(stdout,",%ld)", length); myassert(length == TEST_ODBC_TEXT_LEN-1); row_count++; rc = SQLFetch(hstmt); } - fprintf(stdout,"total rows: %d\n", row_count); + fprintf(stdout,"total rows: %ld\n", row_count); myassert(row_count == i); SQLFreeStmt(hstmt, SQL_UNBIND); SQLFreeStmt(hstmt, SQL_CLOSE); - rc = SQLExecDirect(hstmt,"DROP TABLE t_text_fetch",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"DROP TABLE t_text_fetch",SQL_NTS); mystmt(hstmt,rc); return OK; --- myodbc-3.51.15r409.orig/test/my_catalog.c +++ myodbc-3.51.15r409/test/my_catalog.c @@ -27,9 +27,9 @@ SQLRETURN rc; /* initialize data */ - SQLExecDirect(hstmt,"drop table my_column_null",SQL_NTS); + SQLExecDirect(hstmt,(SQLCHAR *)"drop table my_column_null",SQL_NTS); - rc = SQLExecDirect(hstmt,"create table my_column_null(id int not null, name varchar(30))",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"create table my_column_null(id int not null, name varchar(30))",SQL_NTS); mystmt(hstmt,rc); rc = SQLTransact(NULL,hdbc,SQL_COMMIT); @@ -38,7 +38,7 @@ rc = SQLFreeStmt(hstmt,SQL_CLOSE); mystmt(hstmt,rc); - rc = SQLColumns(hstmt,NULL,SQL_NTS,NULL,SQL_NTS,"my_column_null",SQL_NTS,NULL,SQL_NTS); + rc = SQLColumns(hstmt,NULL,SQL_NTS,NULL,SQL_NTS,(SQLCHAR *)"my_column_null",SQL_NTS,NULL,SQL_NTS); mystmt(hstmt,rc); myassert(2 == my_print_non_format_result(hstmt)); @@ -54,9 +54,9 @@ SQLRETURN rc; /* initialize data */ - SQLExecDirect(hstmt,"drop table my_drop_table",SQL_NTS); + SQLExecDirect(hstmt,(SQLCHAR *)"drop table my_drop_table",SQL_NTS); - rc = SQLExecDirect(hstmt,"create table my_drop_table(id int not null)",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"create table my_drop_table(id int not null)",SQL_NTS); mystmt(hstmt,rc); rc = SQLTransact(NULL,hdbc,SQL_COMMIT); @@ -65,12 +65,12 @@ rc = SQLFreeStmt(hstmt,SQL_CLOSE); mystmt(hstmt,rc); - rc = SQLColumns(hstmt,NULL,0,NULL,0,"my_drop_table",SQL_NTS,NULL,0); + rc = SQLColumns(hstmt,NULL,0,NULL,0,(SQLCHAR *)"my_drop_table",SQL_NTS,NULL,0); mystmt(hstmt,rc); myassert(1 == my_print_non_format_result(hstmt)); - rc = SQLExecDirect(hstmt,"drop table my_drop_table",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"drop table my_drop_table",SQL_NTS); mystmt(hstmt,rc); rc = SQLFreeStmt(hstmt,SQL_CLOSE); @@ -84,8 +84,8 @@ { SQLRETURN rc; - rc = SQLTablePrivileges(hstmt,"te%",SQL_NTS, - NULL,0,"my_%",SQL_NTS); + rc = SQLTablePrivileges(hstmt,(SQLCHAR *)"te%",SQL_NTS, + NULL,0,(SQLCHAR *)"my_%",SQL_NTS); mystmt(hstmt,rc); my_print_non_format_result(hstmt); @@ -124,40 +124,40 @@ SQLRETURN rc; SQLINTEGER nrows; - SQLExecDirect(hstmt, "DROP DATABASE my_all_db_test1", SQL_NTS); - SQLExecDirect(hstmt, "DROP DATABASE my_all_db_test2", SQL_NTS); - SQLExecDirect(hstmt, "DROP DATABASE my_all_db_test3", SQL_NTS); - SQLExecDirect(hstmt, "DROP DATABASE my_all_db_test4", SQL_NTS); + SQLExecDirect(hstmt, (SQLCHAR *)"DROP DATABASE my_all_db_test1", SQL_NTS); + SQLExecDirect(hstmt, (SQLCHAR *)"DROP DATABASE my_all_db_test2", SQL_NTS); + SQLExecDirect(hstmt, (SQLCHAR *)"DROP DATABASE my_all_db_test3", SQL_NTS); + SQLExecDirect(hstmt, (SQLCHAR *)"DROP DATABASE my_all_db_test4", SQL_NTS); - rc = SQLTables(hstmt,"%",1,NULL,0,NULL,0,NULL,0); + rc = SQLTables(hstmt,(SQLCHAR *)"%",1,NULL,0,NULL,0,NULL,0); mystmt(hstmt,rc); nrows = my_print_non_format_result(hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); mystmt(hstmt,rc); - rc = SQLTables(hstmt,"SQL_ALL_CATALOGS",SQL_NTS,NULL,0,NULL,0,NULL,0); + rc = SQLTables(hstmt,(SQLCHAR *)"SQL_ALL_CATALOGS",SQL_NTS,NULL,0,NULL,0,NULL,0); mystmt(hstmt,rc); assert(nrows == my_print_non_format_result(hstmt)); rc = SQLFreeStmt(hstmt, SQL_CLOSE); mystmt(hstmt,rc); - rc = SQLTables(hstmt,"test",4,NULL,0,NULL,0,NULL,0); + rc = SQLTables(hstmt,(SQLCHAR *)"test",4,NULL,0,NULL,0,NULL,0); mystmt(hstmt,rc); my_print_non_format_result(hstmt); rc = SQLFreeStmt(hstmt, SQL_CLOSE); mystmt(hstmt,rc); - rc = SQLTables(hstmt,"mysql",5,NULL,0,NULL,0,NULL,0); + rc = SQLTables(hstmt,(SQLCHAR *)"mysql",5,NULL,0,NULL,0,NULL,0); mystmt(hstmt,rc); assert(my_print_non_format_result(hstmt) != 0); rc = SQLFreeStmt(hstmt, SQL_CLOSE); mystmt(hstmt,rc); - rc = SQLTables(hstmt,"%",1,NULL,0,NULL,0,NULL,0); + rc = SQLTables(hstmt,(SQLCHAR *)"%",1,NULL,0,NULL,0,NULL,0); mystmt(hstmt,rc); rc = SQLFetch(hstmt); @@ -195,16 +195,16 @@ SQLFreeStmt(hstmt,SQL_UNBIND); SQLFreeStmt(hstmt,SQL_CLOSE); - rc = SQLExecDirect(hstmt, "CREATE DATABASE my_all_db_test1", SQL_NTS); + rc = SQLExecDirect(hstmt, (SQLCHAR *)"CREATE DATABASE my_all_db_test1", SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt, "CREATE DATABASE my_all_db_test2", SQL_NTS); + rc = SQLExecDirect(hstmt, (SQLCHAR *)"CREATE DATABASE my_all_db_test2", SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt, "CREATE DATABASE my_all_db_test3", SQL_NTS); + rc = SQLExecDirect(hstmt, (SQLCHAR *)"CREATE DATABASE my_all_db_test3", SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt, "CREATE DATABASE my_all_db_test4", SQL_NTS); + rc = SQLExecDirect(hstmt, (SQLCHAR *)"CREATE DATABASE my_all_db_test4", SQL_NTS); mystmt(hstmt,rc); - rc = SQLTables(hstmt,"%",1,NULL,0,NULL,0,NULL,0); + rc = SQLTables(hstmt,(SQLCHAR *)"%",1,NULL,0,NULL,0,NULL,0); mystmt(hstmt,rc); nrows += 4; @@ -212,34 +212,34 @@ rc = SQLFreeStmt(hstmt, SQL_CLOSE); mystmt(hstmt,rc); - rc = SQLTables(hstmt,"SQL_ALL_CATALOGS",SQL_NTS,NULL,0,NULL,0,NULL,0); + rc = SQLTables(hstmt,(SQLCHAR *)"SQL_ALL_CATALOGS",SQL_NTS,NULL,0,NULL,0,NULL,0); mystmt(hstmt,rc); assert(nrows == my_print_non_format_result(hstmt)); rc = SQLFreeStmt(hstmt, SQL_CLOSE); mystmt(hstmt,rc); - rc = SQLTables(hstmt,"my_all_db_test",SQL_NTS,NULL,0,NULL,0,NULL,0); + rc = SQLTables(hstmt,(SQLCHAR *)"my_all_db_test",SQL_NTS,NULL,0,NULL,0,NULL,0); mystmt(hstmt,rc); assert(0 == my_print_non_format_result(hstmt)); rc = SQLFreeStmt(hstmt, SQL_CLOSE); mystmt(hstmt,rc); - rc = SQLTables(hstmt,"my_all_db_test%",SQL_NTS,NULL,0,NULL,0,NULL,0); + rc = SQLTables(hstmt,(SQLCHAR *)"my_all_db_test%",SQL_NTS,NULL,0,NULL,0,NULL,0); mystmt(hstmt,rc); assert(0 == my_print_non_format_result(hstmt)); rc = SQLFreeStmt(hstmt, SQL_CLOSE); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt, "DROP DATABASE my_all_db_test1", SQL_NTS); + rc = SQLExecDirect(hstmt, (SQLCHAR *)"DROP DATABASE my_all_db_test1", SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt, "DROP DATABASE my_all_db_test2", SQL_NTS); + rc = SQLExecDirect(hstmt, (SQLCHAR *)"DROP DATABASE my_all_db_test2", SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt, "DROP DATABASE my_all_db_test3", SQL_NTS); + rc = SQLExecDirect(hstmt, (SQLCHAR *)"DROP DATABASE my_all_db_test3", SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt, "DROP DATABASE my_all_db_test4", SQL_NTS); + rc = SQLExecDirect(hstmt, (SQLCHAR *)"DROP DATABASE my_all_db_test4", SQL_NTS); mystmt(hstmt,rc); return OK; @@ -250,29 +250,29 @@ { SQLRETURN rc; - SQLExecDirect( hstmt, "DROP TABLE test_colprev1",SQL_NTS); - SQLExecDirect( hstmt, "DROP TABLE test_colprev2",SQL_NTS); - SQLExecDirect( hstmt, "DROP TABLE test_colprev3",SQL_NTS); + SQLExecDirect( hstmt, (SQLCHAR *)"DROP TABLE test_colprev1",SQL_NTS); + SQLExecDirect( hstmt, (SQLCHAR *)"DROP TABLE test_colprev2",SQL_NTS); + SQLExecDirect( hstmt, (SQLCHAR *)"DROP TABLE test_colprev3",SQL_NTS); SQLFreeStmt(hstmt, SQL_CLOSE); - rc = SQLExecDirect(hstmt, "CREATE TABLE test_colprev1(a INT,b INT,c INT, d INT)",SQL_NTS); + rc = SQLExecDirect(hstmt, (SQLCHAR *)"CREATE TABLE test_colprev1(a INT,b INT,c INT, d INT)",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt, "CREATE TABLE test_colprev2(a INT,b INT,c INT, d INT)", SQL_NTS); + rc = SQLExecDirect(hstmt, (SQLCHAR *)"CREATE TABLE test_colprev2(a INT,b INT,c INT, d INT)", SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt, "CREATE TABLE test_colprev3(a INT,b INT,c INT, d INT)", SQL_NTS); + rc = SQLExecDirect(hstmt, (SQLCHAR *)"CREATE TABLE test_colprev3(a INT,b INT,c INT, d INT)", SQL_NTS); mystmt(hstmt,rc); SQLFreeStmt(hstmt, SQL_CLOSE); - SQLExecDirect(hstmt, "DELETE FROM mysql.columns_priv where USER='my_colpriv'",SQL_NTS); - rc = SQLExecDirect(hstmt, "GRANT SELECT(a,b),INSERT(d), UPDATE(c) ON test_colprev1 TO my_colpriv",SQL_NTS); + SQLExecDirect(hstmt, (SQLCHAR *)"DELETE FROM mysql.columns_priv where USER='my_colpriv'",SQL_NTS); + rc = SQLExecDirect(hstmt, (SQLCHAR *)"GRANT SELECT(a,b),INSERT(d), UPDATE(c) ON test_colprev1 TO my_colpriv",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect( hstmt, "GRANT SELECT(c,a),UPDATE(a,b) ON test_colprev3 TO my_colpriv", SQL_NTS); + rc = SQLExecDirect( hstmt, (SQLCHAR *)"GRANT SELECT(c,a),UPDATE(a,b) ON test_colprev3 TO my_colpriv", SQL_NTS); mystmt(hstmt,rc); - SQLExecDirect( hstmt, "FLUSH PRIVILEGES", SQL_NTS); + SQLExecDirect( hstmt, (SQLCHAR *)"FLUSH PRIVILEGES", SQL_NTS); SQLFreeStmt(hstmt, SQL_CLOSE); } @@ -281,30 +281,30 @@ { SQLRETURN rc; - SQLExecDirect( hstmt, "DROP TABLE test_tabprev1",SQL_NTS); - SQLExecDirect( hstmt, "DROP TABLE test_tabprev2",SQL_NTS); - SQLExecDirect( hstmt, "DROP TABLE test_tabprev3",SQL_NTS); + SQLExecDirect( hstmt, (SQLCHAR *)"DROP TABLE test_tabprev1",SQL_NTS); + SQLExecDirect( hstmt, (SQLCHAR *)"DROP TABLE test_tabprev2",SQL_NTS); + SQLExecDirect( hstmt, (SQLCHAR *)"DROP TABLE test_tabprev3",SQL_NTS); SQLFreeStmt(hstmt, SQL_CLOSE); - rc = SQLExecDirect(hstmt, "CREATE TABLE test_tabprev1(f1 INT)",SQL_NTS); + rc = SQLExecDirect(hstmt, (SQLCHAR *)"CREATE TABLE test_tabprev1(f1 INT)",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt, "CREATE TABLE test_tabprev2(f1 INT)", SQL_NTS); + rc = SQLExecDirect(hstmt, (SQLCHAR *)"CREATE TABLE test_tabprev2(f1 INT)", SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt, "CREATE TABLE test_tabprev3(f1 INT)", SQL_NTS); + rc = SQLExecDirect(hstmt, (SQLCHAR *)"CREATE TABLE test_tabprev3(f1 INT)", SQL_NTS); mystmt(hstmt,rc); SQLFreeStmt(hstmt, SQL_CLOSE); - SQLExecDirect(hstmt, "DELETE FROM mysql.tables_priv where USER='my_tabpriv'",SQL_NTS); + SQLExecDirect(hstmt, (SQLCHAR *)"DELETE FROM mysql.tables_priv where USER='my_tabpriv'",SQL_NTS); - SQLExecDirect(hstmt, "GRANT CONNECT TO my_tabpriv IDENTIFIED BY my_tabpriv",SQL_NTS);/* sybase */ + SQLExecDirect(hstmt, (SQLCHAR *)"GRANT CONNECT TO my_tabpriv IDENTIFIED BY my_tabpriv",SQL_NTS);/* sybase */ SQLFreeStmt(hstmt, SQL_CLOSE); - rc = SQLExecDirect(hstmt, "GRANT SELECT,INSERT ON test_tabprev1 TO my_tabpriv",SQL_NTS); + rc = SQLExecDirect(hstmt, (SQLCHAR *)"GRANT SELECT,INSERT ON test_tabprev1 TO my_tabpriv",SQL_NTS); if (rc == SQL_ERROR) { /* probably GRANT is disabled or not enough privs */ @@ -312,10 +312,10 @@ } mystmt(hstmt,rc); - rc = SQLExecDirect( hstmt, "GRANT ALL ON test_tabprev3 TO my_tabpriv", SQL_NTS); + rc = SQLExecDirect( hstmt, (SQLCHAR *)"GRANT ALL ON test_tabprev3 TO my_tabpriv", SQL_NTS); mystmt(hstmt,rc); - SQLExecDirect( hstmt, "FLUSH PRIVILEGES", SQL_NTS); + SQLExecDirect( hstmt, (SQLCHAR *)"FLUSH PRIVILEGES", SQL_NTS); SQLFreeStmt(hstmt, SQL_CLOSE); return 0; @@ -332,7 +332,7 @@ printMessage("\n With All Types(CataLog,Schema and TableName)"); rc = SQLTablePrivileges(hstmt, - "mysql", SQL_NTS,/* CataLog */ + (SQLCHAR *)"mysql", SQL_NTS,/* CataLog */ NULL,SQL_NTS, /* SchemaName */ NULL,SQL_NTS); /* TableName */ mystmt(hstmt,rc); @@ -346,7 +346,7 @@ rc = SQLTablePrivileges(hstmt, NULL, 0, /* CataLog */ NULL,SQL_NTS, /* SchemaName */ - "test_tabprev1",SQL_NTS); /* TableName */ + (SQLCHAR *)"test_tabprev1",SQL_NTS); /* TableName */ mystmt(hstmt,rc); assert( 2 == my_print_non_format_result(hstmt)); @@ -358,7 +358,7 @@ rc = SQLTablePrivileges(hstmt, NULL, 0, /* CataLog */ NULL,SQL_NTS, /* SchemaName */ - "test_tabprev2",SQL_NTS); /* TableName */ + (SQLCHAR *)"test_tabprev2",SQL_NTS); /* TableName */ mystmt(hstmt,rc); assert( 0 == my_print_non_format_result(hstmt)); @@ -370,7 +370,7 @@ rc = SQLTablePrivileges(hstmt, NULL, 0, /* CataLog */ NULL,SQL_NTS, /* SchemaName */ - "test_tabprev3",SQL_NTS); /* TableName */ + (SQLCHAR *)"test_tabprev3",SQL_NTS); /* TableName */ mystmt(hstmt,rc); /* value changed due to two additional rows in the result related to VIEWs */ @@ -383,7 +383,7 @@ rc = SQLTablePrivileges(hstmt, NULL, 0, /* CataLog */ NULL,SQL_NTS, /* SchemaName */ - "test_%",SQL_NTS); /* TableName */ + (SQLCHAR *)"test_%",SQL_NTS); /* TableName */ mystmt(hstmt,rc); my_print_non_format_result(hstmt); @@ -396,7 +396,7 @@ rc = SQLTablePrivileges(hstmt, NULL, 0, /* CataLog */ NULL,SQL_NTS, /* SchemaName */ - "test_tabprev%",SQL_NTS); /* TableName */ + (SQLCHAR *)"test_tabprev%",SQL_NTS); /* TableName */ mystmt(hstmt,rc); @@ -405,7 +405,7 @@ rc = SQLFreeStmt(hstmt, SQL_CLOSE); mystmt(hstmt,rc); - rc = SQLTablePrivileges(hstmt,"mysql",SQL_NTS,NULL,SQL_NTS,"tables_priv",SQL_NTS); + rc = SQLTablePrivileges(hstmt,(SQLCHAR *)"mysql",SQL_NTS,NULL,SQL_NTS,(SQLCHAR *)"tables_priv",SQL_NTS); mystmt(hstmt,rc); my_print_non_format_result(hstmt); @@ -428,16 +428,16 @@ SQLCHAR Privilege_buf[129]; SQLCHAR IsGrantable_buf[4]; - SQLExecDirect(hstmt, "DROP USER todbc1_test",SQL_NTS); - SQLExecDirect(hstmt, "DROP TABLE todbc1_tpriv1",SQL_NTS); - SQLExecDirect(hstmt, "DROP TABLE todbc1_tpriv2",SQL_NTS); - SQLExecDirect(hstmt, "DELETE FROM mysql.tables_priv where Table_name='todbc1_tpriv1'",SQL_NTS); - SQLExecDirect(hstmt, "DELETE FROM mysql.tables_priv where User='todbc1_test'",SQL_NTS); + SQLExecDirect(hstmt, (SQLCHAR *)"DROP USER todbc1_test",SQL_NTS); + SQLExecDirect(hstmt, (SQLCHAR *)"DROP TABLE todbc1_tpriv1",SQL_NTS); + SQLExecDirect(hstmt, (SQLCHAR *)"DROP TABLE todbc1_tpriv2",SQL_NTS); + SQLExecDirect(hstmt, (SQLCHAR *)"DELETE FROM mysql.tables_priv where Table_name='todbc1_tpriv1'",SQL_NTS); + SQLExecDirect(hstmt, (SQLCHAR *)"DELETE FROM mysql.tables_priv where User='todbc1_test'",SQL_NTS); SQLTransact(NULL, hdbc, SQL_COMMIT); - rc = SQLExecDirect(hstmt, "CREATE TABLE todbc1_tpriv1(a INTEGER)",SQL_NTS); + rc = SQLExecDirect(hstmt, (SQLCHAR *)"CREATE TABLE todbc1_tpriv1(a INTEGER)",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt, "CREATE TABLE todbc1_tpriv2 (a INTEGER)",SQL_NTS); + rc = SQLExecDirect(hstmt, (SQLCHAR *)"CREATE TABLE todbc1_tpriv2 (a INTEGER)",SQL_NTS); mystmt(hstmt,rc); SQLTransact(NULL, hdbc, SQL_COMMIT); @@ -448,7 +448,7 @@ ---*/ rc = SQLTablePrivileges(hstmt, NULL, SQL_NTS, NULL, SQL_NTS, - "todbc1_tpriv1", SQL_NTS); + (SQLCHAR *)"todbc1_tpriv1", SQL_NTS); mystmt(hstmt,rc); rc = SQLFetch(hstmt); @@ -460,16 +460,16 @@ SQLFreeStmt(hstmt, SQL_CLOSE); - rc = SQLExecDirect(hstmt, "GRANT SELECT ON todbc1_tpriv1\ + rc = SQLExecDirect(hstmt, (SQLCHAR *)"GRANT SELECT ON todbc1_tpriv1\ TO todbc1_test WITH GRANT OPTION",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt, "GRANT INSERT, UPDATE ON todbc1_tpriv1\ + rc = SQLExecDirect(hstmt, (SQLCHAR *)"GRANT INSERT, UPDATE ON todbc1_tpriv1\ TO todbc1_test", SQL_NTS);mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt, "GRANT USAGE ON todbc1_tpriv2\ + rc = SQLExecDirect(hstmt, (SQLCHAR *)"GRANT USAGE ON todbc1_tpriv2\ TO todbc1_test", SQL_NTS);mystmt(hstmt,rc); SQLTransact(NULL, hdbc, SQL_COMMIT); rc = SQLTablePrivileges(hstmt, NULL, SQL_NTS, NULL, SQL_NTS, - "todbc1_tpriv1", SQL_NTS); + (SQLCHAR *)"todbc1_tpriv1", SQL_NTS); mystmt(hstmt,rc); assert( 4 == my_print_non_format_result(hstmt)); @@ -477,7 +477,7 @@ mystmt(hstmt,rc); rc = SQLTablePrivileges(hstmt, NULL, SQL_NTS, NULL, SQL_NTS, - "todbc1_tpriv1", SQL_NTS); + (SQLCHAR *)"todbc1_tpriv1", SQL_NTS); mystmt(hstmt,rc); TODBC_BIND_CHAR(1, TableQualifier_buf); @@ -533,12 +533,12 @@ SQLFreeStmt(hstmt, SQL_CLOSE); - rc = SQLExecDirect(hstmt, "REVOKE INSERT, UPDATE, SELECT\ + rc = SQLExecDirect(hstmt, (SQLCHAR *)"REVOKE INSERT, UPDATE, SELECT\ ON todbc1_tpriv1 FROM todbc1_test",SQL_NTS); mystmt(hstmt,rc); SQLTransact(NULL, hdbc, SQL_COMMIT); rc = SQLTablePrivileges(hstmt, NULL, SQL_NTS, NULL, SQL_NTS, - "todbc1\\_tpriv_", SQL_NTS); + (SQLCHAR *)"todbc1\\_tpriv_", SQL_NTS); mystmt(hstmt,rc); assert( 2 == my_print_non_format_result(hstmt)); @@ -546,7 +546,7 @@ mystmt(hstmt,rc); rc = SQLTablePrivileges(hstmt, NULL, SQL_NTS, NULL, SQL_NTS, - "todbc1\\_tpriv_", SQL_NTS); + (SQLCHAR *)"todbc1\\_tpriv_", SQL_NTS); mystmt(hstmt,rc); TODBC_BIND_CHAR(1, TableQualifier_buf); @@ -614,7 +614,7 @@ DECLARE_TEST(my_colpriv) { ok_stmt(hstmt, SQLColumnPrivileges(hstmt, - "mysql", SQL_NTS, NULL, SQL_NTS, + (SQLCHAR *)"mysql", SQL_NTS, NULL, SQL_NTS, NULL, SQL_NTS, NULL, SQL_NTS)); assert(0 == my_print_non_format_result(hstmt)); @@ -623,7 +623,7 @@ ok_stmt(hstmt, SQLColumnPrivileges(hstmt, NULL, SQL_NTS, NULL, SQL_NTS, - "test_colprev1", SQL_NTS, NULL, SQL_NTS)); + (SQLCHAR *)"test_colprev1", SQL_NTS, NULL, SQL_NTS)); assert(4 == my_print_non_format_result(hstmt)); @@ -631,7 +631,7 @@ ok_stmt(hstmt, SQLColumnPrivileges(hstmt, NULL, SQL_NTS, NULL, SQL_NTS, - "test_colprev1", SQL_NTS, "a", SQL_NTS)); + (SQLCHAR *)"test_colprev1", SQL_NTS, (SQLCHAR *)"a", SQL_NTS)); assert(1 == my_print_non_format_result(hstmt)); @@ -639,14 +639,14 @@ ok_stmt(hstmt, SQLColumnPrivileges(hstmt, NULL, SQL_NTS, NULL, SQL_NTS, - "test_colprev2", SQL_NTS, NULL, SQL_NTS)); + (SQLCHAR *)"test_colprev2", SQL_NTS, NULL, SQL_NTS)); assert(0 == my_print_non_format_result(hstmt)); ok_stmt(hstmt, SQLFreeStmt(hstmt, SQL_CLOSE)); ok_stmt(hstmt, SQLColumnPrivileges(hstmt, NULL, SQL_NTS, NULL, SQL_NTS, - "test_colprev3", SQL_NTS, NULL, SQL_NTS)); + (SQLCHAR *)"test_colprev3", SQL_NTS, NULL, SQL_NTS)); assert(4 == my_print_non_format_result(hstmt)); @@ -654,7 +654,7 @@ ok_stmt(hstmt, SQLColumnPrivileges(hstmt, NULL, SQL_NTS, NULL, SQL_NTS, - "test_%", SQL_NTS, NULL, SQL_NTS)); + (SQLCHAR *)"test_%", SQL_NTS, NULL, SQL_NTS)); my_print_non_format_result(hstmt); @@ -662,15 +662,15 @@ ok_stmt(hstmt, SQLColumnPrivileges(hstmt, NULL, SQL_NTS, NULL, SQL_NTS, - "test_colprev%", SQL_NTS, NULL, SQL_NTS)); + (SQLCHAR *)"test_colprev%", SQL_NTS, NULL, SQL_NTS)); assert(8 == my_print_non_format_result(hstmt)); ok_stmt(hstmt, SQLFreeStmt(hstmt, SQL_CLOSE)); ok_stmt(hstmt, SQLColumnPrivileges(hstmt, - "mysql", SQL_NTS, NULL, SQL_NTS, - "columns_priv", SQL_NTS, NULL, SQL_NTS)); + (SQLCHAR *)"mysql", SQL_NTS, NULL, SQL_NTS, + (SQLCHAR *)"columns_priv", SQL_NTS, NULL, SQL_NTS)); my_print_non_format_result(hstmt); @@ -682,7 +682,6 @@ DECLARE_TEST(t_sqlprocedures) { - SQLRETURN rc; /** @todo check server version */ ok_sql(hstmt, "DROP FUNCTION IF EXISTS t_sqlproc_func"); @@ -698,13 +697,13 @@ ok_stmt(hstmt, SQLFreeStmt(hstmt, SQL_CLOSE)); /* Try without specifying a catalog. */ - ok_stmt(hstmt, SQLProcedures(hstmt, NULL, 0, NULL, 0, "t_sqlproc%", SQL_NTS)); + ok_stmt(hstmt, SQLProcedures(hstmt, NULL, 0, NULL, 0, (SQLCHAR *)"t_sqlproc%", SQL_NTS)); is_num(my_print_non_format_result(hstmt), 2); /* And try with specifying a catalog. */ - ok_stmt(hstmt, SQLProcedures(hstmt, "test", SQL_NTS, NULL, 0, - "t_sqlproc%", SQL_NTS)); + ok_stmt(hstmt, SQLProcedures(hstmt, (SQLCHAR *)"test", SQL_NTS, NULL, 0, + (SQLCHAR *)"t_sqlproc%", SQL_NTS)); is_num(my_print_non_format_result(hstmt), 2); @@ -733,12 +732,12 @@ 9,11,10,11,9,9,11,13,14,14,8,7,10,13,16,17,16,11 }; - SQLExecDirect(hstmt,"drop table t_catalog",SQL_NTS); + SQLExecDirect(hstmt,(SQLCHAR *)"drop table t_catalog",SQL_NTS); - rc = SQLExecDirect(hstmt,"create table t_catalog(a tinyint, b char(4))",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"create table t_catalog(a tinyint, b char(4))",SQL_NTS); mystmt(hstmt,rc); - rc = SQLColumns(hstmt,NULL,0,NULL,0,"t_catalog",9,NULL,0); + rc = SQLColumns(hstmt,NULL,0,NULL,0,(SQLCHAR *)"t_catalog",9,NULL,0); mystmt(hstmt,rc); rc = SQLNumResultCols(hstmt, &ncols); @@ -751,7 +750,7 @@ SQLFreeStmt(hstmt, SQL_UNBIND); SQLFreeStmt(hstmt, SQL_CLOSE); - rc = SQLColumns(hstmt,NULL,0,NULL,0,"t_catalog",9,NULL,0); + rc = SQLColumns(hstmt,NULL,0,NULL,0,(SQLCHAR *)"t_catalog",9,NULL,0); mystmt(hstmt,rc); rc = SQLNumResultCols(hstmt,&ncols); @@ -806,7 +805,7 @@ SQL_BEST_ROWID, NULL,0, NULL,0, - "tmysql_specialcols",SQL_NTS, + (SQLCHAR *)"tmysql_specialcols",SQL_NTS, SQL_SCOPE_SESSION, SQL_NULLABLE); mystmt(hstmt,rc); @@ -831,8 +830,8 @@ { SQLSMALLINT NumPrecRadix, DataType, Nullable, DecimalDigits; SQLLEN cbColumnSize, cbDecimalDigits, cbNumPrecRadix, - cbDatabaseName, cbDataType, cbNullable; - SQLRETURN rc; + cbDataType, cbNullable; + SQLINTEGER cbDatabaseName; SQLUINTEGER ColumnSize, i; SQLUINTEGER ColumnCount= 7; SQLCHAR ColumnName[MAX_NAME_LEN], DatabaseName[MAX_NAME_LEN]; @@ -952,12 +951,12 @@ { SQLRETURN rc; SQLSMALLINT i, ColumnCount, pcbColName, pfSqlType, pibScale, pfNullable; - SQLUINTEGER pcbColDef; + SQLULEN pcbColDef; SQLCHAR szColName[MAX_NAME_LEN]; SQLFreeStmt(hstmt, SQL_CLOSE); - rc = SQLTables(hstmt,NULL,0,NULL,0,NULL,0,"'TABLE'",SQL_NTS); + rc = SQLTables(hstmt,NULL,0,NULL,0,NULL,0,(SQLCHAR *)"'TABLE'",SQL_NTS); mystmt(hstmt,rc); rc = SQLNumResultCols(hstmt,&ColumnCount); @@ -977,7 +976,7 @@ fprintf(stdout, "\t Column Name : %s\n", szColName); fprintf(stdout, "\t NameLengh : %d\n", pcbColName); fprintf(stdout, "\t DataType : %d\n", pfSqlType); - fprintf(stdout, "\t ColumnSize : %d\n", pcbColDef); + fprintf(stdout, "\t ColumnSize : %ld\n", pcbColDef); fprintf(stdout, "\t DecimalDigits : %d\n", pibScale); fprintf(stdout, "\t Nullable : %d\n", pfNullable); @@ -998,26 +997,26 @@ { SQLCHAR cur_db[255], db[255]; SQLRETURN rc; - SQLUINTEGER len; + SQLINTEGER len; rc = SQLFreeStmt(hstmt,SQL_CLOSE); mystmt(hstmt,rc); rc = SQLGetConnectAttr(hdbc, SQL_ATTR_CURRENT_CATALOG, (char *)db, 255, &len); mycon(hdbc,rc); - fprintf(stdout,"current_catalog: %s (%ld)\n", db, len); + fprintf(stdout,"current_catalog: %s (%d)\n", db, len); myassert(strcmp(db, "test") == 0 || strlen("test") == len); rc = SQLSetConnectAttr(hdbc, SQL_ATTR_CURRENT_CATALOG, (char *)db, SQL_NTS); mycon(hdbc,rc); - SQLExecDirect(hstmt, "DROP DATABASE IF EXISTS test_odbc_current", SQL_NTS); + SQLExecDirect(hstmt, (SQLCHAR *)"DROP DATABASE IF EXISTS test_odbc_current", SQL_NTS); strcpy(cur_db, "test_odbc_current"); rc = SQLSetConnectAttr(hdbc, SQL_ATTR_CURRENT_CATALOG, (char *)cur_db, SQL_NTS); mycon_r(hdbc,rc); - rc = SQLExecDirect(hstmt, "CREATE DATABASE test_odbc_current", SQL_NTS); + rc = SQLExecDirect(hstmt, (SQLCHAR *)"CREATE DATABASE test_odbc_current", SQL_NTS); mystmt(hstmt,rc); strcpy(cur_db, "test_odbc_current"); @@ -1026,7 +1025,7 @@ rc = SQLGetConnectAttr(hdbc, SQL_ATTR_CURRENT_CATALOG, (char *)db, 255, &len); mycon(hdbc,rc); - fprintf(stdout,"current_catalog: %s (%ld)\n", db, len); + fprintf(stdout,"current_catalog: %s (%d)\n", db, len); myassert(strcmp(cur_db, db) == 0 || strlen(cur_db) == len); strcpy(cur_db, "test_odbc_current_12455"); @@ -1040,7 +1039,7 @@ rc = SQLSetConnectAttr(hdbc, SQL_ATTR_CURRENT_CATALOG, (SQLCHAR *)"test", SQL_NTS); mycon(hdbc,rc); - rc = SQLExecDirect(hstmt, "DROP DATABASE test_odbc_current", SQL_NTS); + rc = SQLExecDirect(hstmt, (SQLCHAR *)"DROP DATABASE test_odbc_current", SQL_NTS); mycon(hstmt,rc); return OK; @@ -1086,10 +1085,10 @@ r = SQLFreeStmt(hstmt, SQL_CLOSE); mystmt(hstmt,r); - r = SQLTables(hstmt,NULL,0,NULL,0,NULL,0,"'system table'",SQL_NTS); + r = SQLTables(hstmt,NULL,0,NULL,0,NULL,0,(SQLCHAR *)"'system table'",SQL_NTS); mystmt(hstmt,r); - if (driver_min_version(hdbc,"03.51.07",8)) + if (driver_min_version(hdbc,(SQLCHAR *)"03.51.07",8)) myassert(myresult(hstmt) != 0); else myassert(0 == myresult(hstmt)); @@ -1097,7 +1096,7 @@ r = SQLFreeStmt(hstmt, SQL_CLOSE); mystmt(hstmt,r); - r = SQLTables(hstmt,NULL,0,NULL,0,NULL,0,"TABLE",SQL_NTS); + r = SQLTables(hstmt,NULL,0,NULL,0,NULL,0,(SQLCHAR *)"TABLE",SQL_NTS); mystmt(hstmt,r); myresult(hstmt); @@ -1105,7 +1104,7 @@ r = SQLFreeStmt(hstmt, SQL_CLOSE); mystmt(hstmt,r); - r = SQLTables(hstmt,"TEST",SQL_NTS,"TEST",SQL_NTS,NULL,0,"TABLE",SQL_NTS); + r = SQLTables(hstmt,(SQLCHAR *)"TEST",SQL_NTS,(SQLCHAR *)"TEST",SQL_NTS,NULL,0,(SQLCHAR *)"TABLE",SQL_NTS); mystmt(hstmt,r); myresult(hstmt); @@ -1113,7 +1112,7 @@ r = SQLFreeStmt(hstmt, SQL_CLOSE); mystmt(hstmt,r); - r = SQLTables(hstmt,"%",SQL_NTS,NULL,0,NULL,0,NULL,0); + r = SQLTables(hstmt,(SQLCHAR *)"%",SQL_NTS,NULL,0,NULL,0,NULL,0); mystmt(hstmt,r); myresult(hstmt); @@ -1121,7 +1120,7 @@ r = SQLFreeStmt(hstmt, SQL_CLOSE); mystmt(hstmt,r); - r = SQLTables(hstmt,NULL,0,"%",SQL_NTS,NULL,0,NULL,0); + r = SQLTables(hstmt,NULL,0,(SQLCHAR *)"%",SQL_NTS,NULL,0,NULL,0); mystmt(hstmt,r); myresult(hstmt); @@ -1129,10 +1128,10 @@ r = SQLFreeStmt(hstmt, SQL_CLOSE); mystmt(hstmt,r); - r = SQLTables(hstmt,NULL,0,NULL,0,NULL,0,"%",SQL_NTS); + r = SQLTables(hstmt,NULL,0,NULL,0,NULL,0,(SQLCHAR *)"%",SQL_NTS); mystmt(hstmt,r); - if (driver_min_version(hdbc,"03.51.07",8)) + if (driver_min_version(hdbc,(SQLCHAR *)"03.51.07",8)) myassert( 2 == myresult(hstmt)); else myassert( 1 == myresult(hstmt)); --- myodbc-3.51.15r409.orig/test/my_curext.c +++ myodbc-3.51.15r409/test/my_curext.c @@ -31,17 +31,17 @@ SQLCHAR szData[255]={0}; /* initialize data */ - SQLExecDirect(hstmt,"drop table my_pcbValue",SQL_NTS); + SQLExecDirect(hstmt,(SQLCHAR *)"drop table my_pcbValue",SQL_NTS); - rc = SQLExecDirect(hstmt,"create table my_pcbValue(id int, name varchar(30),\ + rc = SQLExecDirect(hstmt,(SQLCHAR *)"create table my_pcbValue(id int, name varchar(30),\ name1 varchar(30),\ name2 varchar(30))",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_pcbValue(id,name) values(100,'venu')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_pcbValue(id,name) values(100,'venu')",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_pcbValue(id,name) values(200,'monty')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_pcbValue(id,name) values(200,'monty')",SQL_NTS); mystmt(hstmt,rc); rc = SQLTransact(NULL,hdbc,SQL_COMMIT); @@ -72,7 +72,7 @@ mystmt(hstmt, rc); /* Open the resultset of table 'my_demo_cursor' */ - rc = SQLExecDirect(hstmt,"SELECT * FROM my_pcbValue",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"SELECT * FROM my_pcbValue",SQL_NTS); mystmt(hstmt,rc); /* goto the last row */ @@ -109,7 +109,7 @@ mycon(hdbc,rc); /* Now fetch and verify the data */ - rc = SQLExecDirect(hstmt, "SELECT * FROM my_pcbValue",SQL_NTS); + rc = SQLExecDirect(hstmt, (SQLCHAR *)"SELECT * FROM my_pcbValue",SQL_NTS); mystmt(hstmt,rc); rc = SQLFetch(hstmt); @@ -159,17 +159,17 @@ SQLCHAR szData[255]={0}; /* initialize data */ - SQLExecDirect(hstmt,"drop table my_pcbValue_add",SQL_NTS); + SQLExecDirect(hstmt,(SQLCHAR *)"drop table my_pcbValue_add",SQL_NTS); - rc = SQLExecDirect(hstmt,"create table my_pcbValue_add(id int, name varchar(30),\ + rc = SQLExecDirect(hstmt,(SQLCHAR *)"create table my_pcbValue_add(id int, name varchar(30),\ name1 varchar(30),\ name2 varchar(30))",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_pcbValue_add(id,name) values(100,'venu')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_pcbValue_add(id,name) values(100,'venu')",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_pcbValue_add(id,name) values(200,'monty')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_pcbValue_add(id,name) values(200,'monty')",SQL_NTS); mystmt(hstmt,rc); rc = SQLTransact(NULL,hdbc,SQL_COMMIT); @@ -200,7 +200,7 @@ mystmt(hstmt, rc); /* Open the resultset of table 'my_pcbValue_add' */ - rc = SQLExecDirect(hstmt,"SELECT * FROM my_pcbValue_add",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"SELECT * FROM my_pcbValue_add",SQL_NTS); mystmt(hstmt,rc); /* goto the last row */ @@ -237,7 +237,7 @@ mycon(hdbc,rc); /* Now fetch and verify the data */ - rc = SQLExecDirect(hstmt, "SELECT * FROM my_pcbValue_add",SQL_NTS); + rc = SQLExecDirect(hstmt, (SQLCHAR *)"SELECT * FROM my_pcbValue_add",SQL_NTS); mystmt(hstmt,rc); rc = SQLFetch(hstmt); @@ -286,13 +286,13 @@ SQLRETURN rc; /* initialize data */ - rc = SQLExecDirect(hstmt,"DROP TABLE IF EXISTS TestColNames",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"DROP TABLE IF EXISTS TestColNames",SQL_NTS); mystmt(hstmt,rc); rc = SQLTransact(NULL,hdbc,SQL_COMMIT); mycon(hdbc,rc); - rc = SQLExecDirect(hstmt,"CREATE TABLE `TestColNames`(`Value One` text,\ + rc = SQLExecDirect(hstmt,(SQLCHAR *)"CREATE TABLE `TestColNames`(`Value One` text,\ `Value Two` text,\ `Value Three` text)",SQL_NTS); mystmt(hstmt,rc); @@ -300,10 +300,10 @@ rc = SQLTransact(NULL,hdbc,SQL_COMMIT); mycon(hdbc,rc); - rc = SQLExecDirect(hstmt,"INSERT INTO TestColNames VALUES ('venu','anuganti','mysql ab')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"INSERT INTO TestColNames VALUES ('venu','anuganti','mysql ab')",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"INSERT INTO TestColNames VALUES ('monty','widenius','mysql ab')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"INSERT INTO TestColNames VALUES ('monty','widenius','mysql ab')",SQL_NTS); mystmt(hstmt,rc); rc = SQLTransact(NULL,hdbc,SQL_COMMIT); @@ -312,7 +312,7 @@ rc = SQLFreeStmt(hstmt,SQL_CLOSE); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"SELECT * FROM `TestColNames`",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"SELECT * FROM `TestColNames`",SQL_NTS); mystmt(hstmt,rc); myassert(2 == my_print_non_format_result(hstmt)); @@ -320,7 +320,7 @@ rc = SQLFreeStmt(hstmt,SQL_CLOSE); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"SELECT `Value One`,`Value Two`,`Value Three` FROM `TestColNames`",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"SELECT `Value One`,`Value Two`,`Value Three` FROM `TestColNames`",SQL_NTS); mystmt(hstmt,rc); myassert(2 == my_print_non_format_result(hstmt)); @@ -340,12 +340,12 @@ SQLCHAR szData[255]={0}; /* initialize data */ - SQLExecDirect(hstmt,"drop table my_empty_string",SQL_NTS); + SQLExecDirect(hstmt,(SQLCHAR *)"drop table my_empty_string",SQL_NTS); - rc = SQLExecDirect(hstmt,"create table my_empty_string(name varchar(30))",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"create table my_empty_string(name varchar(30))",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_empty_string values('')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_empty_string values('')",SQL_NTS); mystmt(hstmt,rc); rc = SQLTransact(NULL,hdbc,SQL_COMMIT); @@ -355,7 +355,7 @@ mystmt(hstmt,rc); /* Now fetch and verify the data */ - rc = SQLExecDirect(hstmt, "SELECT * FROM my_empty_string",SQL_NTS); + rc = SQLExecDirect(hstmt, (SQLCHAR *)"SELECT * FROM my_empty_string",SQL_NTS); mystmt(hstmt,rc); rc = SQLFetch(hstmt); --- myodbc-3.51.15r409.orig/test/my_cursor.c +++ myodbc-3.51.15r409/test/my_cursor.c @@ -677,7 +677,7 @@ SQLSetStmtAttr(hstmt1, SQL_ATTR_CURSOR_TYPE, (SQLPOINTER) SQL_CURSOR_DYNAMIC, 0); SQLSetStmtOption(hstmt1,SQL_SIMULATE_CURSOR,SQL_SC_NON_UNIQUE); - rc = SQLSetCursorName(hstmt,"venu_cur",8); + rc = SQLSetCursorName(hstmt,(SQLCHAR *)"venu_cur",8); mystmt(hstmt,rc); rc = SQLGetStmtAttr(hstmt, SQL_ATTR_CURSOR_TYPE, &cur_type, 0, NULL); @@ -697,12 +697,12 @@ rc = SQLSetPos(hstmt,1,SQL_POSITION,SQL_LOCK_NO_CHANGE); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt1,"DELETE FROM t_pos_delete WHERE CURRENT OF venu_cur",SQL_NTS); + rc = SQLExecDirect(hstmt1,(SQLCHAR *)"DELETE FROM t_pos_delete WHERE CURRENT OF venu_cur",SQL_NTS); mystmt(hstmt1,rc); rc = SQLRowCount(hstmt1,&row_count); mystmt(hstmt1,rc); - fprintf(stdout, "rows affected: %d\n", row_count); + fprintf(stdout, "rows affected: %ld\n", row_count); myassert(row_count == 1); rc = SQLExtendedFetch(hstmt,SQL_FETCH_NEXT,1,NULL,&rgfRowStatus); @@ -719,12 +719,12 @@ rc = SQLSetPos(hstmt,1,SQL_POSITION,SQL_LOCK_NO_CHANGE); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt1,"DELETE FROM t_pos_delete WHERE CURRENT OF venu_cur",SQL_NTS); + rc = SQLExecDirect(hstmt1,(SQLCHAR *)"DELETE FROM t_pos_delete WHERE CURRENT OF venu_cur",SQL_NTS); mystmt(hstmt1,rc); rc = SQLRowCount(hstmt1,&row_count); mystmt(hstmt1,rc); - fprintf(stdout, "rows affected: %d\n", row_count); + fprintf(stdout, "rows affected: %ld\n", row_count); myassert(row_count == 1); SQLFreeStmt(hstmt,SQL_UNBIND); @@ -798,7 +798,7 @@ myassert(!strcmp(curname,"SQL_CUR0")); } - rc = SQLSetCursorName(hstmt1,"venucur123",7); + rc = SQLSetCursorName(hstmt1,(SQLCHAR *)"venucur123",7); mystmt(hstmt1,rc); rc = SQLGetCursorName(hstmt1,curname,8,&nlen); @@ -1056,7 +1056,7 @@ rc = SQLFreeStmt(hstmt,SQL_CLOSE); mystmt(hstmt,rc); - rc = SQLSetCursorName(hstmt,"venu",SQL_NTS); + rc = SQLSetCursorName(hstmt,(SQLCHAR *)"venu",SQL_NTS); mystmt(hstmt,rc); rc = tmysql_exec(hstmt,"select * from tmysql_setpos"); @@ -1106,7 +1106,7 @@ rc = SQLFreeStmt(hstmt,SQL_CLOSE); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"DELETE FROM tmysql_setpos WHERE col2 = 'updated'",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"DELETE FROM tmysql_setpos WHERE col2 = 'updated'",SQL_NTS); mystmt(hstmt,rc); rc = SQLRowCount(hstmt,&nlen); @@ -1156,7 +1156,7 @@ rc = SQLFreeStmt(hstmt,SQL_CLOSE); mystmt(hstmt,rc); - rc = SQLSetCursorName(hstmt,"venu",SQL_NTS); + rc = SQLSetCursorName(hstmt,(SQLCHAR *)"venu",SQL_NTS); mystmt(hstmt,rc); rc = tmysql_exec(hstmt,"select * from tmysql_setpos_add"); @@ -1253,7 +1253,7 @@ rc = SQLFreeStmt(hstmt,SQL_CLOSE); mystmt(hstmt,rc); - rc = SQLSetCursorName(hstmt,"venu_cur",SQL_NTS); + rc = SQLSetCursorName(hstmt,(SQLCHAR *)"venu_cur",SQL_NTS); mystmt(hstmt,rc); rc = tmysql_exec(hstmt,"select * from tmysql_pos_delete"); @@ -1265,16 +1265,16 @@ rc = SQLSetPos(hstmt,1,SQL_POSITION,SQL_LOCK_NO_CHANGE); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt1," DfffELETE FROM tmysql_pos_delete WHERE CURRENT OF venu_cur",SQL_NTS); + rc = SQLExecDirect(hstmt1,(SQLCHAR *)" DfffELETE FROM tmysql_pos_delete WHERE CURRENT OF venu_cur",SQL_NTS); mystmt_r(hstmt1,rc); - rc = SQLExecDirect(hstmt1," DELETE FROM tmysql_pos_delete WHERE CURRENT OF venu_cur curs",SQL_NTS); + rc = SQLExecDirect(hstmt1,(SQLCHAR *)" DELETE FROM tmysql_pos_delete WHERE CURRENT OF venu_cur curs",SQL_NTS); mystmt_r(hstmt1,rc); - rc = SQLExecDirect(hstmt1," DELETE FROM tmysql_pos_delete WHERE ONE CURRENT OF venu_cur",SQL_NTS); + rc = SQLExecDirect(hstmt1,(SQLCHAR *)" DELETE FROM tmysql_pos_delete WHERE ONE CURRENT OF venu_cur",SQL_NTS); mystmt_r(hstmt1,rc); - rc = SQLExecDirect(hstmt1," DELETE FROM tmysql_pos_delete WHERE CURRENT OF venu_cur",SQL_NTS); + rc = SQLExecDirect(hstmt1,(SQLCHAR *)" DELETE FROM tmysql_pos_delete WHERE CURRENT OF venu_cur",SQL_NTS); mystmt(hstmt1,rc); SQLNumResultCols(hstmt1,&rgfRowStatus); @@ -1426,7 +1426,7 @@ SQLHSTMT hstmt1; SQLUINTEGER pcrow; SQLLEN rows; - SQLSMALLINT rgfRowStatus; + SQLUSMALLINT rgfRowStatus; SQLCHAR cursor[30], sql[100], data[]= "tmysql_pos_update_ex1"; ok_sql(hstmt, "DROP TABLE IF EXISTS t_pos_updex1"); @@ -1717,7 +1717,7 @@ rc = SQLFreeStmt(hstmt,SQL_CLOSE); mystmt(hstmt,rc); - rc = SQLSetCursorName(hstmt,"venu",SQL_NTS); + rc = SQLSetCursorName(hstmt,(SQLCHAR *)"venu",SQL_NTS); mystmt(hstmt,rc); /* FULL JOIN */ @@ -1783,7 +1783,7 @@ rc = SQLFreeStmt(hstmt,SQL_CLOSE); mystmt(hstmt,rc); - rc = SQLSetCursorName(hstmt,"venu",SQL_NTS); + rc = SQLSetCursorName(hstmt,(SQLCHAR *)"venu",SQL_NTS); mystmt(hstmt,rc); rc = tmysql_exec(hstmt,"select * from tmysql_setpos1"); @@ -1856,7 +1856,7 @@ ok_stmt(hstmt, SQLFreeStmt(hstmt, SQL_CLOSE)); - ok_stmt(hstmt, SQLSetCursorName(hstmt, "venu", SQL_NTS)); + ok_stmt(hstmt, SQLSetCursorName(hstmt, (SQLCHAR *)"venu", SQL_NTS)); ok_sql(hstmt,"SELECT col1 AS id, col2 AS name FROM t_alias_setpos_pkdel"); @@ -1915,7 +1915,7 @@ ok_stmt(hstmt, SQLFreeStmt(hstmt, SQL_CLOSE)); - ok_stmt(hstmt, SQLSetCursorName(hstmt, "venu", SQL_NTS)); + ok_stmt(hstmt, SQLSetCursorName(hstmt, (SQLCHAR *)"venu", SQL_NTS)); ok_sql(hstmt,"SELECT col1 AS id, col2 AS name FROM t_alias_setpos_del"); @@ -1983,7 +1983,7 @@ rc = SQLFreeStmt(hstmt,SQL_CLOSE); mystmt(hstmt,rc); - rc = SQLSetCursorName(hstmt,"venu",SQL_NTS); + rc = SQLSetCursorName(hstmt,(SQLCHAR *)"venu",SQL_NTS); mystmt(hstmt,rc); rc = tmysql_exec(hstmt,"select col2,col3 from tmysql_setpos1"); @@ -2063,7 +2063,7 @@ rc = SQLFreeStmt(hstmt,SQL_CLOSE); mystmt(hstmt,rc); - rc = SQLSetCursorName(hstmt,"venu",SQL_NTS); + rc = SQLSetCursorName(hstmt,(SQLCHAR *)"venu",SQL_NTS); mystmt(hstmt,rc); rc = tmysql_exec(hstmt,"select col2,col3 from tmysql_setpos1"); @@ -2139,7 +2139,7 @@ rc = SQLFreeStmt(hstmt,SQL_CLOSE); mystmt(hstmt,rc); - rc = SQLSetCursorName(hstmt,"venu",SQL_NTS); + rc = SQLSetCursorName(hstmt,(SQLCHAR *)"venu",SQL_NTS); mystmt(hstmt,rc); rc = tmysql_exec(hstmt,"select col1 from tmysql_setpos1"); @@ -2265,7 +2265,7 @@ rc = SQLFreeStmt(hstmt,SQL_CLOSE); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"DELETE FROM t_setpos_upd_bug1 WHERE fname = 'update'",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"DELETE FROM t_setpos_upd_bug1 WHERE fname = 'update'",SQL_NTS); mystmt(hstmt,rc); rc = SQLRowCount(hstmt,&len); @@ -2315,7 +2315,7 @@ rc = SQLFreeStmt(hstmt,SQL_CLOSE); mystmt(hstmt,rc); - rc = SQLSetCursorName(hstmt,"venu",SQL_NTS); + rc = SQLSetCursorName(hstmt,(SQLCHAR *)"venu",SQL_NTS); mystmt(hstmt,rc); rc = tmysql_exec(hstmt,"select * from my_setpos_upd_pk_order"); @@ -2357,7 +2357,7 @@ rc = SQLFreeStmt(hstmt,SQL_CLOSE); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"DELETE FROM my_setpos_upd_pk_order WHERE col2 = 'updated'",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"DELETE FROM my_setpos_upd_pk_order WHERE col2 = 'updated'",SQL_NTS); mystmt(hstmt,rc); rc = SQLRowCount(hstmt,&nlen); --- myodbc-3.51.15r409.orig/test/my_datetime.c +++ myodbc-3.51.15r409/test/my_datetime.c @@ -142,7 +142,7 @@ mystmt(hstmt,rc); /* TIMESTAMP TO DATE, TIME and TS CONVERSION */ - rc = SQLPrepare(hstmt,"insert into t_tstotime(col1,col2,col3) values(?,?,?)",SQL_NTS); + rc = SQLPrepare(hstmt,(SQLCHAR *)"insert into t_tstotime(col1,col2,col3) values(?,?,?)",SQL_NTS); mystmt(hstmt,rc); rc = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT,SQL_C_TIMESTAMP, @@ -197,7 +197,7 @@ /* TIMESTAMP TO DATE, TIME and TS CONVERSION */ ok_stmt(hstmt, SQLPrepare(hstmt, - "INSERT INTO t_tstotime1 VALUES (?,?,?)", + (SQLCHAR *)"INSERT INTO t_tstotime1 VALUES (?,?,?)", SQL_NTS)); ok_stmt(hstmt, SQLBindParameter(hstmt,1,SQL_PARAM_INPUT,SQL_C_CHAR, @@ -228,11 +228,9 @@ DECLARE_TEST(t_bug25846) { - SQLINTEGER narg; - SQLSMALLINT column_count; - SQLINTEGER my_time_cb; - SQLINTEGER my_date_cb; + SQLLEN my_time_cb; + SQLLEN my_date_cb; SQL_TIMESTAMP_STRUCT my_time_ts; SQL_TIMESTAMP_STRUCT my_date_ts; @@ -285,7 +283,7 @@ rc = SQLTransact(NULL,hdbc,SQL_COMMIT); mycon(hdbc,rc); - rc = SQLPrepare(hstmt,"insert into t_time values (?,?)",SQL_NTS); + rc = SQLPrepare(hstmt,(SQLCHAR *)"insert into t_time values (?,?)",SQL_NTS); mystmt(hstmt,rc); rc = SQLBindParameter( hstmt, 1, SQL_PARAM_INPUT, SQL_C_TIME, @@ -312,7 +310,7 @@ rc = SQLTransact(NULL,hdbc,SQL_COMMIT); mycon(hdbc,rc); - rc = SQLExecDirect(hstmt,"select tm from t_time",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"select tm from t_time",SQL_NTS); mystmt(hstmt,rc); rc = SQLFetch(hstmt); @@ -344,11 +342,11 @@ SQLCHAR data[30]; SQLLEN length; - SQLExecDirect(hstmt,"drop table t_time",SQL_NTS); - rc = SQLExecDirect(hstmt,"create table t_time(t time, t1 timestamp, t2 datetime, t3 date)",SQL_NTS); + SQLExecDirect(hstmt,(SQLCHAR *)"drop table t_time",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"create table t_time(t time, t1 timestamp, t2 datetime, t3 date)",SQL_NTS); mystmt(hstmt,rc); - rc = SQLPrepare(hstmt,"insert into t_time(t) values(?)",SQL_NTS); + rc = SQLPrepare(hstmt,(SQLCHAR *)"insert into t_time(t) values(?)",SQL_NTS); mystmt(hstmt,rc); rc = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT,SQL_C_TYPE_TIME, @@ -428,7 +426,7 @@ SQLFreeStmt(hstmt, SQL_RESET_PARAMS); SQLFreeStmt(hstmt, SQL_CLOSE); - rc = SQLExecDirect(hstmt,"select t from t_time",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"select t from t_time",SQL_NTS); mystmt(hstmt,rc); rc = SQLFetch(hstmt); @@ -436,7 +434,7 @@ rc = SQLGetData(hstmt, 1, SQL_C_CHAR, data, sizeof(data), &length); mystmt(hstmt,rc); - fprintf(stdout,"time: %s(%d)\n", data, length); + fprintf(stdout,"time: %s(%ld)\n", data, length); myassert(strcmp(data,"00:00:03")==0); myassert(length == 8); @@ -445,7 +443,7 @@ rc = SQLGetData(hstmt, 1, SQL_C_CHAR, data, sizeof(data), &length); mystmt(hstmt,rc); - fprintf(stdout,"time: %s(%d)\n", data, length); + fprintf(stdout,"time: %s(%ld)\n", data, length); myassert(strcmp(data,"01:00:00")==0); myassert(length == 8); @@ -454,7 +452,7 @@ rc = SQLGetData(hstmt, 1, SQL_C_CHAR, data, sizeof(data), &length); mystmt(hstmt,rc); - fprintf(stdout,"time: %s(%d)\n", data, length); + fprintf(stdout,"time: %s(%ld)\n", data, length); myassert(strcmp(data,"19:00:00")==0); myassert(length == 8); @@ -463,7 +461,7 @@ rc = SQLGetData(hstmt, 1, SQL_C_CHAR, data, sizeof(data), &length); mystmt(hstmt,rc); - fprintf(stdout,"time: %s(%d)\n", data, length); + fprintf(stdout,"time: %s(%ld)\n", data, length); myassert(strcmp(data,"01:01:00")==0); myassert(length == 8); @@ -472,7 +470,7 @@ rc = SQLGetData(hstmt, 1, SQL_C_CHAR, data, sizeof(data), &length); mystmt(hstmt,rc); - fprintf(stdout,"time: %s(%d)\n", data, length); + fprintf(stdout,"time: %s(%ld)\n", data, length); myassert(strcmp(data,"01:00:01")==0); myassert(length == 8); @@ -481,7 +479,7 @@ rc = SQLGetData(hstmt, 1, SQL_C_CHAR, data, sizeof(data), &length); mystmt(hstmt,rc); - fprintf(stdout,"time: %s(%d)\n", data, length); + fprintf(stdout,"time: %s(%ld)\n", data, length); myassert(strcmp(data,"00:01:00")==0); myassert(length == 8); @@ -490,7 +488,7 @@ rc = SQLGetData(hstmt, 1, SQL_C_CHAR, data, sizeof(data), &length); mystmt(hstmt,rc); - fprintf(stdout,"time: %s(%d)\n", data, length); + fprintf(stdout,"time: %s(%ld)\n", data, length); myassert(strcmp(data,"00:11:12")==0); myassert(length == 8); @@ -499,7 +497,7 @@ rc = SQLGetData(hstmt, 1, SQL_C_CHAR, data, sizeof(data), &length); mystmt(hstmt,rc); - fprintf(stdout,"time: %s(%d)\n", data, length); + fprintf(stdout,"time: %s(%ld)\n", data, length); myassert(strcmp(data,"01:01:01")==0); myassert(length == 8); @@ -508,7 +506,7 @@ rc = SQLGetData(hstmt, 1, SQL_C_CHAR, data, sizeof(data), &length); mystmt(hstmt,rc); - fprintf(stdout,"time: %s(%d)\n", data, length); + fprintf(stdout,"time: %s(%ld)\n", data, length); myassert(strcmp(data,"00:00:00")==0); myassert(length == 8); @@ -518,7 +516,7 @@ rc = SQLGetData(hstmt, 1, SQL_C_CHAR, data, sizeof(data), &length); mystmt(hstmt,rc); - fprintf(stdout,"time: %s(%d)\n", data, length); + fprintf(stdout,"time: %s(%ld)\n", data, length); myassert(strcmp(data,"10:11:12")==0); myassert(length == 8); @@ -528,13 +526,13 @@ SQLFreeStmt(hstmt, SQL_UNBIND); SQLFreeStmt(hstmt, SQL_CLOSE); - rc = SQLExecDirect(hstmt,"delete from t_time",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"delete from t_time",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into t_time(t1) values('2003-05-12 10:11:12')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into t_time(t1) values('2003-05-12 10:11:12')",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"select t1 from t_time", SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"select t1 from t_time", SQL_NTS); mystmt(hstmt,rc); rc = SQLFetch(hstmt); @@ -542,7 +540,7 @@ rc = SQLGetData(hstmt, 1, SQL_C_TIME, &tt, sizeof(tt), &length); mystmt(hstmt,rc); - fprintf(stdout,"time: %d:%d:%d(%d)\n", tt.hour, tt.minute, tt.second, length); + fprintf(stdout,"time: %d:%d:%d(%ld)\n", tt.hour, tt.minute, tt.second, length); myassert(tt.hour == 10 && tt.minute == 11 && tt.second == 12); myassert(length == sizeof(SQL_TIME_STRUCT)); @@ -553,13 +551,13 @@ SQLFreeStmt(hstmt, SQL_UNBIND); SQLFreeStmt(hstmt, SQL_CLOSE); - rc = SQLExecDirect(hstmt,"delete from t_time",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"delete from t_time",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into t_time(t2) values('03-12-28 05:59:59')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into t_time(t2) values('03-12-28 05:59:59')",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"select t2 from t_time", SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"select t2 from t_time", SQL_NTS); mystmt(hstmt,rc); rc = SQLFetch(hstmt); @@ -567,7 +565,7 @@ rc = SQLGetData(hstmt, 1, SQL_C_TIME, &tt, sizeof(tt), &length); mystmt(hstmt,rc); - fprintf(stdout,"time: %d:%d:%d(%d)\n", tt.hour, tt.minute, tt.second, length); + fprintf(stdout,"time: %d:%d:%d(%ld)\n", tt.hour, tt.minute, tt.second, length); myassert(tt.hour == 05 && tt.minute == 59 && tt.second == 59); myassert(length == sizeof(SQL_TIME_STRUCT)); @@ -577,13 +575,13 @@ SQLFreeStmt(hstmt, SQL_UNBIND); SQLFreeStmt(hstmt, SQL_CLOSE); - rc = SQLExecDirect(hstmt,"delete from t_time",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"delete from t_time",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into t_time(t3) values('2003-05-12 10:11:12')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into t_time(t3) values('2003-05-12 10:11:12')",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"select t3 from t_time", SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"select t3 from t_time", SQL_NTS); mystmt(hstmt,rc); rc = SQLFetch(hstmt); @@ -591,7 +589,7 @@ rc = SQLGetData(hstmt, 1, SQL_C_TIME, &tt, sizeof(tt), &length); mystmt(hstmt,rc); - fprintf(stdout,"time: %d:%d:%d(%d)\n", tt.hour, tt.minute, tt.second, length); + fprintf(stdout,"time: %d:%d:%d(%ld)\n", tt.hour, tt.minute, tt.second, length); myassert(tt.hour == 00 || tt.minute == 00 || tt.second == 00); myassert(length == sizeof(SQL_TIME_STRUCT)); @@ -611,7 +609,7 @@ */ DECLARE_TEST(t_bug12520) { - SQLINTEGER my_time_cb; + SQLLEN my_time_cb; SQL_TIMESTAMP_STRUCT my_time_ts; SQLLEN len; SQLCHAR datetime[50]; @@ -627,7 +625,7 @@ ok_stmt(hstmt, SQLBindCol(hstmt, 1, SQL_C_CHAR, datetime, sizeof(datetime), &len)); - ok_stmt(hstmt, SQLBindCol(hstmt, 2, SQL_C_TIMESTAMP, &my_time_ts, NULL, + ok_stmt(hstmt, SQLBindCol(hstmt, 2, SQL_C_TIMESTAMP, &my_time_ts, 0, &my_time_cb)); ok_stmt(hstmt, SQLFetch(hstmt)); --- myodbc-3.51.15r409.orig/test/my_dyn_cursor.c +++ myodbc-3.51.15r409/test/my_dyn_cursor.c @@ -32,15 +32,15 @@ SQLCHAR szData[255]={0}; /* initialize data */ - SQLExecDirect(hstmt,"drop table my_dynamic_cursor",SQL_NTS); + SQLExecDirect(hstmt,(SQLCHAR *)"drop table my_dynamic_cursor",SQL_NTS); - rc = SQLExecDirect(hstmt,"create table my_dynamic_cursor(id int, name varchar(30))",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"create table my_dynamic_cursor(id int, name varchar(30))",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_dynamic_cursor values(100,'venu')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_dynamic_cursor values(100,'venu')",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_dynamic_cursor values(200,'monty')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_dynamic_cursor values(200,'monty')",SQL_NTS); mystmt(hstmt,rc); rc = SQLTransact(NULL,hdbc,SQL_COMMIT); @@ -54,7 +54,7 @@ mycon(hdbc, rc); /* set the cursor name as 'mysqlcur' on hstmt */ - rc = SQLSetCursorName(hstmt, "mysqlcur", SQL_NTS); + rc = SQLSetCursorName(hstmt, (SQLCHAR *)"mysqlcur", SQL_NTS); mystmt(hstmt, rc); rc = SQLBindCol(hstmt,1,SQL_C_LONG,&nData,0,NULL); @@ -73,7 +73,7 @@ mystmt(hstmt, rc); /* Open the resultset of table 'my_demo_cursor' */ - rc = SQLExecDirect(hstmt,"SELECT * FROM my_dynamic_cursor",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"SELECT * FROM my_dynamic_cursor",SQL_NTS); mystmt(hstmt,rc); /* goto the last row */ @@ -81,7 +81,7 @@ mystmt(hstmt,rc); /* now update the name field to 'update' using positioned cursor */ - rc = SQLExecDirect(hstmt_pos, "UPDATE my_dynamic_cursor SET id=300, name='updated' WHERE CURRENT OF mysqlcur", SQL_NTS); + rc = SQLExecDirect(hstmt_pos, (SQLCHAR *)"UPDATE my_dynamic_cursor SET id=300, name='updated' WHERE CURRENT OF mysqlcur", SQL_NTS); mystmt(hstmt_pos, rc); rc = SQLRowCount(hstmt_pos, &nRowCount); @@ -128,7 +128,7 @@ mystmt(hstmt_pos,rc); /* Now fetch and verify the data */ - rc = SQLExecDirect(hstmt, "SELECT * FROM my_dynamic_cursor",SQL_NTS); + rc = SQLExecDirect(hstmt, (SQLCHAR *)"SELECT * FROM my_dynamic_cursor",SQL_NTS); mystmt(hstmt,rc); rc = SQLFetch(hstmt); @@ -165,30 +165,30 @@ char data[30],szData[15][10]={0}; /* initialize data */ - SQLExecDirect(hstmt,"drop table my_dynamic_cursor",SQL_NTS); + SQLExecDirect(hstmt,(SQLCHAR *)"drop table my_dynamic_cursor",SQL_NTS); - rc = SQLExecDirect(hstmt,"create table my_dynamic_cursor(id int, name varchar(30))",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"create table my_dynamic_cursor(id int, name varchar(30))",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_dynamic_cursor values(1,'MySQL1')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_dynamic_cursor values(1,'MySQL1')",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_dynamic_cursor values(2,'MySQL2')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_dynamic_cursor values(2,'MySQL2')",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_dynamic_cursor values(3,'MySQL3')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_dynamic_cursor values(3,'MySQL3')",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_dynamic_cursor values(4,'MySQL4')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_dynamic_cursor values(4,'MySQL4')",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_dynamic_cursor values(5,'MySQL5')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_dynamic_cursor values(5,'MySQL5')",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_dynamic_cursor values(6,'MySQL6')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_dynamic_cursor values(6,'MySQL6')",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_dynamic_cursor values(7,'MySQL7')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_dynamic_cursor values(7,'MySQL7')",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_dynamic_cursor values(8,'MySQL8')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_dynamic_cursor values(8,'MySQL8')",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_dynamic_cursor values(9,'MySQL9')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_dynamic_cursor values(9,'MySQL9')",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_dynamic_cursor values(10,'MySQL10')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_dynamic_cursor values(10,'MySQL10')",SQL_NTS); mystmt(hstmt,rc); SQLFreeStmt(hstmt,SQL_CLOSE); @@ -201,7 +201,7 @@ mycon(hdbc, rc); /* set the cursor name as 'mysqlcur' on hstmt */ - rc = SQLSetCursorName(hstmt, "mysqlcur", SQL_NTS); + rc = SQLSetCursorName(hstmt, (SQLCHAR *)"mysqlcur", SQL_NTS); mystmt(hstmt, rc); rc = SQLBindCol(hstmt,1,SQL_C_LONG,&nData,0,NULL); @@ -214,7 +214,7 @@ mystmt(hstmt,rc); /* Open the resultset of table 'my_demo_cursor' */ - rc = SQLExecDirect(hstmt,"SELECT * FROM my_dynamic_cursor",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"SELECT * FROM my_dynamic_cursor",SQL_NTS); mystmt(hstmt,rc); /* goto the last row */ @@ -225,7 +225,7 @@ mystmt(hstmt,rc); */ /* now update the name field to 'update' using positioned cursor */ - rc = SQLExecDirect(hstmt_pos, "UPDATE my_dynamic_cursor SET id=999, name='updated' WHERE CURRENT OF mysqlcur", SQL_NTS); + rc = SQLExecDirect(hstmt_pos, (SQLCHAR *)"UPDATE my_dynamic_cursor SET id=999, name='updated' WHERE CURRENT OF mysqlcur", SQL_NTS); mystmt(hstmt_pos, rc); rc = SQLRowCount(hstmt_pos, &nRowCount); @@ -270,7 +270,7 @@ rc = SQLSetStmtAttr(hstmt,SQL_ATTR_ROW_ARRAY_SIZE,(SQLPOINTER)1,0); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt, "SELECT * FROM my_dynamic_cursor",SQL_NTS); + rc = SQLExecDirect(hstmt, (SQLCHAR *)"SELECT * FROM my_dynamic_cursor",SQL_NTS); mystmt(hstmt,rc); rc = SQLBindCol(hstmt,1,SQL_C_LONG,&i,0,NULL); @@ -318,17 +318,17 @@ SQLINTEGER nData; SQLLEN nrow; - SQLExecDirect(hstmt,"drop table my_position",SQL_NTS); - rc = SQLExecDirect(hstmt,"create table my_position(col1 int, col2 varchar(30))",SQL_NTS); + SQLExecDirect(hstmt,(SQLCHAR *)"drop table my_position",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"create table my_position(col1 int, col2 varchar(30))",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_position values(100,'MySQL1')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_position values(100,'MySQL1')",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_position values(200,'MySQL2')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_position values(200,'MySQL2')",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_position values(300,'MySQL3')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_position values(300,'MySQL3')",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_position values(400,'MySQL4')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_position values(400,'MySQL4')",SQL_NTS); mystmt(hstmt,rc); rc = SQLTransact(NULL,hdbc,SQL_COMMIT); @@ -346,7 +346,7 @@ rc = SQLSetStmtAttr(hstmt, SQL_ATTR_ROW_ARRAY_SIZE ,(SQLPOINTER)1 , 0); mystmt(hstmt, rc); - rc = SQLExecDirect(hstmt,"select * from my_position",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"select * from my_position",SQL_NTS); mystmt(hstmt,rc); rc = SQLBindCol(hstmt,1,SQL_C_LONG,&nData,0,&nrow); @@ -379,7 +379,7 @@ rc = SQLFreeStmt(hstmt,SQL_CLOSE); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"select * from my_position",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"select * from my_position",SQL_NTS); mystmt(hstmt,rc); rc = SQLFetch(hstmt); @@ -423,33 +423,33 @@ SQLLEN nlen[15]= {0}, nrow[15]= {0}; char szData[15][15]={0}; - SQLExecDirect(hstmt,"drop table my_position",SQL_NTS); - rc = SQLExecDirect(hstmt,"create table my_position(col1 int, col2 varchar(30))",SQL_NTS); + SQLExecDirect(hstmt,(SQLCHAR *)"drop table my_position",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"create table my_position(col1 int, col2 varchar(30))",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_position values(1,'MySQL1')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_position values(1,'MySQL1')",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_position values(2,'MySQL2')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_position values(2,'MySQL2')",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_position values(3,'MySQL3')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_position values(3,'MySQL3')",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_position values(4,'MySQL4')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_position values(4,'MySQL4')",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_position values(5,'MySQL5')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_position values(5,'MySQL5')",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_position values(6,'MySQL6')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_position values(6,'MySQL6')",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_position values(7,'MySQL7')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_position values(7,'MySQL7')",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_position values(8,'MySQL8')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_position values(8,'MySQL8')",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_position values(9,'MySQL9')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_position values(9,'MySQL9')",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_position values(10,'MySQL10')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_position values(10,'MySQL10')",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_position values(11,'MySQL11')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_position values(11,'MySQL11')",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_position values(12,'MySQL12')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_position values(12,'MySQL12')",SQL_NTS); mystmt(hstmt,rc); rc = SQLTransact(NULL,hdbc,SQL_COMMIT); @@ -467,10 +467,10 @@ rc = SQLSetStmtAttr(hstmt, SQL_ATTR_ROW_ARRAY_SIZE ,(SQLPOINTER)3 , 0); mystmt(hstmt, rc); - rc = SQLExecDirect(hstmt,"select * from my_position",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"select * from my_position",SQL_NTS); mystmt(hstmt,rc); - rc = SQLBindCol(hstmt,1,SQL_C_LONG,&nData,0,&nrow); + rc = SQLBindCol(hstmt,1,SQL_C_LONG,&nData,0,nrow); mystmt(hstmt,rc); rc = SQLBindCol(hstmt,2,SQL_C_CHAR,szData,sizeof(szData[0]),nlen); @@ -496,7 +496,7 @@ rc = SQLFreeStmt(hstmt,SQL_CLOSE); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"select * from my_position",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"select * from my_position",SQL_NTS); mystmt(hstmt,rc); rc = SQLFetchScroll(hstmt,SQL_FETCH_ABSOLUTE,4); @@ -530,21 +530,21 @@ char szData[15][15]={0}; SQLINTEGER nData[15]; - SQLExecDirect(hstmt,"drop table my_zero_irow",SQL_NTS); - rc = SQLExecDirect(hstmt,"create table my_zero_irow(col1 int, col2 varchar(30))",SQL_NTS); + SQLExecDirect(hstmt,(SQLCHAR *)"drop table my_zero_irow",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"create table my_zero_irow(col1 int, col2 varchar(30))",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_zero_irow values(1,'MySQL1')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_zero_irow values(1,'MySQL1')",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_zero_irow values(2,'MySQL2')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_zero_irow values(2,'MySQL2')",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_zero_irow values(3,'MySQL3')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_zero_irow values(3,'MySQL3')",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_zero_irow values(4,'MySQL4')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_zero_irow values(4,'MySQL4')",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_zero_irow values(5,'MySQL5')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_zero_irow values(5,'MySQL5')",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_zero_irow values(6,'MySQL6')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_zero_irow values(6,'MySQL6')",SQL_NTS); mystmt(hstmt,rc); rc = SQLTransact(NULL,hdbc,SQL_COMMIT); @@ -562,7 +562,7 @@ rc = SQLSetStmtAttr(hstmt, SQL_ATTR_ROW_ARRAY_SIZE ,(SQLPOINTER)3 , 0); mystmt(hstmt, rc); - rc = SQLExecDirect(hstmt,"select * from my_zero_irow",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"select * from my_zero_irow",SQL_NTS); mystmt(hstmt,rc); rc = SQLBindCol(hstmt,1,SQL_C_LONG,&nData,0,nrow); @@ -588,7 +588,7 @@ rc = SQLFreeStmt(hstmt,SQL_CLOSE); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"select * from my_zero_irow",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"select * from my_zero_irow",SQL_NTS); mystmt(hstmt,rc); rc = SQLFetchScroll(hstmt,SQL_FETCH_ABSOLUTE,2); @@ -622,21 +622,21 @@ char szData[15][15]={0}; SQLINTEGER nData[15]; - SQLExecDirect(hstmt,"drop table my_zero_irow",SQL_NTS); - rc = SQLExecDirect(hstmt,"create table my_zero_irow(col1 int, col2 varchar(30))",SQL_NTS); + SQLExecDirect(hstmt,(SQLCHAR *)"drop table my_zero_irow",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"create table my_zero_irow(col1 int, col2 varchar(30))",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_zero_irow values(1,'MySQL1')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_zero_irow values(1,'MySQL1')",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_zero_irow values(2,'MySQL2')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_zero_irow values(2,'MySQL2')",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_zero_irow values(3,'MySQL3')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_zero_irow values(3,'MySQL3')",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_zero_irow values(4,'MySQL4')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_zero_irow values(4,'MySQL4')",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_zero_irow values(5,'MySQL5')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_zero_irow values(5,'MySQL5')",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_zero_irow values(6,'MySQL6')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_zero_irow values(6,'MySQL6')",SQL_NTS); mystmt(hstmt,rc); rc = SQLTransact(NULL,hdbc,SQL_COMMIT); @@ -654,7 +654,7 @@ rc = SQLSetStmtAttr(hstmt, SQL_ATTR_ROW_ARRAY_SIZE ,(SQLPOINTER)3 , 0); mystmt(hstmt, rc); - rc = SQLExecDirect(hstmt,"select * from my_zero_irow",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"select * from my_zero_irow",SQL_NTS); mystmt(hstmt,rc); rc = SQLBindCol(hstmt,1,SQL_C_LONG,&nData,0,nrow); @@ -672,7 +672,7 @@ rc = SQLFreeStmt(hstmt,SQL_CLOSE); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"select * from my_zero_irow",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"select * from my_zero_irow",SQL_NTS); mystmt(hstmt,rc); rc = SQLFetchScroll(hstmt,SQL_FETCH_ABSOLUTE,1); @@ -709,15 +709,15 @@ SQLCHAR szData[255]={0}; /* initialize data */ - SQLExecDirect(hstmt,"drop table my_dynamic_cursor",SQL_NTS); + SQLExecDirect(hstmt,(SQLCHAR *)"drop table my_dynamic_cursor",SQL_NTS); - rc = SQLExecDirect(hstmt,"create table my_dynamic_cursor(col1 int, col2 varchar(30))",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"create table my_dynamic_cursor(col1 int, col2 varchar(30))",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_dynamic_cursor values(100,'venu')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_dynamic_cursor values(100,'venu')",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_dynamic_cursor values(200,'monty')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_dynamic_cursor values(200,'monty')",SQL_NTS); mystmt(hstmt,rc); rc = SQLTransact(NULL,hdbc,SQL_COMMIT); @@ -733,7 +733,7 @@ mystmt(hstmt, rc); /* Now, add a row of data */ - rc = SQLExecDirect(hstmt,"select * from my_dynamic_cursor",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"select * from my_dynamic_cursor",SQL_NTS); mystmt(hstmt,rc); rc = SQLBindCol(hstmt,1,SQL_C_LONG,&nData,0,NULL); @@ -788,7 +788,7 @@ rc = SQLFreeStmt(hstmt,SQL_CLOSE); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"select * from my_dynamic_cursor",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"select * from my_dynamic_cursor",SQL_NTS); mystmt(hstmt,rc); myassert(6 == myresult(hstmt)); --- myodbc-3.51.15r409.orig/test/my_keys.c +++ myodbc-3.51.15r409/test/my_keys.c @@ -29,21 +29,21 @@ SQLROWCOUNT rowcount; SQLINTEGER nData; - SQLExecDirect(hstmt,"drop table my_primary_keys",SQL_NTS); - rc = SQLExecDirect(hstmt,"create table my_primary_keys(col1 int not null,\ + SQLExecDirect(hstmt,(SQLCHAR *)"drop table my_primary_keys",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"create table my_primary_keys(col1 int not null,\ col2 varchar(30) unique,\ col3 int unique not null,\ col4 int not null,\ primary key(col1))",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_primary_keys values(100,'MySQL1',1,3000)",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_primary_keys values(100,'MySQL1',1,3000)",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_primary_keys values(200,'MySQL2',2,3000)",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_primary_keys values(200,'MySQL2',2,3000)",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_primary_keys values(300,'MySQL3',3,3000)",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_primary_keys values(300,'MySQL3',3,3000)",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_primary_keys values(400,'MySQL4',4,3000)",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_primary_keys values(400,'MySQL4',4,3000)",SQL_NTS); mystmt(hstmt,rc); rc = SQLTransact(NULL,hdbc,SQL_COMMIT); @@ -61,7 +61,7 @@ rc = SQLSetStmtAttr(hstmt, SQL_ATTR_ROW_ARRAY_SIZE ,(SQLPOINTER)1 , 0); mystmt(hstmt, rc); - rc = SQLExecDirect(hstmt,"select col4 from my_primary_keys",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"select col4 from my_primary_keys",SQL_NTS); mystmt(hstmt,rc); rc = SQLBindCol(hstmt,1,SQL_C_LONG,&nData,100,NULL); @@ -87,7 +87,7 @@ rc = SQLFreeStmt(hstmt,SQL_CLOSE); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"select * from my_primary_keys",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"select * from my_primary_keys",SQL_NTS); mystmt(hstmt,rc); myassert(4 == myresult(hstmt)); @@ -95,7 +95,7 @@ rc = SQLFreeStmt(hstmt,SQL_CLOSE); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"select * from my_primary_keys",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"select * from my_primary_keys",SQL_NTS); mystmt(hstmt,rc); rc = SQLFetch(hstmt); @@ -130,20 +130,20 @@ SQLROWCOUNT rowcount; SQLINTEGER nData; - SQLExecDirect(hstmt,"drop table my_unique_notnull_keys",SQL_NTS); - rc = SQLExecDirect(hstmt,"create table my_unique_notnull_keys(col1 int not null,\ + SQLExecDirect(hstmt,(SQLCHAR *)"drop table my_unique_notnull_keys",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"create table my_unique_notnull_keys(col1 int not null,\ col2 varchar(30) unique,\ col3 int unique not null,\ col4 int not null)",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_unique_notnull_keys values(100,'MySQL1',1,3000)",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_unique_notnull_keys values(100,'MySQL1',1,3000)",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_unique_notnull_keys values(200,'MySQL2',2,3000)",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_unique_notnull_keys values(200,'MySQL2',2,3000)",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_unique_notnull_keys values(300,'MySQL3',3,3000)",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_unique_notnull_keys values(300,'MySQL3',3,3000)",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_unique_notnull_keys values(400,'MySQL4',4,3000)",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_unique_notnull_keys values(400,'MySQL4',4,3000)",SQL_NTS); mystmt(hstmt,rc); rc = SQLTransact(NULL,hdbc,SQL_COMMIT); @@ -161,7 +161,7 @@ rc = SQLSetStmtAttr(hstmt, SQL_ATTR_ROW_ARRAY_SIZE ,(SQLPOINTER)1 , 0); mystmt(hstmt, rc); - rc = SQLExecDirect(hstmt,"select col4 from my_unique_notnull_keys",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"select col4 from my_unique_notnull_keys",SQL_NTS); mystmt(hstmt,rc); rc = SQLBindCol(hstmt,1,SQL_C_LONG,&nData,100,NULL); @@ -187,7 +187,7 @@ rc = SQLFreeStmt(hstmt,SQL_CLOSE); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"select * from my_unique_notnull_keys",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"select * from my_unique_notnull_keys",SQL_NTS); mystmt(hstmt,rc); myassert(4 == myresult(hstmt)); @@ -195,7 +195,7 @@ rc = SQLFreeStmt(hstmt,SQL_CLOSE); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"select * from my_unique_notnull_keys",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"select * from my_unique_notnull_keys",SQL_NTS); mystmt(hstmt,rc); rc = SQLFetch(hstmt); @@ -231,20 +231,20 @@ SQLROWCOUNT rowcount; SQLINTEGER nData; - SQLExecDirect(hstmt,"drop table my_unique_keys",SQL_NTS); - rc = SQLExecDirect(hstmt,"create table my_unique_keys(col1 int not null,\ + SQLExecDirect(hstmt,(SQLCHAR *)"drop table my_unique_keys",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"create table my_unique_keys(col1 int not null,\ col2 varchar(30) unique,\ col3 int unique,\ col4 int not null)",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_unique_keys values(100,'MySQL1',1,3000)",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_unique_keys values(100,'MySQL1',1,3000)",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_unique_keys values(200,'MySQL2',2,3000)",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_unique_keys values(200,'MySQL2',2,3000)",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_unique_keys values(300,'MySQL3',3,3000)",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_unique_keys values(300,'MySQL3',3,3000)",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_unique_keys values(400,'MySQL4',4,3000)",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_unique_keys values(400,'MySQL4',4,3000)",SQL_NTS); mystmt(hstmt,rc); rc = SQLTransact(NULL,hdbc,SQL_COMMIT); @@ -262,7 +262,7 @@ rc = SQLSetStmtAttr(hstmt, SQL_ATTR_ROW_ARRAY_SIZE ,(SQLPOINTER)1 , 0); mystmt(hstmt, rc); - rc = SQLExecDirect(hstmt,"select col4 from my_unique_keys",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"select col4 from my_unique_keys",SQL_NTS); mystmt(hstmt,rc); rc = SQLBindCol(hstmt,1,SQL_C_LONG,&nData,100,NULL); @@ -288,7 +288,7 @@ rc = SQLFreeStmt(hstmt,SQL_CLOSE); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"select * from my_unique_keys",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"select * from my_unique_keys",SQL_NTS); mystmt(hstmt,rc); myassert(4 == myresult(hstmt)); @@ -296,7 +296,7 @@ rc = SQLFreeStmt(hstmt,SQL_CLOSE); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"select * from my_unique_keys",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"select * from my_unique_keys",SQL_NTS); mystmt(hstmt,rc); rc = SQLFetch(hstmt); @@ -329,24 +329,23 @@ DECLARE_TEST(my_no_keys) { SQLRETURN rc; - SQLROWCOUNT rowcount; SQLINTEGER nData; /* INIT */ - SQLExecDirect(hstmt,"drop table my_no_keys",SQL_NTS); - rc = SQLExecDirect(hstmt,"create table my_no_keys(col1 int,\ + SQLExecDirect(hstmt,(SQLCHAR *)"drop table my_no_keys",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"create table my_no_keys(col1 int,\ col2 varchar(30),\ col3 int,\ col4 int)",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_no_keys values(100,'MySQL1',1,3000)",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_no_keys values(100,'MySQL1',1,3000)",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_no_keys values(200,'MySQL2',2,3000)",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_no_keys values(200,'MySQL2',2,3000)",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_no_keys values(300,'MySQL3',3,3000)",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_no_keys values(300,'MySQL3',3,3000)",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into my_no_keys values(400,'MySQL4',4,3000)",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into my_no_keys values(400,'MySQL4',4,3000)",SQL_NTS); mystmt(hstmt,rc); rc = SQLTransact(NULL,hdbc,SQL_COMMIT); @@ -365,7 +364,7 @@ mystmt(hstmt, rc); /* UPDATE ROW[2]COL[4] */ - rc = SQLExecDirect(hstmt,"select col4 from my_no_keys",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"select col4 from my_no_keys",SQL_NTS); mystmt(hstmt,rc); rc = SQLBindCol(hstmt,1,SQL_C_LONG,&nData,100,NULL); @@ -393,7 +392,7 @@ rc = SQLFreeStmt(hstmt,SQL_CLOSE); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"select * from my_no_keys",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"select * from my_no_keys",SQL_NTS); mystmt(hstmt,rc); myassert(4 == myresult(hstmt)); @@ -401,7 +400,7 @@ rc = SQLFreeStmt(hstmt,SQL_CLOSE); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"select * from my_no_keys",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"select * from my_no_keys",SQL_NTS); mystmt(hstmt,rc); rc = SQLFetch(hstmt); @@ -439,26 +438,26 @@ { SQLRETURN rc; - SQLExecDirect(hstmt,"DROP DATABASE test_odbc_fk",SQL_NTS); - SQLExecDirect(hstmt,"CREATE DATABASE test_odbc_fk",SQL_NTS); - SQLExecDirect(hstmt,"use test_odbc_fk",SQL_NTS); - - rc = SQLExecDirect(hstmt,"DROP TABLE test_fkey_c1",SQL_NTS); - rc = SQLExecDirect(hstmt,"DROP TABLE test_fkey3",SQL_NTS); - rc = SQLExecDirect(hstmt,"DROP TABLE test_fkey2",SQL_NTS); - rc = SQLExecDirect(hstmt,"DROP TABLE test_fkey1",SQL_NTS); - rc = SQLExecDirect(hstmt,"DROP TABLE test_fkey_p1",SQL_NTS); - rc = SQLExecDirect(hstmt,"DROP TABLE test_fkey_comment_f",SQL_NTS); - rc = SQLExecDirect(hstmt,"DROP TABLE test_fkey_comment_p",SQL_NTS); + SQLExecDirect(hstmt,(SQLCHAR *)"DROP DATABASE test_odbc_fk",SQL_NTS); + SQLExecDirect(hstmt,(SQLCHAR *)"CREATE DATABASE test_odbc_fk",SQL_NTS); + SQLExecDirect(hstmt,(SQLCHAR *)"use test_odbc_fk",SQL_NTS); + + rc = SQLExecDirect(hstmt,(SQLCHAR *)"DROP TABLE test_fkey_c1",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"DROP TABLE test_fkey3",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"DROP TABLE test_fkey2",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"DROP TABLE test_fkey1",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"DROP TABLE test_fkey_p1",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"DROP TABLE test_fkey_comment_f",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"DROP TABLE test_fkey_comment_p",SQL_NTS); rc = SQLExecDirect(hstmt, - "CREATE TABLE test_fkey1(\ + (SQLCHAR *)"CREATE TABLE test_fkey1(\ A INTEGER NOT NULL,B INTEGER NOT NULL,C INTEGER NOT NULL,\ D INTEGER,PRIMARY KEY (C,B,A))TYPE=InnoDB;",SQL_NTS); mystmt(hstmt,rc); rc = SQLExecDirect(hstmt, - "CREATE TABLE test_fkey_p1(\ + (SQLCHAR *)"CREATE TABLE test_fkey_p1(\ A INTEGER NOT NULL,B INTEGER NOT NULL,C INTEGER NOT NULL,\ D INTEGER NOT NULL,E INTEGER NOT NULL,F INTEGER NOT NULL,\ G INTEGER NOT NULL,H INTEGER NOT NULL,I INTEGER NOT NULL,\ @@ -468,7 +467,7 @@ PRIMARY KEY (D,F,G,H,I,J,K,L,M,N,O))TYPE=InnoDB;",SQL_NTS); mystmt(hstmt,rc); rc = SQLExecDirect(hstmt, - "CREATE TABLE test_fkey2 (\ + (SQLCHAR *)"CREATE TABLE test_fkey2 (\ E INTEGER NOT NULL,C INTEGER NOT NULL,B INTEGER NOT NULL,\ A INTEGER NOT NULL,PRIMARY KEY (E),\ INDEX test_fkey2_ind(C,B,A),\ @@ -476,7 +475,7 @@ mystmt(hstmt,rc); rc = SQLExecDirect(hstmt, - "CREATE TABLE test_fkey3 (\ + (SQLCHAR *)"CREATE TABLE test_fkey3 (\ F INTEGER NOT NULL,C INTEGER NOT NULL,E INTEGER NOT NULL,\ G INTEGER, A INTEGER NOT NULL, B INTEGER NOT NULL,\ PRIMARY KEY (F),\ @@ -487,7 +486,7 @@ mystmt(hstmt,rc); rc = SQLExecDirect(hstmt, - "CREATE TABLE test_fkey_c1(\ + (SQLCHAR *)"CREATE TABLE test_fkey_c1(\ A INTEGER NOT NULL,B INTEGER NOT NULL,C INTEGER NOT NULL,\ D INTEGER NOT NULL,E INTEGER NOT NULL,F INTEGER NOT NULL,\ G INTEGER NOT NULL,H INTEGER NOT NULL,I INTEGER NOT NULL,\ @@ -505,7 +504,7 @@ mystmt(hstmt,rc); rc = SQLExecDirect(hstmt, - "CREATE TABLE test_fkey_comment_p ( \ + (SQLCHAR *)"CREATE TABLE test_fkey_comment_p ( \ ISP_ID SMALLINT NOT NULL, \ CUSTOMER_ID VARCHAR(10), \ ABBREVIATION VARCHAR(20) NOT NULL, \ @@ -518,7 +517,7 @@ mystmt(hstmt,rc); rc = SQLExecDirect(hstmt, - "CREATE TABLE test_fkey_comment_f ( \ + (SQLCHAR *)"CREATE TABLE test_fkey_comment_f ( \ CAMPAIGN_ID INT NOT NULL , \ ISP_ID SMALLINT NOT NULL, \ NAME VARCHAR(40) NOT NULL, \ @@ -542,26 +541,26 @@ { SQLRETURN rc; - SQLExecDirect(hstmt,"DROP DATABASE test_odbc_fk",SQL_NTS); - SQLExecDirect(hstmt,"CREATE DATABASE test_odbc_fk",SQL_NTS); - SQLExecDirect(hstmt,"use test_odbc_fk",SQL_NTS); - - rc = SQLExecDirect(hstmt,"DROP TABLE test_fkey_c1",SQL_NTS); - rc = SQLExecDirect(hstmt,"DROP TABLE test_fkey3",SQL_NTS); - rc = SQLExecDirect(hstmt,"DROP TABLE test_fkey2",SQL_NTS); - rc = SQLExecDirect(hstmt,"DROP TABLE test_fkey1",SQL_NTS); - rc = SQLExecDirect(hstmt,"DROP TABLE test_fkey_p1",SQL_NTS); - rc = SQLExecDirect(hstmt,"DROP TABLE test_fkey_comment_f",SQL_NTS); - rc = SQLExecDirect(hstmt,"DROP TABLE test_fkey_comment_p",SQL_NTS); + SQLExecDirect(hstmt,(SQLCHAR *)"DROP DATABASE test_odbc_fk",SQL_NTS); + SQLExecDirect(hstmt,(SQLCHAR *)"CREATE DATABASE test_odbc_fk",SQL_NTS); + SQLExecDirect(hstmt,(SQLCHAR *)"use test_odbc_fk",SQL_NTS); + + rc = SQLExecDirect(hstmt,(SQLCHAR *)"DROP TABLE test_fkey_c1",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"DROP TABLE test_fkey3",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"DROP TABLE test_fkey2",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"DROP TABLE test_fkey1",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"DROP TABLE test_fkey_p1",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"DROP TABLE test_fkey_comment_f",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"DROP TABLE test_fkey_comment_p",SQL_NTS); rc = SQLExecDirect(hstmt, - "CREATE TABLE test_fkey1(\ + (SQLCHAR *)"CREATE TABLE test_fkey1(\ A INTEGER NOT NULL,B INTEGER NOT NULL,C INTEGER NOT NULL,\ D INTEGER,PRIMARY KEY (C,B,A))",SQL_NTS); mystmt(hstmt,rc); rc = SQLExecDirect(hstmt, - "CREATE TABLE test_fkey_p1(\ + (SQLCHAR *)"CREATE TABLE test_fkey_p1(\ A INTEGER NOT NULL,B INTEGER NOT NULL,C INTEGER NOT NULL,\ D INTEGER NOT NULL,E INTEGER NOT NULL,F INTEGER NOT NULL,\ G INTEGER NOT NULL,H INTEGER NOT NULL,I INTEGER NOT NULL,\ @@ -571,14 +570,14 @@ PRIMARY KEY (D,F,G,H,I,J,K,L,M,N,O))",SQL_NTS); mystmt(hstmt,rc); rc = SQLExecDirect(hstmt, - "CREATE TABLE test_fkey2 (\ + (SQLCHAR *)"CREATE TABLE test_fkey2 (\ E INTEGER NOT NULL,C INTEGER NOT NULL,B INTEGER NOT NULL,\ A INTEGER NOT NULL,PRIMARY KEY (E),\ FOREIGN KEY (C,B,A) REFERENCES test_fkey1(C,B,A))",SQL_NTS); mystmt(hstmt,rc); rc = SQLExecDirect(hstmt, - "CREATE TABLE test_fkey3 (\ + (SQLCHAR *)"CREATE TABLE test_fkey3 (\ F INTEGER NOT NULL,C INTEGER NOT NULL,E INTEGER NOT NULL,\ G INTEGER, A INTEGER NOT NULL, B INTEGER NOT NULL,\ PRIMARY KEY (F),\ @@ -587,7 +586,7 @@ mystmt(hstmt,rc); rc = SQLExecDirect(hstmt, - "CREATE TABLE test_fkey_c1(\ + (SQLCHAR *)"CREATE TABLE test_fkey_c1(\ A INTEGER NOT NULL,B INTEGER NOT NULL,C INTEGER NOT NULL,\ D INTEGER NOT NULL,E INTEGER NOT NULL,F INTEGER NOT NULL,\ G INTEGER NOT NULL,H INTEGER NOT NULL,I INTEGER NOT NULL,\ @@ -608,7 +607,7 @@ DECLARE_TEST(my_foreign_keys) { SQLRETURN rc=0; - char dbc[255]; + SQLCHAR dbc[255]; server_is_mysql(hdbc) ? my_init_mysql_fkey(hdbc,hstmt) : my_init_fkey(hdbc,hstmt); @@ -618,7 +617,7 @@ rc = SQLForeignKeys(hstmt, dbc, SQL_NTS, /*PK CATALOG*/ NULL, SQL_NTS, /*PK SCHEMA*/ - "test_fkey1", SQL_NTS, /*PK TABLE*/ + (SQLCHAR *)"test_fkey1", SQL_NTS, /*PK TABLE*/ dbc, SQL_NTS, /*FK CATALOG*/ NULL, SQL_NTS, /*FK SCHEMA*/ NULL, SQL_NTS); /*FK TABLE*/ @@ -632,7 +631,7 @@ NULL, SQL_NTS, dbc, SQL_NTS, NULL, SQL_NTS, - "test_fkey1", SQL_NTS); + (SQLCHAR *)"test_fkey1", SQL_NTS); mystmt(hstmt,rc); myassert(0 == myresult(hstmt)); @@ -643,7 +642,7 @@ NULL, SQL_NTS, dbc, SQL_NTS, NULL, SQL_NTS, - "test_fkey_c1", SQL_NTS); + (SQLCHAR *)"test_fkey_c1", SQL_NTS); mystmt(hstmt,rc); /* myassert(15 == myresult(hstmt)); */ @@ -654,7 +653,7 @@ NULL, SQL_NTS, dbc, SQL_NTS, NULL, SQL_NTS, - "test_fkey2", SQL_NTS); + (SQLCHAR *)"test_fkey2", SQL_NTS); mystmt(hstmt,rc); /* myassert(3 == myresult(hstmt)); */ @@ -662,7 +661,7 @@ rc = SQLForeignKeys(hstmt, dbc, SQL_NTS, NULL, SQL_NTS, - "test_fkey_p1", SQL_NTS, + (SQLCHAR *)"test_fkey_p1", SQL_NTS, dbc, SQL_NTS, NULL, SQL_NTS, NULL, SQL_NTS); @@ -673,7 +672,7 @@ rc = SQLForeignKeys(hstmt, dbc, SQL_NTS, NULL, SQL_NTS, - "test_fkey3", SQL_NTS, + (SQLCHAR *)"test_fkey3", SQL_NTS, dbc, SQL_NTS, NULL, SQL_NTS, NULL, SQL_NTS); @@ -684,7 +683,7 @@ rc = SQLForeignKeys(hstmt, dbc, SQL_NTS, NULL, SQL_NTS, - "test_fkey2", SQL_NTS, + (SQLCHAR *)"test_fkey2", SQL_NTS, dbc, SQL_NTS, NULL, SQL_NTS, NULL, SQL_NTS); @@ -695,7 +694,7 @@ rc = SQLForeignKeys(hstmt, dbc, SQL_NTS, NULL, SQL_NTS, - "test_fkey1", SQL_NTS, + (SQLCHAR *)"test_fkey1", SQL_NTS, dbc, SQL_NTS, NULL, SQL_NTS, NULL, SQL_NTS); @@ -709,7 +708,7 @@ NULL, SQL_NTS, dbc, SQL_NTS, NULL, SQL_NTS, - "test_fkey3", SQL_NTS); + (SQLCHAR *)"test_fkey3", SQL_NTS); mystmt(hstmt,rc); /* myassert(4 == myresult(hstmt)); */ @@ -717,10 +716,10 @@ rc = SQLForeignKeys(hstmt, dbc, SQL_NTS, NULL, SQL_NTS, - "test_fkey1",SQL_NTS, + (SQLCHAR *)"test_fkey1",SQL_NTS, dbc, SQL_NTS, NULL, SQL_NTS, - "test_fkey3", SQL_NTS); + (SQLCHAR *)"test_fkey3", SQL_NTS); mystmt(hstmt,rc); /* myassert(3 == myresult(hstmt)); */ @@ -728,10 +727,10 @@ rc = SQLForeignKeys(hstmt, dbc, SQL_NTS, NULL, SQL_NTS, - "test_fkey_p1",SQL_NTS, + (SQLCHAR *)"test_fkey_p1",SQL_NTS, dbc, SQL_NTS, NULL, SQL_NTS, - "test_fkey_c1", SQL_NTS); + (SQLCHAR *)"test_fkey_c1", SQL_NTS); mystmt(hstmt,rc); /* myassert(11 == myresult(hstmt)); */ @@ -739,10 +738,10 @@ rc = SQLForeignKeys(hstmt, dbc, SQL_NTS, NULL, SQL_NTS, - "test_fkey1",SQL_NTS, + (SQLCHAR *)"test_fkey1",SQL_NTS, dbc, SQL_NTS, NULL, SQL_NTS, - "test_fkey2", SQL_NTS); + (SQLCHAR *)"test_fkey2", SQL_NTS); mystmt(hstmt,rc); /* myassert(3 == myresult(hstmt)); */ @@ -750,10 +749,10 @@ rc = SQLForeignKeys(hstmt, dbc, SQL_NTS, NULL, SQL_NTS, - "test_fkey_p1",SQL_NTS, + (SQLCHAR *)"test_fkey_p1",SQL_NTS, dbc, SQL_NTS, NULL, SQL_NTS, - "test_fkey2", SQL_NTS); + (SQLCHAR *)"test_fkey2", SQL_NTS); mystmt(hstmt,rc); myassert(0 == myresult(hstmt)); @@ -761,10 +760,10 @@ rc = SQLForeignKeys(hstmt, dbc, SQL_NTS, NULL, SQL_NTS, - "test_fkey3", SQL_NTS, + (SQLCHAR *)"test_fkey3", SQL_NTS, dbc, SQL_NTS, NULL, SQL_NTS, - "test_fkey1", SQL_NTS); + (SQLCHAR *)"test_fkey1", SQL_NTS); mystmt(hstmt,rc); myassert(0 == myresult(hstmt)); @@ -772,10 +771,10 @@ rc = SQLForeignKeys(hstmt, dbc, SQL_NTS, NULL, SQL_NTS, - "test_fkey2", SQL_NTS, + (SQLCHAR *)"test_fkey2", SQL_NTS, dbc, SQL_NTS, NULL, SQL_NTS, - "test_fkey1", SQL_NTS); + (SQLCHAR *)"test_fkey1", SQL_NTS); mystmt(hstmt,rc); myassert(0 == myresult(hstmt)); @@ -784,10 +783,10 @@ rc = SQLForeignKeys(hstmt, dbc, SQL_NTS, NULL, SQL_NTS, - "test_fkey1",10, + (SQLCHAR *)"test_fkey1",10, dbc, SQL_NTS, NULL, SQL_NTS, - "test_fkey2",10); + (SQLCHAR *)"test_fkey2",10); mystmt(hstmt,rc); /* assert(3 == myresult(hstmt)); */ SQLFreeStmt(hstmt,SQL_CLOSE); @@ -796,10 +795,10 @@ rc = SQLForeignKeys(hstmt, dbc, SQL_NTS, NULL, SQL_NTS, - "test_fkey_junk", SQL_NTS, + (SQLCHAR *)"test_fkey_junk", SQL_NTS, dbc, SQL_NTS, NULL, SQL_NTS, - "test_fkey_junk", SQL_NTS); + (SQLCHAR *)"test_fkey_junk", SQL_NTS); mystmt(hstmt,rc); myassert(0 == myresult(hstmt)); SQLFreeStmt(hstmt,SQL_CLOSE); @@ -808,20 +807,20 @@ rc = SQLForeignKeys(hstmt, dbc, SQL_NTS, NULL, SQL_NTS, - "test_fkey_comment_p", SQL_NTS, + (SQLCHAR *)"test_fkey_comment_p", SQL_NTS, dbc, SQL_NTS, NULL, SQL_NTS, - "test_fkey_comment_f", SQL_NTS); + (SQLCHAR *)"test_fkey_comment_f", SQL_NTS); mystmt(hstmt,rc); /* myassert(1 == myresult(hstmt)); */ { char buff[255]; sprintf(buff,"use %s",mydb); - rc = SQLExecDirect(hstmt, "DROP DATABASE test_odbc_fk", SQL_NTS); + rc = SQLExecDirect(hstmt, (SQLCHAR *)"DROP DATABASE test_odbc_fk", SQL_NTS); mystmt(hstmt, rc); SQLFreeStmt(hstmt, SQL_CLOSE); - SQLExecDirect(hstmt, buff, SQL_NTS); + SQLExecDirect(hstmt, (SQLCHAR *)buff, SQL_NTS); SQLFreeStmt(hstmt, SQL_CLOSE); } @@ -850,10 +849,10 @@ SQLHDBC hdbc1; SQLHSTMT hstmt1; SQLRETURN rc; - char conn[256]; + SQLCHAR conn[256]; - SQLExecDirect(hstmt,"DROP DATABASE my_tables_test_db",SQL_NTS); - rc = SQLExecDirect(hstmt,"CREATE DATABASE my_tables_test_db",SQL_NTS); + SQLExecDirect(hstmt,(SQLCHAR *)"DROP DATABASE my_tables_test_db",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"CREATE DATABASE my_tables_test_db",SQL_NTS); mystmt(hstmt,rc); sprintf(conn,"DSN=%s;UID=%s;PASSWORD=%s;DATABASE=%s", @@ -874,55 +873,55 @@ mycon(hdbc1,rc); rc = SQLExecDirect(hstmt1, - "CREATE TABLE my_tables_test1(\ + (SQLCHAR *)"CREATE TABLE my_tables_test1(\ A INTEGER NOT NULL,B INTEGER NOT NULL)",SQL_NTS); mystmt(hstmt1,rc); rc = SQLExecDirect(hstmt1, - "CREATE TABLE my_tables_test2(\ + (SQLCHAR *)"CREATE TABLE my_tables_test2(\ A INTEGER NOT NULL,B INTEGER NOT NULL)",SQL_NTS); mystmt(hstmt1,rc); SQLEndTran(SQL_HANDLE_DBC,hdbc1,SQL_COMMIT); - rc = SQLTables(hstmt1,"non_existing_junk",SQL_NTS, + rc = SQLTables(hstmt1,(SQLCHAR *)"non_existing_junk",SQL_NTS, NULL,0, - "my_tables_test1",SQL_NTS, - "TABLE",SQL_NTS); + (SQLCHAR *)"my_tables_test1",SQL_NTS, + (SQLCHAR *)"TABLE",SQL_NTS); mystmt(hstmt1,rc); myassert(0 == my_print_non_format_result(hstmt1)); SQLFreeStmt(hstmt1,SQL_CLOSE); - rc = SQLTables(hstmt1,"my_tables_test_db",SQL_NTS, + rc = SQLTables(hstmt1,(SQLCHAR *)"my_tables_test_db",SQL_NTS, NULL,0, - "my_tables_test1",SQL_NTS, - "TABLE",SQL_NTS); + (SQLCHAR *)"my_tables_test1",SQL_NTS, + (SQLCHAR *)"TABLE",SQL_NTS); mystmt(hstmt1,rc); myassert(1 == my_print_non_format_result(hstmt1)); SQLFreeStmt(hstmt,SQL_CLOSE); - rc = SQLTables(hstmt1,"my_tables_test_db",SQL_NTS, + rc = SQLTables(hstmt1,(SQLCHAR *)"my_tables_test_db",SQL_NTS, NULL,0, - "my_tables_test1",15, - "TABLE",SQL_NTS); + (SQLCHAR *)"my_tables_test1",15, + (SQLCHAR *)"TABLE",SQL_NTS); mystmt(hstmt1,rc); myassert(1 == my_print_non_format_result(hstmt1)); SQLFreeStmt(hstmt1,SQL_CLOSE); - rc = SQLTables(hstmt1,"my_tables_test_db",SQL_NTS, + rc = SQLTables(hstmt1,(SQLCHAR *)"my_tables_test_db",SQL_NTS, NULL,0, NULL,0, - "TABLE",SQL_NTS); + (SQLCHAR *)"TABLE",SQL_NTS); mystmt(hstmt1,rc); myassert(2 == my_print_non_format_result(hstmt1)); SQLFreeStmt(hstmt1,SQL_CLOSE); - rc = SQLTables(hstmt1,"my_tables_test_db",SQL_NTS, + rc = SQLTables(hstmt1,(SQLCHAR *)"my_tables_test_db",SQL_NTS, NULL,0, NULL,0, - "`TABLE`",SQL_NTS); + (SQLCHAR *)"`TABLE`",SQL_NTS); mystmt(hstmt1,rc); - if (!driver_min_version(hdbc,"03.51.07",8)) + if (!driver_min_version(hdbc,(SQLCHAR *)"03.51.07",8)) myassert(0 == my_print_non_format_result(hstmt1)); else myassert(0 != my_print_non_format_result(hstmt1)); @@ -931,9 +930,9 @@ rc = SQLTables(hstmt1,NULL,0, NULL,0, NULL,0, - "SYSTEM TABLE",SQL_NTS); + (SQLCHAR *)"SYSTEM TABLE",SQL_NTS); mystmt(hstmt1,rc); - if (!driver_min_version(hdbc,"03.51.07",8)) + if (!driver_min_version(hdbc,(SQLCHAR *)"03.51.07",8)) myassert(0 == my_print_non_format_result(hstmt1)); else myassert(my_print_non_format_result(hstmt1) != 0); @@ -942,9 +941,9 @@ rc = SQLTables(hstmt1,NULL,0, NULL,0, NULL,0, - "TABLE,SYSTEM TABLE",SQL_NTS); + (SQLCHAR *)"TABLE,SYSTEM TABLE",SQL_NTS); mystmt(hstmt1,rc); - if (!driver_min_version(hdbc,"03.51.07",8)) + if (!driver_min_version(hdbc,(SQLCHAR *)"03.51.07",8)) myassert(2 == my_print_non_format_result(hstmt1)); else myassert(my_print_non_format_result(hstmt1) > 2); @@ -953,9 +952,9 @@ rc = SQLTables(hstmt1,NULL,0, NULL,0, NULL,0, - "TABLE,VIEW,SYSTEM TABLE",SQL_NTS); + (SQLCHAR *)"TABLE,VIEW,SYSTEM TABLE",SQL_NTS); mystmt(hstmt1,rc); - if (!driver_min_version(hdbc,"03.51.07",8)) + if (!driver_min_version(hdbc,(SQLCHAR *)"03.51.07",8)) myassert(2 == my_print_non_format_result(hstmt1)); else myassert(my_print_non_format_result(hstmt1) > 2); @@ -964,9 +963,9 @@ rc = SQLTables(hstmt1,NULL,0, NULL,0, NULL,0, - "'TABLE','VIEW','SYSTEM TABLE'",SQL_NTS); + (SQLCHAR *)"'TABLE','VIEW','SYSTEM TABLE'",SQL_NTS); mystmt(hstmt1,rc); - if (!driver_min_version(hdbc,"03.51.07",8)) + if (!driver_min_version(hdbc,(SQLCHAR *)"03.51.07",8)) myassert(2 == my_print_non_format_result(hstmt1)); else myassert(my_print_non_format_result(hstmt1) > 2); @@ -975,12 +974,12 @@ rc = SQLTables(hstmt1,NULL,0, NULL,0, NULL,0, - "'TABLE',",SQL_NTS); + (SQLCHAR *)"'TABLE',",SQL_NTS); mystmt(hstmt1,rc); myassert(2 == my_print_non_format_result(hstmt1)); SQLFreeStmt(hstmt1,SQL_CLOSE); - SQLExecDirect(hstmt1,"DROP DATABASE my_tables_test_db",SQL_NTS); + SQLExecDirect(hstmt1,(SQLCHAR *)"DROP DATABASE my_tables_test_db",SQL_NTS); SQLEndTran(SQL_HANDLE_DBC,hdbc1,SQL_COMMIT); SQLFreeStmt(hstmt1,SQL_CLOSE); --- myodbc-3.51.15r409.orig/test/my_param.c +++ myodbc-3.51.15r409/test/my_param.c @@ -32,7 +32,7 @@ /* drop table 'my_demo_param' if it already exists */ printMessage(" creating table 'my_demo_param'\n"); - rc = SQLExecDirect(hstmt,"DROP TABLE if exists my_demo_param",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"DROP TABLE if exists my_demo_param",SQL_NTS); mystmt(hstmt,rc); /* commit the transaction */ @@ -40,7 +40,7 @@ mycon(hdbc,rc); /* create the table 'my_demo_param' */ - rc = SQLExecDirect(hstmt,"CREATE TABLE my_demo_param(\ + rc = SQLExecDirect(hstmt,(SQLCHAR *)"CREATE TABLE my_demo_param(\ id int,\ auto int primary key auto_increment,\ name varchar(20),\ @@ -62,7 +62,7 @@ char name[50]; /* prepare the insert statement with parameters */ - rc = SQLPrepare(hstmt,"INSERT INTO my_demo_param(id,name) VALUES(?,?)",SQL_NTS); + rc = SQLPrepare(hstmt,(SQLCHAR *)"INSERT INTO my_demo_param(id,name) VALUES(?,?)",SQL_NTS); mystmt(hstmt,rc); /* now supply data to parameter 1 and 2 */ @@ -98,7 +98,7 @@ mycon(hdbc,rc); /* Now fetch and verify the data */ - rc = SQLExecDirect(hstmt, "SELECT * FROM my_demo_param",SQL_NTS); + rc = SQLExecDirect(hstmt, (SQLCHAR *)"SELECT * FROM my_demo_param",SQL_NTS); mystmt(hstmt,rc); assert(10 == myresult(hstmt)); @@ -115,7 +115,7 @@ char name[]="update"; /* prepare the insert statement with parameters */ - rc = SQLPrepare(hstmt,"UPDATE my_demo_param set name = ? WHERE id = ?",SQL_NTS); + rc = SQLPrepare(hstmt,(SQLCHAR *)"UPDATE my_demo_param set name = ? WHERE id = ?",SQL_NTS); mystmt(hstmt,rc); /* now supply data to parameter 1 and 2 */ @@ -152,7 +152,7 @@ mycon(hdbc,rc); /* Now fetch and verify the data */ - rc = SQLExecDirect(hstmt, "SELECT * FROM my_demo_param",SQL_NTS); + rc = SQLExecDirect(hstmt, (SQLCHAR *)"SELECT * FROM my_demo_param",SQL_NTS); mystmt(hstmt,rc); assert(10 == myresult(hstmt)); @@ -175,7 +175,7 @@ /* execute the DELETE STATEMENT to delete 5th row */ id = 5; - rc = SQLExecDirect(hstmt,"DELETE FROM my_demo_param WHERE id = ?",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"DELETE FROM my_demo_param WHERE id = ?",SQL_NTS); mystmt(hstmt,rc); /* check the rows affected by the update statement */ @@ -194,7 +194,7 @@ mystmt(hstmt,rc); id = 8; - rc = SQLExecDirect(hstmt,"DELETE FROM my_demo_param WHERE id = ?",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"DELETE FROM my_demo_param WHERE id = ?",SQL_NTS); mystmt(hstmt,rc); /* check the rows affected by the update statement */ @@ -216,13 +216,13 @@ mycon(hdbc,rc); /* Now fetch and verify the data */ - rc = SQLExecDirect(hstmt, "SELECT * FROM my_demo_param",SQL_NTS); + rc = SQLExecDirect(hstmt, (SQLCHAR *)"SELECT * FROM my_demo_param",SQL_NTS); mystmt(hstmt,rc); assert(8 == myresult(hstmt)); /* drop the table */ - rc = SQLExecDirect(hstmt,"DROP TABLE my_demo_param",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"DROP TABLE my_demo_param",SQL_NTS); mystmt(hstmt,rc); rc = SQLEndTran(SQL_HANDLE_DBC, hdbc, SQL_COMMIT); @@ -330,7 +330,7 @@ SQLULEN pcbParamDef; SQLFreeStmt(hstmt,SQL_CLOSE); - rc = SQLPrepare(hstmt,"insert into sqlerr (TD, NODE, TAG, SQLNAME, SQL_ERR, FIX_ERR, PROG_ERR)\ + rc = SQLPrepare(hstmt,(SQLCHAR *)"insert into sqlerr (TD, NODE, TAG, SQLNAME, SQL_ERR, FIX_ERR, PROG_ERR)\ values (?, ?, ?, ?, ?, ?, ?)",200); mystmt(hstmt,rc); --- myodbc-3.51.15r409.orig/test/my_position.c +++ myodbc-3.51.15r409/test/my_position.c @@ -32,23 +32,23 @@ if (!driver_supports_setpos(hdbc)) return; - SQLExecDirect(hstmt,"drop table t_chunk",SQL_NTS); + SQLExecDirect(hstmt,(SQLCHAR *)"drop table t_chunk",SQL_NTS); - rc = SQLExecDirect(hstmt,"create table t_chunk(id int not null primary key, description varchar(50), txt text)",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"create table t_chunk(id int not null primary key, description varchar(50), txt text)",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"INSERT INTO t_chunk VALUES(1,'venu','Developer, MySQL AB')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"INSERT INTO t_chunk VALUES(1,'venu','Developer, MySQL AB')",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"INSERT INTO t_chunk VALUES(2,'monty','Michael Monty Widenius - main MySQL developer')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"INSERT INTO t_chunk VALUES(2,'monty','Michael Monty Widenius - main MySQL developer')",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"INSERT INTO t_chunk VALUES(3,'mysql','MySQL AB- Speed, Power and Precision')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"INSERT INTO t_chunk VALUES(3,'mysql','MySQL AB- Speed, Power and Precision')",SQL_NTS); mystmt(hstmt,rc); SQLFreeStmt(hstmt,SQL_CLOSE); - rc = SQLExecDirect(hstmt,"SELECT * from t_chunk",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"SELECT * from t_chunk",SQL_NTS); mystmt(hstmt,rc); rc = SQLFetchScroll(hstmt, SQL_FETCH_NEXT, 1); --- myodbc-3.51.15r409.orig/test/my_prepare.c +++ myodbc-3.51.15r409/test/my_prepare.c @@ -31,12 +31,12 @@ SQLLEN length1, length2; char name[20]; - SQLExecDirect(hstmt,"drop table t_prep_basic",SQL_NTS); + SQLExecDirect(hstmt,(SQLCHAR *)"drop table t_prep_basic",SQL_NTS); - rc = SQLExecDirect(hstmt,"create table t_prep_basic(a int, b char(4))",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"create table t_prep_basic(a int, b char(4))",SQL_NTS); mystmt(hstmt,rc); - rc = SQLPrepare(hstmt, "insert into t_prep_basic values(?,'venu')",SQL_NTS); + rc = SQLPrepare(hstmt, (SQLCHAR *)"insert into t_prep_basic values(?,'venu')",SQL_NTS); mystmt(hstmt,rc); rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &id, 0, NULL); @@ -55,7 +55,7 @@ SQLFreeStmt(hstmt,SQL_RESET_PARAMS); SQLFreeStmt(hstmt,SQL_CLOSE); - rc = SQLExecDirect(hstmt,"select * from t_prep_basic",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"select * from t_prep_basic",SQL_NTS); mystmt(hstmt,rc); rc = SQLBindCol(hstmt, 1, SQL_C_LONG, &id, 0, &length1); @@ -91,12 +91,12 @@ SQLLEN length; char buffer[20]; - SQLExecDirect(hstmt,"drop table t_prep_buffer_length",SQL_NTS); + SQLExecDirect(hstmt,(SQLCHAR *)"drop table t_prep_buffer_length",SQL_NTS); - rc = SQLExecDirect(hstmt,"create table t_prep_buffer_length(a varchar(20))",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"create table t_prep_buffer_length(a varchar(20))",SQL_NTS); mystmt(hstmt,rc); - rc = SQLPrepare(hstmt, "insert into t_prep_buffer_length values(?)",SQL_NTS); + rc = SQLPrepare(hstmt, (SQLCHAR *)"insert into t_prep_buffer_length values(?)",SQL_NTS); mystmt(hstmt,rc); length= 0; @@ -131,7 +131,7 @@ SQLFreeStmt(hstmt,SQL_RESET_PARAMS); SQLFreeStmt(hstmt,SQL_CLOSE); - rc = SQLExecDirect(hstmt,"select * from t_prep_buffer_length",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"select * from t_prep_buffer_length",SQL_NTS); mystmt(hstmt,rc); rc = SQLBindCol(hstmt, 1, SQL_C_CHAR, buffer, 15, &length); @@ -183,17 +183,17 @@ /* For data truncation */ DECLARE_TEST(t_prep_truncate) { - SQLINTEGER pcrow; + SQLROWCOUNT pcrow; SQLLEN length, length1; SQLCHAR name[20], bin[10]; - SQLExecDirect(hstmt,"drop table t_prep_truncate",SQL_NTS); + SQLExecDirect(hstmt,(SQLCHAR *)"drop table t_prep_truncate",SQL_NTS); - rc = SQLExecDirect(hstmt,"create table t_prep_truncate(a int, b char(4), c binary(4))",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"create table t_prep_truncate(a int, b char(4), c binary(4))",SQL_NTS); mystmt(hstmt,rc); - rc = SQLPrepare(hstmt, "insert into t_prep_truncate values(500,'venu','venu')",SQL_NTS); + rc = SQLPrepare(hstmt, (SQLCHAR *)"insert into t_prep_truncate values(500,'venu','venu')",SQL_NTS); mystmt(hstmt,rc); strcpy(name,"venu"); @@ -215,7 +215,7 @@ SQLFreeStmt(hstmt,SQL_RESET_PARAMS); SQLFreeStmt(hstmt,SQL_CLOSE); - rc = SQLExecDirect(hstmt,"select b,c from t_prep_truncate",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"select b,c from t_prep_truncate",SQL_NTS); mystmt(hstmt,rc); rc = SQLBindCol(hstmt, 1, SQL_C_CHAR, name, 2, &length); @@ -322,12 +322,12 @@ SQLLEN length; SQLCHAR tiny; - SQLExecDirect(hstmt,"drop table t_prep_getdata",SQL_NTS); + SQLExecDirect(hstmt,(SQLCHAR *)"drop table t_prep_getdata",SQL_NTS); - rc = SQLExecDirect(hstmt,"create table t_prep_getdata(a tinyint, b int, c char(4))",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"create table t_prep_getdata(a tinyint, b int, c char(4))",SQL_NTS); mystmt(hstmt,rc); - rc = SQLPrepare(hstmt,"insert into t_prep_getdata values(?,?,?)",SQL_NTS); + rc = SQLPrepare(hstmt,(SQLCHAR *)"insert into t_prep_getdata values(?,?,?)",SQL_NTS); mystmt(hstmt,rc); rc = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT,SQL_C_LONG,SQL_TINYINT, @@ -352,7 +352,7 @@ SQLFreeStmt(hstmt,SQL_CLOSE); data= 0; - rc = SQLExecDirect(hstmt,"select * from t_prep_getdata",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"select * from t_prep_getdata",SQL_NTS); mystmt(hstmt,rc); rc = SQLBindCol(hstmt, 1,SQL_C_TINYINT, &tiny, 0, NULL); @@ -404,17 +404,17 @@ SQLCHAR data[11]; SQLLEN length; - SQLExecDirect(hstmt,"drop table t_prep_getdata",SQL_NTS); + SQLExecDirect(hstmt,(SQLCHAR *)"drop table t_prep_getdata",SQL_NTS); - rc = SQLExecDirect(hstmt,"create table t_prep_getdata(a char(10), b int)",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"create table t_prep_getdata(a char(10), b int)",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into t_prep_getdata values('abcdefghij',12345)",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into t_prep_getdata values('abcdefghij',12345)",SQL_NTS); mystmt(hstmt,rc); SQLFreeStmt(hstmt,SQL_CLOSE); - rc = SQLExecDirect(hstmt,"select * from t_prep_getdata",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"select * from t_prep_getdata",SQL_NTS); mystmt(hstmt,rc); rc = SQLFetch(hstmt); @@ -527,14 +527,14 @@ DECLARE_TEST(t_prep_catalog) { SQLCHAR table[20]; - SQLINTEGER length; + SQLLEN length; - SQLExecDirect(hstmt,"drop table t_prep_catalog",SQL_NTS); + SQLExecDirect(hstmt,(SQLCHAR *)"drop table t_prep_catalog",SQL_NTS); - rc = SQLExecDirect(hstmt,"create table t_prep_catalog(a int default 100)",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"create table t_prep_catalog(a int default 100)",SQL_NTS); mystmt(hstmt,rc); - rc = SQLTables(hstmt,NULL,0,NULL,0,"t_prep_catalog",14,"TABLE",5); + rc = SQLTables(hstmt,NULL,0,NULL,0,(SQLCHAR *)"t_prep_catalog",14,(SQLCHAR *)"TABLE",5); mystmt(hstmt,rc); rc = SQLFetch(hstmt); @@ -557,7 +557,7 @@ rc = SQLFreeStmt(hstmt,SQL_CLOSE); mystmt(hstmt,rc); - rc = SQLColumns(hstmt,NULL,0,NULL,0,"t_prep_catalog",14,NULL,0); + rc = SQLColumns(hstmt,NULL,0,NULL,0,(SQLCHAR *)"t_prep_catalog",14,NULL,0); mystmt(hstmt,rc); rc = SQLFetch(hstmt); @@ -607,20 +607,20 @@ } */ - SQLExecDirect(hstmt,"drop procedure t_sp",SQL_NTS); + SQLExecDirect(hstmt,(SQLCHAR *)"drop procedure t_sp",SQL_NTS); - SQLExecDirect(hstmt,"drop table t_tabsp",SQL_NTS); + SQLExecDirect(hstmt,(SQLCHAR *)"drop table t_tabsp",SQL_NTS); - rc = SQLExecDirect(hstmt,"create table t_tabsp(a int, b varchar(10))",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"create table t_tabsp(a int, b varchar(10))",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"create procedure t_sp(x int, y char(10)) \ + rc = SQLExecDirect(hstmt,(SQLCHAR *)"create procedure t_sp(x int, y char(10)) \ begin \ insert into t_tabsp values(x, y); \ end;",SQL_NTS); mystmt(hstmt,rc); - rc = SQLPrepare(hstmt,"call t_sp(?,?)",SQL_NTS); + rc = SQLPrepare(hstmt,(SQLCHAR *)"call t_sp(?,?)",SQL_NTS); mystmt(hstmt,rc); rc = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT,SQL_C_LONG,SQL_INTEGER, @@ -639,7 +639,7 @@ SQLFreeStmt(hstmt, SQL_RESET_PARAMS); SQLFreeStmt(hstmt, SQL_CLOSE); - rc = SQLExecDirect(hstmt,"select * from t_tabsp",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"select * from t_tabsp",SQL_NTS); mystmt(hstmt,rc); rc = SQLBindCol(hstmt,1,SQL_C_LONG,&a,0,NULL); @@ -661,10 +661,10 @@ SQLFreeStmt(hstmt, SQL_UNBIND); SQLFreeStmt(hstmt, SQL_CLOSE); - rc = SQLExecDirect(hstmt,"drop procedure t_sp",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"drop procedure t_sp",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"drop table t_tabsp",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"drop table t_tabsp",SQL_NTS); mystmt(hstmt,rc); SQLFreeStmt(hstmt, SQL_CLOSE); @@ -678,7 +678,7 @@ SQLINTEGER nidata= 200, nodata; SQLLEN nlen; char szodata[20],szidata[20]="MySQL"; - SQLROWCOUNT pccol; + SQLSMALLINT pccol; SQLFreeStmt(hstmt,SQL_CLOSE); @@ -693,7 +693,7 @@ rc = tmysql_exec(hstmt,"insert into t_prepare values(200,'MySQL','two')"); mystmt(hstmt,rc); - rc = SQLPrepare(hstmt,"select * from t_prepare where col2 = ? AND col1 = ?",SQL_NTS); + rc = SQLPrepare(hstmt,(SQLCHAR *)"select * from t_prepare where col2 = ? AND col1 = ?",SQL_NTS); mystmt(hstmt,rc); rc = SQLNumResultCols(hstmt,&pccol); @@ -720,7 +720,7 @@ rc = SQLFetch(hstmt); mystmt(hstmt,rc); - fprintf(stdout," outdata: %d, %s(%d)\n", nodata,szodata,nlen); + fprintf(stdout," outdata: %d, %s(%ld)\n", nodata,szodata,nlen); my_assert(nodata == 200); rc = SQLFetch(hstmt); @@ -780,7 +780,7 @@ rc = SQLFreeStmt(hstmt,SQL_RESET_PARAMS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"SELECT * FROM t_prepare1",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"SELECT * FROM t_prepare1",SQL_NTS); mystmt(hstmt,rc); myassert(3 == myresult(hstmt));/* unless prepare is supported..*/ @@ -965,7 +965,7 @@ mystmt(hstmt,rc); - rc = SQLPrepare(hstmt,"select id from t_acc_update where id = ?",SQL_NTS); + rc = SQLPrepare(hstmt,(SQLCHAR *)"select id from t_acc_update where id = ?",SQL_NTS); mystmt(hstmt,rc); rc = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT,SQL_C_DEFAULT,SQL_INTEGER,11,0,&id,0,NULL); @@ -1002,7 +1002,7 @@ rc = SQLBindParameter(hstmt1,2,SQL_PARAM_INPUT,SQL_C_DEFAULT,SQL_INTEGER,11,0,&id1,0,NULL); mystmt(hstmt1,rc); - rc = SQLExecDirect(hstmt1,"UPDATE t_acc_update SET id = ? WHERE id = ?",SQL_NTS); + rc = SQLExecDirect(hstmt1,(SQLCHAR *)"UPDATE t_acc_update SET id = ? WHERE id = ?",SQL_NTS); mystmt(hstmt1,rc); rc = SQLRowCount(hstmt1,&pcrow); --- myodbc-3.51.15r409.orig/test/my_relative.c +++ myodbc-3.51.15r409/test/my_relative.c @@ -31,12 +31,12 @@ long index; char name[21]; - SQLExecDirect(hstmt,"drop table t_relative",SQL_NTS); + SQLExecDirect(hstmt,(SQLCHAR *)"drop table t_relative",SQL_NTS); - rc = SQLExecDirect(hstmt,"create table t_relative(id int,name char(20))",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"create table t_relative(id int,name char(20))",SQL_NTS); mystmt(hstmt,rc); - rc = SQLPrepare(hstmt,"insert into t_relative values(?,?)",SQL_NTS); + rc = SQLPrepare(hstmt,(SQLCHAR *)"insert into t_relative values(?,?)",SQL_NTS); mystmt(hstmt,rc); rc = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT, SQL_C_ULONG, @@ -66,7 +66,7 @@ rc = SQLSetStmtAttr(hstmt,SQL_ATTR_ROWS_FETCHED_PTR,&nrows,0); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"select * from t_relative",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"select * from t_relative",SQL_NTS); mystmt(hstmt,rc); rc = SQLBindCol(hstmt,1,SQL_C_LONG,&iarray,0,NULL); @@ -171,12 +171,12 @@ SQLUINTEGER i; const int max_rows=10; - SQLExecDirect(hstmt,"drop table t_relative1",SQL_NTS); + SQLExecDirect(hstmt,(SQLCHAR *)"drop table t_relative1",SQL_NTS); - rc = SQLExecDirect(hstmt,"create table t_relative1(id int)",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"create table t_relative1(id int)",SQL_NTS); mystmt(hstmt,rc); - rc = SQLPrepare(hstmt,"insert into t_relative1 values(?)",SQL_NTS); + rc = SQLPrepare(hstmt,(SQLCHAR *)"insert into t_relative1 values(?)",SQL_NTS); mystmt(hstmt,rc); rc = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT, SQL_C_ULONG, @@ -202,7 +202,7 @@ rc = SQLSetStmtAttr(hstmt,SQL_ATTR_ROWS_FETCHED_PTR,&nrows,0); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"select * from t_relative1",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"select * from t_relative1",SQL_NTS); mystmt(hstmt,rc); rc = SQLBindCol(hstmt,1,SQL_C_LONG,&i,0,NULL); @@ -377,12 +377,12 @@ SQLUINTEGER i; const int max_rows=10; - SQLExecDirect(hstmt,"drop table t_relative2",SQL_NTS); + SQLExecDirect(hstmt,(SQLCHAR *)"drop table t_relative2",SQL_NTS); - rc = SQLExecDirect(hstmt,"create table t_relative2(id int)",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"create table t_relative2(id int)",SQL_NTS); mystmt(hstmt,rc); - rc = SQLPrepare(hstmt,"insert into t_relative2 values(?)",SQL_NTS); + rc = SQLPrepare(hstmt,(SQLCHAR *)"insert into t_relative2 values(?)",SQL_NTS); mystmt(hstmt,rc); rc = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT, SQL_C_ULONG, @@ -408,7 +408,7 @@ rc = SQLSetStmtAttr(hstmt,SQL_ATTR_ROWS_FETCHED_PTR,&nrows,0); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"select * from t_relative2",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"select * from t_relative2",SQL_NTS); mystmt(hstmt,rc); rc = SQLBindCol(hstmt,1,SQL_C_LONG,&iarray,0,NULL); @@ -619,27 +619,27 @@ SQLINTEGER rowsFetched, rowsSize; long i; - SQLExecDirect(hstmt,"drop table t_rows_fetched_ptr",SQL_NTS); + SQLExecDirect(hstmt,(SQLCHAR *)"drop table t_rows_fetched_ptr",SQL_NTS); - rc = SQLExecDirect(hstmt,"create table t_rows_fetched_ptr(a int)",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"create table t_rows_fetched_ptr(a int)",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into t_rows_fetched_ptr values(0)",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into t_rows_fetched_ptr values(0)",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into t_rows_fetched_ptr values(1)",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into t_rows_fetched_ptr values(1)",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into t_rows_fetched_ptr values(2)",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into t_rows_fetched_ptr values(2)",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into t_rows_fetched_ptr values(3)",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into t_rows_fetched_ptr values(3)",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into t_rows_fetched_ptr values(4)",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into t_rows_fetched_ptr values(4)",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into t_rows_fetched_ptr values(5)",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into t_rows_fetched_ptr values(5)",SQL_NTS); mystmt(hstmt,rc); rowsSize= 1; @@ -649,7 +649,7 @@ rc = SQLSetStmtAttr(hstmt, SQL_ATTR_ROWS_FETCHED_PTR, &rowsFetched, 0); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt, "SELECT * FROM t_rows_fetched_ptr",SQL_NTS); + rc = SQLExecDirect(hstmt, (SQLCHAR *)"SELECT * FROM t_rows_fetched_ptr",SQL_NTS); mystmt(hstmt,rc); i= 0; @@ -671,7 +671,7 @@ rc = SQLSetStmtAttr(hstmt, SQL_ATTR_ROWS_FETCHED_PTR, &rowsFetched, 0); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt, "SELECT * FROM t_rows_fetched_ptr",SQL_NTS); + rc = SQLExecDirect(hstmt, (SQLCHAR *)"SELECT * FROM t_rows_fetched_ptr",SQL_NTS); mystmt(hstmt,rc); i= 0; @@ -693,7 +693,7 @@ rc = SQLSetStmtAttr(hstmt, SQL_ATTR_ROWS_FETCHED_PTR, &rowsFetched, 0); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt, "SELECT * FROM t_rows_fetched_ptr",SQL_NTS); + rc = SQLExecDirect(hstmt, (SQLCHAR *)"SELECT * FROM t_rows_fetched_ptr",SQL_NTS); mystmt(hstmt,rc); i= 0; @@ -715,7 +715,7 @@ rc = SQLSetStmtAttr(hstmt, SQL_ATTR_ROWS_FETCHED_PTR, &rowsFetched, 0); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt, "SELECT * FROM t_rows_fetched_ptr",SQL_NTS); + rc = SQLExecDirect(hstmt, (SQLCHAR *)"SELECT * FROM t_rows_fetched_ptr",SQL_NTS); mystmt(hstmt,rc); rc = SQLFetch(hstmt); @@ -751,27 +751,27 @@ SQLLEN rowsFetched, rowsSize; SQLINTEGER i; - SQLExecDirect(hstmt,"drop table t_rows_fetched_ptr",SQL_NTS); + SQLExecDirect(hstmt,(SQLCHAR *)"drop table t_rows_fetched_ptr",SQL_NTS); - rc = SQLExecDirect(hstmt,"create table t_rows_fetched_ptr(a int)",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"create table t_rows_fetched_ptr(a int)",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into t_rows_fetched_ptr values(0)",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into t_rows_fetched_ptr values(0)",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into t_rows_fetched_ptr values(1)",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into t_rows_fetched_ptr values(1)",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into t_rows_fetched_ptr values(2)",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into t_rows_fetched_ptr values(2)",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into t_rows_fetched_ptr values(3)",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into t_rows_fetched_ptr values(3)",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into t_rows_fetched_ptr values(4)",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into t_rows_fetched_ptr values(4)",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into t_rows_fetched_ptr values(5)",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into t_rows_fetched_ptr values(5)",SQL_NTS); mystmt(hstmt,rc); rowsSize= 1; @@ -781,7 +781,7 @@ rc = SQLSetStmtAttr(hstmt, SQL_ATTR_ROWS_FETCHED_PTR, &rowsFetched, 0); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt, "SELECT * FROM t_rows_fetched_ptr",SQL_NTS); + rc = SQLExecDirect(hstmt, (SQLCHAR *)"SELECT * FROM t_rows_fetched_ptr",SQL_NTS); mystmt(hstmt,rc); i= 0; @@ -803,7 +803,7 @@ rc = SQLSetStmtAttr(hstmt, SQL_ATTR_ROWS_FETCHED_PTR, &rowsFetched, 0); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt, "SELECT * FROM t_rows_fetched_ptr",SQL_NTS); + rc = SQLExecDirect(hstmt, (SQLCHAR *)"SELECT * FROM t_rows_fetched_ptr",SQL_NTS); mystmt(hstmt,rc); i= 0; @@ -825,7 +825,7 @@ rc = SQLSetStmtAttr(hstmt, SQL_ATTR_ROWS_FETCHED_PTR, &rowsFetched, 0); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt, "SELECT * FROM t_rows_fetched_ptr",SQL_NTS); + rc = SQLExecDirect(hstmt, (SQLCHAR *)"SELECT * FROM t_rows_fetched_ptr",SQL_NTS); mystmt(hstmt,rc); i= 0; @@ -847,7 +847,7 @@ rc = SQLSetStmtAttr(hstmt, SQL_ATTR_ROWS_FETCHED_PTR, &rowsFetched, 0); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt, "SELECT * FROM t_rows_fetched_ptr",SQL_NTS); + rc = SQLExecDirect(hstmt, (SQLCHAR *)"SELECT * FROM t_rows_fetched_ptr",SQL_NTS); mystmt(hstmt,rc); rc = SQLFetch(hstmt); --- myodbc-3.51.15r409.orig/test/my_result.c +++ myodbc-3.51.15r409/test/my_result.c @@ -26,13 +26,14 @@ DECLARE_TEST(my_resultset) { SQLRETURN rc; - SQLUINTEGER nRowCount=0, pcColDef; + SQLUINTEGER nRowCount=0; + SQLULEN pcColDef; SQLCHAR szColName[MAX_NAME_LEN]; SQLCHAR szData[MAX_ROW_DATA_LEN+1]; SQLSMALLINT nIndex,ncol,pfSqlType, pcbScale, pfNullable; /* drop table 'myodbc3_demo_result' if it already exists */ - rc = SQLExecDirect(hstmt,"DROP TABLE if exists myodbc3_demo_result",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"DROP TABLE if exists myodbc3_demo_result",SQL_NTS); mystmt(hstmt,rc); /* commit the transaction */ @@ -40,7 +41,7 @@ mycon(hdbc,rc); /* create the table 'myodbc3_demo_result' */ - rc = SQLExecDirect(hstmt,"CREATE TABLE myodbc3_demo_result(\ + rc = SQLExecDirect(hstmt,(SQLCHAR *)"CREATE TABLE myodbc3_demo_result(\ id int primary key auto_increment,\ name varchar(20))",SQL_NTS); mystmt(hstmt,rc); @@ -49,11 +50,11 @@ mycon(hdbc,rc); /* insert 2 rows of data */ - rc = SQLExecDirect(hstmt,"INSERT INTO myodbc3_demo_result values(\ + rc = SQLExecDirect(hstmt,(SQLCHAR *)"INSERT INTO myodbc3_demo_result values(\ 1,'MySQL')",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"INSERT INTO myodbc3_demo_result values(\ + rc = SQLExecDirect(hstmt,(SQLCHAR *)"INSERT INTO myodbc3_demo_result values(\ 2,'MyODBC')",SQL_NTS); mystmt(hstmt,rc); @@ -62,7 +63,7 @@ mycon(hdbc,rc); /* update second row */ - rc = SQLExecDirect(hstmt,"UPDATE myodbc3_demo_result set name=\ + rc = SQLExecDirect(hstmt,(SQLCHAR *)"UPDATE myodbc3_demo_result set name=\ 'MyODBC 3.51' where id=2",SQL_NTS); mystmt(hstmt,rc); @@ -71,7 +72,7 @@ mycon(hdbc,rc); /* now fetch back..*/ - rc = SQLExecDirect(hstmt,"SELECT * from myodbc3_demo_result",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"SELECT * from myodbc3_demo_result",SQL_NTS); mystmt(hstmt,rc); /* get total number of columns from the resultset */ @@ -121,7 +122,7 @@ rc = SQLFreeStmt(hstmt, SQL_CLOSE); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt, "DROP TABLE myodbc3_demo_result", SQL_NTS); + rc = SQLExecDirect(hstmt, (SQLCHAR *)"DROP TABLE myodbc3_demo_result", SQL_NTS); mystmt(hstmt,rc); return OK; @@ -157,26 +158,26 @@ rc = SQLGetInfo(hdbc,SQL_DBMS_VER,(SQLCHAR *)&DbVersion,MAX_NAME_LEN,NULL); mycon(hdbc,rc); - SQLExecDirect(hstmt,"DROP TABLE t_convert",SQL_NTS); + SQLExecDirect(hstmt,(SQLCHAR *)"DROP TABLE t_convert",SQL_NTS); - rc = SQLExecDirect(hstmt,"CREATE TABLE t_convert(col0 integer, \ + rc = SQLExecDirect(hstmt,(SQLCHAR *)"CREATE TABLE t_convert(col0 integer, \ col1 date,\ col2 char(10))",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"INSERT INTO t_convert VALUES(10,'2002-10-24','venu')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"INSERT INTO t_convert VALUES(10,'2002-10-24','venu')",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"INSERT INTO t_convert VALUES(20,'2002-10-23','venu1')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"INSERT INTO t_convert VALUES(20,'2002-10-23','venu1')",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"INSERT INTO t_convert VALUES(30,'2002-10-25','venu2')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"INSERT INTO t_convert VALUES(30,'2002-10-25','venu2')",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"INSERT INTO t_convert VALUES(40,'2002-10-24','venu3')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"INSERT INTO t_convert VALUES(40,'2002-10-24','venu3')",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"SELECT MAX(col0) FROM t_convert",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"SELECT MAX(col0) FROM t_convert",SQL_NTS); mystmt(hstmt,rc); rc = SQLDescribeCol(hstmt,1,(SQLCHAR *)&ColName,MAX_NAME_LEN,NULL,&SqlType,NULL,NULL,NULL); @@ -187,7 +188,7 @@ SQLFreeStmt(hstmt,SQL_CLOSE); - rc = SQLExecDirect(hstmt,"SELECT MAX(col1) FROM t_convert",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"SELECT MAX(col1) FROM t_convert",SQL_NTS); mystmt(hstmt,rc); rc = SQLDescribeCol(hstmt,1,(SQLCHAR *)&ColName,MAX_NAME_LEN,NULL,&SqlType,NULL,NULL,NULL); @@ -198,7 +199,7 @@ SQLFreeStmt(hstmt,SQL_CLOSE); - rc = SQLExecDirect(hstmt,"SELECT MAX(col2) FROM t_convert",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"SELECT MAX(col2) FROM t_convert",SQL_NTS); mystmt(hstmt,rc); rc = SQLDescribeCol(hstmt,1,(SQLCHAR *)&ColName,MAX_NAME_LEN,NULL,&SqlType,NULL,NULL,NULL); @@ -210,7 +211,7 @@ if (strncmp(DbVersion,"4.",2) >= 0) { - rc = SQLExecDirect(hstmt,"SELECT CAST(MAX(col1) AS DATE) AS col1 FROM t_convert",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"SELECT CAST(MAX(col1) AS DATE) AS col1 FROM t_convert",SQL_NTS); mystmt(hstmt,rc); rc = SQLDescribeCol(hstmt,1,(SQLCHAR *)&ColName,MAX_NAME_LEN,NULL,&SqlType,NULL,NULL,NULL); @@ -221,7 +222,7 @@ SQLFreeStmt(hstmt,SQL_CLOSE); - rc = SQLExecDirect(hstmt,"SELECT CONVERT(MAX(col1),DATE) AS col1 FROM t_convert",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"SELECT CONVERT(MAX(col1),DATE) AS col1 FROM t_convert",SQL_NTS); mystmt(hstmt,rc); rc = SQLDescribeCol(hstmt,1,(SQLCHAR *)&ColName,MAX_NAME_LEN,NULL,&SqlType,NULL,NULL,NULL); @@ -232,7 +233,7 @@ SQLFreeStmt(hstmt,SQL_CLOSE); - rc = SQLExecDirect(hstmt,"SELECT CAST(MAX(col1) AS CHAR) AS col1 FROM t_convert",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"SELECT CAST(MAX(col1) AS CHAR) AS col1 FROM t_convert",SQL_NTS); mystmt(hstmt,rc); rc = SQLDescribeCol(hstmt,1,(SQLCHAR *)&ColName,MAX_NAME_LEN,NULL,&SqlType,NULL,NULL,NULL); @@ -244,7 +245,7 @@ SQLFreeStmt(hstmt,SQL_CLOSE); } - rc = SQLExecDirect(hstmt,"DROP TABLE t_convert",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"DROP TABLE t_convert",SQL_NTS); mystmt(hstmt,rc); SQLFreeStmt(hstmt,SQL_CLOSE); @@ -264,7 +265,7 @@ { SQLRETURN rc; SQLSMALLINT pcbColName, pfSqlType, pibScale, pfNullable; - SQLUINTEGER pcbColDef; + SQLULEN pcbColDef; SQLCHAR szColName[MAX_NAME_LEN]; rc = SQLDescribeCol(hstmt, icol, @@ -277,7 +278,7 @@ fprintf(stdout, "\t Column Name : %s\n", szColName); fprintf(stdout, "\t NameLengh : %d\n", pcbColName); fprintf(stdout, "\t DataType : %d\n", pfSqlType); - fprintf(stdout, "\t ColumnSize : %d\n", pcbColDef); + fprintf(stdout, "\t ColumnSize : %ld\n", pcbColDef); fprintf(stdout, "\t DecimalDigits : %d\n", pibScale); fprintf(stdout, "\t Nullable : %d\n", pfNullable); @@ -297,9 +298,9 @@ SQLFreeStmt(hstmt, SQL_CLOSE); - SQLExecDirect(hstmt,"DROP TABLE t_desc_col",SQL_NTS); + SQLExecDirect(hstmt,(SQLCHAR *)"DROP TABLE t_desc_col",SQL_NTS); - rc = SQLExecDirect(hstmt,"CREATE TABLE t_desc_col(c1 integer, \ + rc = SQLExecDirect(hstmt,(SQLCHAR *)"CREATE TABLE t_desc_col(c1 integer, \ c2 binary(2) NOT NULL,\ c3 char(1), \ c4 varchar(5),\ @@ -324,7 +325,7 @@ c23 tinyblob)",SQL_NTS); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"SELECT * FROM t_desc_col",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"SELECT * FROM t_desc_col",SQL_NTS); mystmt(hstmt,rc); rc = SQLNumResultCols(hstmt, &ColumnCount); @@ -435,7 +436,7 @@ rc = SQLTransact(NULL,hdbc,SQL_COMMIT); mycon(hdbc,rc); - rc = SQLPrepare(hstmt,"insert into t_max_rows values(?)",SQL_NTS); + rc = SQLPrepare(hstmt,(SQLCHAR *)"insert into t_max_rows values(?)",SQL_NTS); mystmt(hstmt,rc); rc = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT,SQL_C_ULONG,SQL_INTEGER,0,0,&i,0,NULL); @@ -539,7 +540,7 @@ rc = SQLFetch(hstmt); mystmt(hstmt,rc); - fprintf(stdout,"id: %ld\n",id); + fprintf(stdout,"id: %d\n",id); myassert(id == 10); rc = SQLGetData(hstmt,2,SQL_C_CHAR,szData,0,&pcbValue); @@ -647,13 +648,13 @@ pcbValue= pcbValue1= 99; rc = SQLGetData(hstmt,1,SQL_C_CHAR,szData,0,&pcbValue); mystmt_err(hstmt,rc == SQL_SUCCESS_WITH_INFO,rc); - fprintf(stdout,"length: %d\n", pcbValue); + fprintf(stdout,"length: %ld\n", pcbValue); myassert(pcbValue == 0); bData[0]=bData[1]='z'; rc = SQLGetData(hstmt,2,SQL_C_BINARY,bData,0,&pcbValue1); mystmt_err(hstmt,rc == SQL_SUCCESS_WITH_INFO,rc); - fprintf(stdout,"length: %d\n", pcbValue1); + fprintf(stdout,"length: %ld\n", pcbValue1); myassert(pcbValue1 == 0); myassert(bData[0] == 'z'); myassert(bData[1] == 'z'); @@ -661,7 +662,7 @@ bData1[0]=bData1[1]='z'; rc = SQLGetData(hstmt,3,SQL_C_BINARY,bData1,0,&pcbValue2); mystmt_err(hstmt,rc == SQL_SUCCESS_WITH_INFO,rc); - fprintf(stdout,"length: %d\n", pcbValue2); + fprintf(stdout,"length: %ld\n", pcbValue2); myassert(pcbValue2 == 0); myassert(bData1[0] == 'z'); myassert(bData1[1] == 'z'); @@ -669,21 +670,21 @@ pcbValue= pcbValue1= 99; rc = SQLGetData(hstmt,1,SQL_C_CHAR,szData,1,&pcbValue); mystmt(hstmt,rc); - fprintf(stdout,"data: %s, length: %d\n", szData, pcbValue); + fprintf(stdout,"data: %s, length: %ld\n", szData, pcbValue); myassert(pcbValue == 0); myassert(szData[0] == '\0'); bData[0]=bData[1]='z'; rc = SQLGetData(hstmt,2,SQL_C_BINARY,bData,1,&pcbValue1); mystmt(hstmt,rc); - fprintf(stdout,"data: %s, length: %d\n", bData, pcbValue1); + fprintf(stdout,"data: %s, length: %ld\n", bData, pcbValue1); myassert(pcbValue1 == 0); myassert(bData[0]== '\0'); bData1[0]=bData1[1]='z'; rc = SQLGetData(hstmt,3,SQL_C_CHAR,bData1,1,&pcbValue2); mystmt(hstmt,rc); - fprintf(stdout,"data: %s, length: %d\n", bData1, pcbValue2); + fprintf(stdout,"data: %s, length: %ld\n", bData1, pcbValue2); myassert(pcbValue2 == 0); myassert(bData1[0] == '\0'); myassert(bData1[1] == 'z'); @@ -695,40 +696,40 @@ szData[0]= bData[0]= 'z'; rc = SQLGetData(hstmt,1,SQL_C_CHAR,szData,0,&pcbValue); mystmt_err(hstmt,rc == SQL_SUCCESS_WITH_INFO,rc); - fprintf(stdout,"length: %d\n", pcbValue); + fprintf(stdout,"length: %ld\n", pcbValue); myassert(pcbValue == 4); myassert(szData[0] == 'z'); rc = SQLGetData(hstmt,2,SQL_C_BINARY,bData,0,&pcbValue1); mystmt_err(hstmt,rc == SQL_SUCCESS_WITH_INFO,rc); - fprintf(stdout,"length: %d\n", pcbValue1); + fprintf(stdout,"length: %ld\n", pcbValue1); myassert(pcbValue1 == 5); myassert(bData[0] == 'z'); bData[0]=bData1[1]='z'; rc = SQLGetData(hstmt,3,SQL_C_BINARY,bData1,0,&pcbValue2); mystmt_err(hstmt,rc == SQL_SUCCESS_WITH_INFO,rc); - fprintf(stdout,"length: %d\n", pcbValue2); + fprintf(stdout,"length: %ld\n", pcbValue2); myassert(pcbValue2 == 5); pcbValue= pcbValue1= 99; szData[0]= szData[1]= bData[0]= bData[1]= 'z'; rc = SQLGetData(hstmt,1,SQL_C_CHAR,szData,1,&pcbValue); mystmt_err(hstmt,rc == SQL_SUCCESS_WITH_INFO,rc); - fprintf(stdout,"data: %s, length: %d\n", szData,pcbValue); + fprintf(stdout,"data: %s, length: %ld\n", szData,pcbValue); myassert(pcbValue == 4); myassert(szData[0] == '\0'); rc = SQLGetData(hstmt,2,SQL_C_BINARY,bData,1,&pcbValue1); mystmt_err(hstmt,rc == SQL_SUCCESS_WITH_INFO,rc); - fprintf(stdout,"data; %s, length: %d\n", bData, pcbValue1); + fprintf(stdout,"data; %s, length: %ld\n", bData, pcbValue1); myassert(pcbValue1 == 5); myassert(bData[0] == 'm'); bData[0]=bData1[1]='z'; rc = SQLGetData(hstmt,3,SQL_C_BINARY,bData1,1,&pcbValue2); mystmt_err(hstmt,rc == SQL_SUCCESS_WITH_INFO,rc); - fprintf(stdout,"length: %d\n", pcbValue2); + fprintf(stdout,"length: %ld\n", pcbValue2); myassert(pcbValue2 == 5); myassert(bData1[0] == 'm'); myassert(bData1[1] == 'z'); @@ -736,33 +737,33 @@ pcbValue= pcbValue1= 99; rc = SQLGetData(hstmt,1,SQL_C_CHAR,szData,4,&pcbValue); mystmt_err(hstmt,rc == SQL_SUCCESS_WITH_INFO,rc); - fprintf(stdout,"data: %s, length: %d\n", szData, pcbValue); + fprintf(stdout,"data: %s, length: %ld\n", szData, pcbValue); myassert(pcbValue == 4); myassert(strcmp(szData,"ven")==0); rc = SQLGetData(hstmt,2,SQL_C_BINARY,bData,4,&pcbValue1); mystmt_err(hstmt,rc == SQL_SUCCESS_WITH_INFO,rc); - fprintf(stdout,"data: %s, length: %d\n", bData, pcbValue1); + fprintf(stdout,"data: %s, length: %ld\n", bData, pcbValue1); myassert(pcbValue1 == 5); myassert(strncmp(bData,"mysq",4)==0); pcbValue= pcbValue1= 99; rc = SQLGetData(hstmt,1,SQL_C_CHAR,szData,5,&pcbValue); mystmt(hstmt,rc); - fprintf(stdout,"data: %s, length: %d\n", szData, pcbValue); + fprintf(stdout,"data: %s, length: %ld\n", szData, pcbValue); myassert(pcbValue == 4); myassert(strcmp(szData,"venu")==0); rc = SQLGetData(hstmt,2,SQL_C_BINARY,bData,5,&pcbValue1); mystmt(hstmt,rc); - fprintf(stdout,"data: %s, length: %d\n", bData, pcbValue1); + fprintf(stdout,"data: %s, length: %ld\n", bData, pcbValue1); myassert(pcbValue1 == 5); myassert(strncmp(bData,"mysql",5)==0); szData[0]= 'z'; rc = SQLGetData(hstmt,3,SQL_C_CHAR,szData,0,&pcbValue); mystmt_err(hstmt,rc == SQL_SUCCESS_WITH_INFO,rc); - fprintf(stdout,"data: %s, length: %d\n", szData, pcbValue); + fprintf(stdout,"data: %s, length: %ld\n", szData, pcbValue); myassert(pcbValue == 5 || pcbValue == 10); myassert(szData[0] == 'z'); @@ -835,7 +836,7 @@ rc = tmysql_exec(hstmt11,"insert into t_cache values(5)"); mystmt(hstmt11,rc); - rc = SQLExecDirect(hstmt11,"select * from t_cache",SQL_NTS); + rc = SQLExecDirect(hstmt11,(SQLCHAR *)"select * from t_cache",SQL_NTS); mystmt(hstmt11,rc); rc = SQLFetch(hstmt11); @@ -848,7 +849,7 @@ mycon(hdbc1,rc); rc = SQLColumns(hstmt12,test_db,SQL_NTS, - NULL,0,"t_cache",SQL_NTS, + NULL,0,(SQLCHAR *)"t_cache",SQL_NTS, NULL,0); mystmt(hstmt12,rc); @@ -926,7 +927,7 @@ rc = tmysql_exec(hstmt11,"insert into t_cache values(5)"); mystmt(hstmt11,rc); - rc = SQLExecDirect(hstmt11,"select * from t_cache",SQL_NTS); + rc = SQLExecDirect(hstmt11,(SQLCHAR *)"select * from t_cache",SQL_NTS); mystmt(hstmt11,rc); rc = SQLFetch(hstmt11); @@ -939,7 +940,7 @@ mycon(hdbc1,rc); rc = SQLColumns(hstmt12,test_db,SQL_NTS, - NULL,0,"t_cache",SQL_NTS, + NULL,0,(SQLCHAR *)"t_cache",SQL_NTS, NULL,0); mystmt(hstmt12,rc); @@ -1004,7 +1005,7 @@ rc = SQLFreeStmt(hstmt,SQL_CLOSE); mystmt(hstmt,rc); - rc = SQLSetCursorName(hstmt,"venu",SQL_NTS); + rc = SQLSetCursorName(hstmt,(SQLCHAR *)"venu",SQL_NTS); mystmt(hstmt,rc); rc = tmysql_exec(hstmt,"select * from t_empty_str_bug"); @@ -1032,7 +1033,7 @@ rc = SQLRowCount(hstmt,&name_len); mystmt(hstmt,rc); - fprintf(stdout," rows affected:%d\n",name_len); + fprintf(stdout," rows affected:%ld\n",name_len); myassert(name_len == 1); rc = SQLFreeStmt(hstmt,SQL_UNBIND); @@ -1088,7 +1089,7 @@ rc = SQLFreeStmt(hstmt,SQL_CLOSE); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into t_desccol values(10,'venu','mysql')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into t_desccol values(10,'venu','mysql')",SQL_NTS); mystmt(hstmt,rc); rc = SQLFreeStmt(hstmt,SQL_CLOSE); @@ -1100,15 +1101,15 @@ rc = tmysql_exec(hstmt,"select * from t_desccol"); mystmt(hstmt,rc); - rc = SQLDescribeCol(hstmt,1,(char *)colname,20,&collen,&datatype,&colsize,&decptr,&nullable); + rc = SQLDescribeCol(hstmt,1,colname,20,&collen,&datatype,&colsize,&decptr,&nullable); mystmt(hstmt,rc); printMessage("1: %s,%d,%d,%d,%d,%d\n",colname,collen,datatype,colsize,decptr,nullable);; - rc = SQLDescribeCol(hstmt,2,(char *)colname,20,&collen,&datatype,&colsize,&decptr,&nullable); + rc = SQLDescribeCol(hstmt,2,colname,20,&collen,&datatype,&colsize,&decptr,&nullable); mystmt(hstmt,rc); printMessage("2: %s,%d,%d,%d,%d,%d\n",colname,collen,datatype,colsize,decptr,nullable);; - rc = SQLDescribeCol(hstmt,3,(char *)colname,20,&collen,&datatype,&colsize,&decptr,&nullable); + rc = SQLDescribeCol(hstmt,3,colname,20,&collen,&datatype,&colsize,&decptr,&nullable); mystmt(hstmt,rc); printMessage("3: %s,%d,%d,%d,%d,%d\n",colname,collen,datatype,colsize,decptr,nullable);; @@ -1164,7 +1165,7 @@ DECLARE_TEST(t_desccolext) { SQLRETURN rc; - SQLCHAR *sql; + char *sql; tmysql_exec(hstmt,"drop table t_desccolext"); @@ -1237,36 +1238,36 @@ rc = SQLFreeStmt(hstmt,SQL_CLOSE); mystmt(hstmt,rc); - desccol(hstmt,"t1",2,SQL_TINYINT,4,0,SQL_NULLABLE); - desccol(hstmt,"t2",2,SQL_TINYINT,10,0,SQL_NULLABLE); - desccol(hstmt,"t3",2,SQL_TINYINT,3,0,SQL_NULLABLE); - - desccol(hstmt,"s1",2,SQL_SMALLINT,6,0,SQL_NULLABLE); - desccol(hstmt,"s2",2,SQL_SMALLINT,10,0,SQL_NULLABLE); - desccol(hstmt,"s3",2,SQL_SMALLINT,5,0,SQL_NULLABLE); - - desccol(hstmt,"m1",2,SQL_INTEGER,9,0,SQL_NULLABLE); - desccol(hstmt,"m2",2,SQL_INTEGER,10,0,SQL_NULLABLE); - desccol(hstmt,"m3",2,SQL_INTEGER,8,0,SQL_NULLABLE); - - desccol(hstmt,"i1",2,SQL_INTEGER,11,0,SQL_NULLABLE); - desccol(hstmt,"i2",2,SQL_INTEGER,10,0,SQL_NO_NULLS); - desccol(hstmt,"i3",2,SQL_INTEGER,10,0,SQL_NULLABLE); - desccol(hstmt,"i4",2,SQL_INTEGER,10,0,SQL_NULLABLE); - - desccol(hstmt,"b1",2,SQL_BIGINT,19,0,SQL_NULLABLE); - desccol(hstmt,"b2",2,SQL_BIGINT,19,0,SQL_NULLABLE); - desccol(hstmt,"b3",2,SQL_BIGINT,20,0,SQL_NULLABLE); - - desccol(hstmt,"f1",2,SQL_REAL,12,31,SQL_NULLABLE); - desccol(hstmt,"f2",2,SQL_REAL,12,31,SQL_NULLABLE); - desccol(hstmt,"f3",2,SQL_REAL,12,31,SQL_NULLABLE); - desccol(hstmt,"f4",2,SQL_REAL,10,4,SQL_NULLABLE); - - desccol(hstmt,"d1",2,SQL_DOUBLE,22,31,SQL_NULLABLE); - desccol(hstmt,"d2",2,SQL_DOUBLE,30,3,SQL_NULLABLE); - desccol(hstmt,"d3",2,SQL_DOUBLE,22,31,SQL_NULLABLE); - desccol(hstmt,"d4",2,SQL_DOUBLE,30,3,SQL_NULLABLE); + desccol(hstmt,(SQLCHAR *)"t1",2,SQL_TINYINT,4,0,SQL_NULLABLE); + desccol(hstmt,(SQLCHAR *)"t2",2,SQL_TINYINT,10,0,SQL_NULLABLE); + desccol(hstmt,(SQLCHAR *)"t3",2,SQL_TINYINT,3,0,SQL_NULLABLE); + + desccol(hstmt,(SQLCHAR *)"s1",2,SQL_SMALLINT,6,0,SQL_NULLABLE); + desccol(hstmt,(SQLCHAR *)"s2",2,SQL_SMALLINT,10,0,SQL_NULLABLE); + desccol(hstmt,(SQLCHAR *)"s3",2,SQL_SMALLINT,5,0,SQL_NULLABLE); + + desccol(hstmt,(SQLCHAR *)"m1",2,SQL_INTEGER,9,0,SQL_NULLABLE); + desccol(hstmt,(SQLCHAR *)"m2",2,SQL_INTEGER,10,0,SQL_NULLABLE); + desccol(hstmt,(SQLCHAR *)"m3",2,SQL_INTEGER,8,0,SQL_NULLABLE); + + desccol(hstmt,(SQLCHAR *)"i1",2,SQL_INTEGER,11,0,SQL_NULLABLE); + desccol(hstmt,(SQLCHAR *)"i2",2,SQL_INTEGER,10,0,SQL_NO_NULLS); + desccol(hstmt,(SQLCHAR *)"i3",2,SQL_INTEGER,10,0,SQL_NULLABLE); + desccol(hstmt,(SQLCHAR *)"i4",2,SQL_INTEGER,10,0,SQL_NULLABLE); + + desccol(hstmt,(SQLCHAR *)"b1",2,SQL_BIGINT,19,0,SQL_NULLABLE); + desccol(hstmt,(SQLCHAR *)"b2",2,SQL_BIGINT,19,0,SQL_NULLABLE); + desccol(hstmt,(SQLCHAR *)"b3",2,SQL_BIGINT,20,0,SQL_NULLABLE); + + desccol(hstmt,(SQLCHAR *)"f1",2,SQL_REAL,12,31,SQL_NULLABLE); + desccol(hstmt,(SQLCHAR *)"f2",2,SQL_REAL,12,31,SQL_NULLABLE); + desccol(hstmt,(SQLCHAR *)"f3",2,SQL_REAL,12,31,SQL_NULLABLE); + desccol(hstmt,(SQLCHAR *)"f4",2,SQL_REAL,10,4,SQL_NULLABLE); + + desccol(hstmt,(SQLCHAR *)"d1",2,SQL_DOUBLE,22,31,SQL_NULLABLE); + desccol(hstmt,(SQLCHAR *)"d2",2,SQL_DOUBLE,30,3,SQL_NULLABLE); + desccol(hstmt,(SQLCHAR *)"d3",2,SQL_DOUBLE,22,31,SQL_NULLABLE); + desccol(hstmt,(SQLCHAR *)"d4",2,SQL_DOUBLE,30,3,SQL_NULLABLE); rc = SQLFreeStmt(hstmt,SQL_CLOSE); mystmt(hstmt,rc); @@ -1280,7 +1281,7 @@ SQLRETURN rc; tmysql_exec(hstmt,"drop table if exists t_desccol1"); - rc = SQLExecDirect(hstmt,"create table t_desccol1\ + rc = SQLExecDirect(hstmt,(SQLCHAR *)"create table t_desccol1\ ( record decimal(8,0),\ title varchar(250),\ num1 float,\ @@ -1449,7 +1450,7 @@ rc = tmysql_exec(hstmt,"create table t_exfetch(col1 int)"); mystmt(hstmt,rc); - rc = SQLPrepare(hstmt,"insert into t_exfetch values(?)",SQL_NTS); + rc = SQLPrepare(hstmt,(SQLCHAR *)"insert into t_exfetch values(?)",SQL_NTS); mystmt(hstmt,rc); rc = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT, SQL_C_ULONG, @@ -1468,7 +1469,7 @@ rc = SQLTransact(NULL,hdbc,SQL_COMMIT); mycon(hdbc,rc); - rc = SQLExecDirect(hstmt,"select * from t_exfetch",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"select * from t_exfetch",SQL_NTS); mystmt(hstmt,rc); rc = SQLBindCol(hstmt,1,SQL_C_LONG,&i,0,NULL); @@ -1575,7 +1576,7 @@ rc = SQLAllocStmt(hdbc,&hstmt1); mycon(hdbc,rc); - rc = SQLSetCursorName(hstmt,"venu_cur",SQL_NTS); + rc = SQLSetCursorName(hstmt,(SQLCHAR *)"venu_cur",SQL_NTS); mystmt(hstmt,rc); tmysql_exec(hstmt,"drop table tmysql_rowstatus"); @@ -1627,7 +1628,7 @@ rc = SQLSetPos(hstmt,1,SQL_POSITION,SQL_LOCK_NO_CHANGE); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt1,"UPDATE tmysql_rowstatus SET col1= 999, col2 = 'pos-update' WHERE CURRENT OF venu_cur",SQL_NTS); + rc = SQLExecDirect(hstmt1,(SQLCHAR *)"UPDATE tmysql_rowstatus SET col1= 999, col2 = 'pos-update' WHERE CURRENT OF venu_cur",SQL_NTS); mystmt(hstmt1,rc); rc = SQLExtendedFetch(hstmt,SQL_FETCH_LAST,1,NULL,NULL); --- myodbc-3.51.15r409.orig/test/my_scroll.c +++ myodbc-3.51.15r409/test/my_scroll.c @@ -25,7 +25,6 @@ /* Testing basic scrolling feature */ DECLARE_TEST(t_scroll) { - SQLRETURN rc; SQLUINTEGER i; ok_sql(hstmt, "DROP TABLE IF EXISTS t_scroll"); @@ -121,12 +120,12 @@ SQLUINTEGER i,index; char name[21]; - SQLExecDirect(hstmt,"drop table t_array_relative_10",SQL_NTS); + SQLExecDirect(hstmt,(SQLCHAR *)"drop table t_array_relative_10",SQL_NTS); - rc = SQLExecDirect(hstmt,"create table t_array_relative_10(id int,name char(20))",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"create table t_array_relative_10(id int,name char(20))",SQL_NTS); mystmt(hstmt,rc); - rc = SQLPrepare(hstmt,"insert into t_array_relative_10 values(?,?)",SQL_NTS); + rc = SQLPrepare(hstmt,(SQLCHAR *)"insert into t_array_relative_10 values(?,?)",SQL_NTS); mystmt(hstmt,rc); rc = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT, SQL_C_ULONG, @@ -156,7 +155,7 @@ rc = SQLSetStmtAttr(hstmt,SQL_ATTR_ROWS_FETCHED_PTR,&nrows,0); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"select * from t_array_relative_10",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"select * from t_array_relative_10",SQL_NTS); mystmt(hstmt,rc); rc = SQLBindCol(hstmt,1,SQL_C_LONG,&iarray,0,NULL); @@ -260,12 +259,12 @@ SQLUINTEGER i; const int max_rows=10; - SQLExecDirect(hstmt,"drop table t_relative_1",SQL_NTS); + SQLExecDirect(hstmt,(SQLCHAR *)"drop table t_relative_1",SQL_NTS); - rc = SQLExecDirect(hstmt,"create table t_relative_1(id int)",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"create table t_relative_1(id int)",SQL_NTS); mystmt(hstmt,rc); - rc = SQLPrepare(hstmt,"insert into t_relative_1 values(?)",SQL_NTS); + rc = SQLPrepare(hstmt,(SQLCHAR *)"insert into t_relative_1 values(?)",SQL_NTS); mystmt(hstmt,rc); rc = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT, SQL_C_ULONG, @@ -291,7 +290,7 @@ rc = SQLSetStmtAttr(hstmt,SQL_ATTR_ROWS_FETCHED_PTR,&nrows,0); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"select * from t_relative_1",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"select * from t_relative_1",SQL_NTS); mystmt(hstmt,rc); rc = SQLBindCol(hstmt,1,SQL_C_LONG,&i,0,NULL); @@ -466,12 +465,12 @@ SQLINTEGER iarray[15]; const int max_rows=10; - SQLExecDirect(hstmt,"drop table t_array_relative_2",SQL_NTS); + SQLExecDirect(hstmt,(SQLCHAR *)"drop table t_array_relative_2",SQL_NTS); - rc = SQLExecDirect(hstmt,"create table t_array_relative_2(id int)",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"create table t_array_relative_2(id int)",SQL_NTS); mystmt(hstmt,rc); - rc = SQLPrepare(hstmt,"insert into t_array_relative_2 values(?)",SQL_NTS); + rc = SQLPrepare(hstmt,(SQLCHAR *)"insert into t_array_relative_2 values(?)",SQL_NTS); mystmt(hstmt,rc); rc = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT, SQL_C_ULONG, @@ -497,7 +496,7 @@ rc = SQLSetStmtAttr(hstmt,SQL_ATTR_ROWS_FETCHED_PTR,&nrows,0); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"select * from t_array_relative_2",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"select * from t_array_relative_2",SQL_NTS); mystmt(hstmt,rc); rc = SQLBindCol(hstmt,1,SQL_C_LONG,&iarray,0,NULL); @@ -704,7 +703,7 @@ rc = SQLSetStmtAttr(hstmt,SQL_ATTR_ROWS_FETCHED_PTR,&nrows,0); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"select * from t_array_relative_2",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"select * from t_array_relative_2",SQL_NTS); mystmt(hstmt,rc); rc = SQLBindCol(hstmt,1,SQL_C_LONG,&iarray,0,NULL); @@ -774,12 +773,12 @@ SQLUINTEGER i; const int max_rows=10; - SQLExecDirect(hstmt,"drop table t_absolute_1",SQL_NTS); + SQLExecDirect(hstmt,(SQLCHAR *)"drop table t_absolute_1",SQL_NTS); - rc = SQLExecDirect(hstmt,"create table t_absolute_1(id int)",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"create table t_absolute_1(id int)",SQL_NTS); mystmt(hstmt,rc); - rc = SQLPrepare(hstmt,"insert into t_absolute_1 values(?)",SQL_NTS); + rc = SQLPrepare(hstmt,(SQLCHAR *)"insert into t_absolute_1 values(?)",SQL_NTS); mystmt(hstmt,rc); rc = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT, SQL_C_ULONG, @@ -805,7 +804,7 @@ rc = SQLSetStmtAttr(hstmt,SQL_ATTR_ROWS_FETCHED_PTR,&nrows,0); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"select * from t_absolute_1",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"select * from t_absolute_1",SQL_NTS); mystmt(hstmt,rc); rc = SQLBindCol(hstmt,1,SQL_C_LONG,&i,0,NULL); @@ -955,12 +954,12 @@ const int max_rows=10; SQLUINTEGER i; - SQLExecDirect(hstmt,"drop table t_absolute_2",SQL_NTS); + SQLExecDirect(hstmt,(SQLCHAR *)"drop table t_absolute_2",SQL_NTS); - rc = SQLExecDirect(hstmt,"create table t_absolute_2(id int)",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"create table t_absolute_2(id int)",SQL_NTS); mystmt(hstmt,rc); - rc = SQLPrepare(hstmt,"insert into t_absolute_2 values(?)",SQL_NTS); + rc = SQLPrepare(hstmt,(SQLCHAR *)"insert into t_absolute_2 values(?)",SQL_NTS); mystmt(hstmt,rc); rc = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT, SQL_C_ULONG, @@ -986,7 +985,7 @@ rc = SQLSetStmtAttr(hstmt,SQL_ATTR_ROWS_FETCHED_PTR,&nrows,0); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"select * from t_absolute_2",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"select * from t_absolute_2",SQL_NTS); mystmt(hstmt,rc); rc = SQLBindCol(hstmt,1,SQL_C_LONG,&iarray,0,NULL); @@ -1153,7 +1152,7 @@ rc = SQLSetStmtAttr(hstmt,SQL_ATTR_ROWS_FETCHED_PTR,&nrows,0); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"select * from t_absolute_2",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"select * from t_absolute_2",SQL_NTS); mystmt(hstmt,rc); rc = SQLBindCol(hstmt,1,SQL_C_LONG,&iarray,0,NULL); --- myodbc-3.51.15r409.orig/test/my_types.c +++ myodbc-3.51.15r409/test/my_types.c @@ -140,7 +140,7 @@ rc = SQLTransact(NULL,hdbc,SQL_COMMIT); mycon(hdbc,rc); - rc = SQLPrepare(hstmt,"insert into t_decimal values (?),(?),(?),(?)",SQL_NTS); + rc = SQLPrepare(hstmt,(SQLCHAR *)"insert into t_decimal values (?),(?),(?),(?)",SQL_NTS); mystmt(hstmt,rc); rc = SQLBindParameter( hstmt, 1, SQL_PARAM_INPUT, SQL_C_DOUBLE, @@ -171,7 +171,7 @@ rc = SQLTransact(NULL,hdbc,SQL_COMMIT); mycon(hdbc,rc); - rc = SQLExecDirect(hstmt,"select d1 from t_decimal",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"select d1 from t_decimal",SQL_NTS); mystmt(hstmt,rc); rc = SQLFetch(hstmt); @@ -270,7 +270,7 @@ mycon(hdbc,rc); rc = SQLSpecialColumns(hstmt,SQL_ROWVER,NULL,SQL_NTS,NULL,SQL_NTS, - "t_bigint",SQL_NTS,SQL_SCOPE_TRANSACTION,SQL_NULLABLE); + (SQLCHAR *)"t_bigint",SQL_NTS,SQL_SCOPE_TRANSACTION,SQL_NULLABLE); mycon(hdbc,rc); @@ -279,7 +279,7 @@ rc = SQLFreeStmt(hstmt,SQL_CLOSE); mystmt(hstmt,rc); - rc = SQLColumns(hstmt,NULL,SQL_NTS,NULL,SQL_NTS,"t_bigint",SQL_NTS,NULL,SQL_NTS); + rc = SQLColumns(hstmt,NULL,SQL_NTS,NULL,SQL_NTS,(SQLCHAR *)"t_bigint",SQL_NTS,NULL,SQL_NTS); mycon(hdbc,rc); @@ -288,7 +288,7 @@ rc = SQLFreeStmt(hstmt,SQL_CLOSE); mystmt(hstmt,rc); - rc = SQLStatistics(hstmt,NULL,SQL_NTS,NULL,SQL_NTS,"t_bigint",SQL_NTS,SQL_INDEX_ALL,SQL_QUICK); + rc = SQLStatistics(hstmt,NULL,SQL_NTS,NULL,SQL_NTS,(SQLCHAR *)"t_bigint",SQL_NTS,SQL_INDEX_ALL,SQL_QUICK); mycon(hdbc,rc); @@ -359,13 +359,13 @@ rc = SQLFreeStmt(hstmt,SQL_CLOSE); mystmt(hstmt,rc); - rc = SQLExecDirect(hstmt,"insert into t_enumset values('MYSQL_E2','TWO,THREE')",SQL_NTS); + rc = SQLExecDirect(hstmt,(SQLCHAR *)"insert into t_enumset values('MYSQL_E2','TWO,THREE')",SQL_NTS); mystmt(hstmt,rc); rc = SQLFreeStmt(hstmt,SQL_CLOSE); mystmt(hstmt,rc); - rc = SQLPrepare(hstmt,"insert into t_enumset values(?,?)",SQL_NTS); + rc = SQLPrepare(hstmt,(SQLCHAR *)"insert into t_enumset values(?,?)",SQL_NTS); mystmt(hstmt,rc); rc = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT,SQL_C_CHAR,SQL_CHAR,0,0,&szEnum,sizeof(szEnum),NULL); --- myodbc-3.51.15r409.orig/test/mytest3.c.save +++ myodbc-3.51.15r409/test/mytest3.c.save @@ -0,0 +1,6922 @@ +/*************************************************************************** + mytest3.c - description + ------------------- + begin : Wed Aug 8 2001 + copyright : (C) 2003 by Venu, MySQL AB + email : venu@mysql.com + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +#include "mytest3.h" + +/* + Utility function to verify a particular column data +*/ +static void verify_col_data(SQLHSTMT hstmt, const char *table, + const char *col, const char *exp_data) +{ + SQLCHAR data[255], query[255]; + SQLRETURN rc; + + if (table && col) + { + sprintf(query,"SELECT %s FROM %s",col,table); + fprintf(stdout,"\n %s", query); + + rc = SQLExecDirect(hstmt, (char *)query, SQL_NTS); + mystmt(hstmt,rc); + } + + rc = SQLFetch(hstmt); + if (rc == SQL_NO_DATA) + myassert(strcmp(exp_data,"SQL_NO_DATA") ==0 ); + + rc = SQLGetData(hstmt, 1, SQL_C_CHAR, &data, 255, NULL); + if (rc == SQL_ERROR) + { + fprintf(stdout,"\n *** ERROR: FAILED TO GET THE RESULT ***"); + exit(1); + } + fprintf(stdout,"\n obtained: `%s` (expected: `%s`)", data, exp_data); + myassert(strcmp(data,exp_data) == 0); + + SQLFreeStmt(hstmt, SQL_UNBIND); + SQLFreeStmt(hstmt, SQL_CLOSE); +} + +/** + Simple function to do basic ops with MySQL +*/ +static void t_basic(SQLHDBC hdbc,SQLHSTMT hstmt) +{ + SQLRETURN rc; + int nInData = 1; + int nOutData, nRowCount=1; + char szOutData[255]; + + myheader("t_basic"); + + /* CREATE TABLE 'myodbc' */ + SQLExecDirect(hstmt,"drop table tmyodbc ",SQL_NTS); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLExecDirect(hstmt,"create table tmyodbc (col1 int, col2 varchar(30))",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + /* DIRECT INSERT */ + rc = SQLExecDirect(hstmt,"insert into tmyodbc values(10,'direct-insert')",SQL_NTS); + mystmt(hstmt,rc); + + /* PREPARE INSERT */ + rc = SQLPrepare(hstmt,"insert into tmyodbc values(?,'prepare-insert')",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT, SQL_C_LONG,SQL_INTEGER, + 0,0,&nInData,0,NULL); + mystmt(hstmt,rc); + + for (nInData= 100 ; nInData <= 2000; nInData=nInData+50) + { + rc = SQLExecute(hstmt); + mystmt(hstmt,rc); + } + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + /* FREE THE PARAM BUFFERS */ + rc = SQLFreeStmt(hstmt,SQL_RESET_PARAMS); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + /* FETCH RESULT SET */ + rc = SQLExecDirect(hstmt,"SELECT * FROM tmyodbc",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,1, SQL_C_LONG, &nOutData,0,NULL); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,2, SQL_C_CHAR, szOutData,sizeof(szOutData),NULL); + mystmt(hstmt,rc); + + rc = SQLFetch(hstmt); + mystmt(hstmt,rc); + + nInData = 100; + while(SQLFetch(hstmt) == SQL_SUCCESS) + { + nRowCount++; + fprintf(stdout,"\n row %d\t: %d",nRowCount, nOutData); + my_assert( nInData == nOutData); + nInData+= 50; + } + nInData-= 50; + fprintf(stdout,"\n Total rows Found:%d\n",nRowCount); + my_assert( nRowCount == nInData/50); + + /* FREE THE OUTPUT BUFFERS */ + rc = SQLFreeStmt(hstmt,SQL_UNBIND); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); +} + +static void tmysql_setpos_del(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLINTEGER nData = 500; + SQLLEN nlen; + SQLCHAR szData[255]={0}; + SQLUINTEGER pcrow; + SQLUSMALLINT rgfRowStatus; + + myheader("tmysql_setpos_del"); + + tmysql_exec(hstmt,"drop table tmysql_setpos1"); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = tmysql_exec(hstmt,"create table tmysql_setpos1(col1 int, col2 varchar(30))"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into tmysql_setpos1 values(100,'MySQL1')"); + mystmt(hstmt,rc); + rc = tmysql_exec(hstmt,"insert into tmysql_setpos1 values(200,'MySQL2')"); + mystmt(hstmt,rc); + rc = tmysql_exec(hstmt,"insert into tmysql_setpos1 values(300,'MySQL3')"); + mystmt(hstmt,rc); + rc = tmysql_exec(hstmt,"insert into tmysql_setpos1 values(400,'MySQL4')"); + mystmt(hstmt,rc); + rc = tmysql_exec(hstmt,"insert into tmysql_setpos1 values(300,'MySQL5')"); + mystmt(hstmt,rc); + rc = tmysql_exec(hstmt,"insert into tmysql_setpos1 values(300,'MySQL6')"); + mystmt(hstmt,rc); + rc = tmysql_exec(hstmt,"insert into tmysql_setpos1 values(300,'MySQL7')"); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLSetCursorName(hstmt,"venu",SQL_NTS); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select * from tmysql_setpos1"); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,1,SQL_C_LONG,&nData,100,NULL); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,2,SQL_C_CHAR,szData,100,&nlen); + mystmt(hstmt,rc); + + rc = SQLExtendedFetch(hstmt,SQL_FETCH_ABSOLUTE,5,&pcrow,NULL); + mystmt(hstmt,rc); + + fprintf(stdout," pcrow:%d\n",pcrow); + + fprintf(stdout," row1:%d,%s\n",nData,szData); + + rc = SQLSetPos(hstmt,1,SQL_DELETE,SQL_LOCK_NO_CHANGE); + mystmt(hstmt,rc); + + rc = SQLNumResultCols(hstmt,&rgfRowStatus); + mystmt(hstmt,rc); + + rc = SQLRowCount(hstmt,&nlen); + mystmt(hstmt,rc); + + fprintf(stdout," rows affected:%ld\n",nlen); + + rc = SQLFreeStmt(hstmt,SQL_UNBIND); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select * from tmysql_setpos1"); + mystmt(hstmt,rc); + + my_assert( 6 == myresult(hstmt)); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select * from tmysql_setpos1"); + mystmt(hstmt,rc); + + rc = SQLExtendedFetch(hstmt,SQL_FETCH_ABSOLUTE,5,NULL,NULL); + mystmt(hstmt,rc); + + my_assert(300 == my_fetch_int(hstmt,1)); + my_assert(!strcmp((const char *)"MySQL6", + my_fetch_str(hstmt,szData,2))); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); +} +static void tmysql_setpos_del1(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLINTEGER nData = 500; + SQLLEN nlen, pccol; + SQLCHAR szData[255]={0}; + SQLUINTEGER pcrow; + + myheader("tmysql_setpos_del1"); + + tmysql_exec(hstmt,"drop table tmysql_setpos"); + rc = tmysql_exec(hstmt,"create table tmysql_setpos(col1 int, col2 varchar(30))"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into tmysql_setpos values(100,'MySQL1')"); + mystmt(hstmt,rc); + rc = tmysql_exec(hstmt,"insert into tmysql_setpos values(200,'MySQL2')"); + mystmt(hstmt,rc); + rc = tmysql_exec(hstmt,"insert into tmysql_setpos values(300,'MySQL2')"); + mystmt(hstmt,rc); + rc = tmysql_exec(hstmt,"insert into tmysql_setpos values(400,'MySQL2')"); + mystmt(hstmt,rc); + + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLSetCursorName(hstmt,"venu",SQL_NTS); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select * from tmysql_setpos"); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,1,SQL_C_LONG,&nData,100,&pccol); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,2,SQL_C_CHAR,szData,100,&nlen); + mystmt(hstmt,rc); + + rc = SQLExtendedFetch(hstmt,SQL_FETCH_ABSOLUTE,2,&pcrow,NULL); + mystmt(hstmt,rc); + + fprintf(stdout," pcrow:%d\n",pcrow); + + fprintf(stdout," row1:%d,%s\n",nData,szData); + + pccol = SQL_COLUMN_IGNORE; + + rc = SQLSetPos(hstmt,0,SQL_DELETE,SQL_LOCK_NO_CHANGE); + mystmt(hstmt,rc); + + rc = SQLRowCount(hstmt,&nlen); + mystmt(hstmt,rc); + + fprintf(stdout," rows affected:%ld\n",nlen); + myassert(nlen == 1); + + rc = SQLFreeStmt(hstmt,SQL_UNBIND); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select * from tmysql_setpos"); + mystmt(hstmt,rc); + + my_assert(3 == myresult(hstmt)); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); +} +static void t_setpos_del_all(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLINTEGER nData[4]; + SQLLEN nlen; + SQLCHAR szData[4][10]; + + myheader("t_setpos_del_all"); + + tmysql_exec(hstmt,"drop table t_sp_del_all"); + rc = tmysql_exec(hstmt,"create table t_sp_del_all(col1 int not null primary key,\ + col2 varchar(20))"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into t_sp_del_all values(100,'MySQL1')"); + mystmt(hstmt,rc); + rc = tmysql_exec(hstmt,"insert into t_sp_del_all values(200,'MySQL2')"); + mystmt(hstmt,rc); + rc = tmysql_exec(hstmt,"insert into t_sp_del_all values(300,'MySQL3')"); + mystmt(hstmt,rc); + rc = tmysql_exec(hstmt,"insert into t_sp_del_all values(400,'MySQL4')"); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLSetCursorName(hstmt,"venu",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLSetStmtOption(hstmt, SQL_ROWSET_SIZE, 4); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select * from t_sp_del_all order by col1 asc"); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,1,SQL_C_LONG,&nData,100,NULL); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,2,SQL_C_CHAR,&szData[0],sizeof(szData[0]),NULL); + mystmt(hstmt,rc); + + rc = SQLExtendedFetch(hstmt,SQL_FETCH_FIRST,1,NULL,NULL); + mystmt(hstmt,rc); + + fprintf(stdout," row1 : %d, %s\n",nData[0],szData[0]); + fprintf(stdout," row2 : %d, %s\n",nData[1],szData[1]); + fprintf(stdout," row3 : %d, %s\n",nData[2],szData[2]); + fprintf(stdout," row4 : %d, %s\n",nData[3],szData[3]); + + rc = SQLSetPos(hstmt,1,SQL_POSITION,SQL_LOCK_NO_CHANGE); + mystmt(hstmt,rc); + + rc = SQLSetPos(hstmt,0,SQL_DELETE,SQL_LOCK_NO_CHANGE); + mystmt(hstmt,rc); + + rc = SQLRowCount(hstmt,&nlen); + mystmt(hstmt,rc); + + fprintf(stdout," total rows deleted: %ld\n",nlen); + myassert(nlen == 4); + + rc = SQLFreeStmt(hstmt,SQL_UNBIND); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select * from t_sp_del_all"); + mystmt(hstmt,rc); + + my_assert(0 == myresult(hstmt)); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLSetStmtOption(hstmt, SQL_ROWSET_SIZE, 1); + mystmt(hstmt,rc); + +} +static void tmysql_setpos_upd(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLINTEGER nData = 500; + SQLLEN nlen; + SQLCHAR szData[255]={0}; + SQLUINTEGER pcrow; + + myheader("tmysql_setpos_upd"); + + tmysql_exec(hstmt,"drop table tmysql_setpos"); + rc = tmysql_exec(hstmt,"create table tmysql_setpos(col1 int, col2 varchar(30))"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into tmysql_setpos values(100,'MySQL1')"); + mystmt(hstmt,rc); + rc = tmysql_exec(hstmt,"insert into tmysql_setpos values(300,'MySQL3')"); + mystmt(hstmt,rc); + rc = tmysql_exec(hstmt,"insert into tmysql_setpos values(200,'MySQL2')"); + mystmt(hstmt,rc); + rc = tmysql_exec(hstmt,"insert into tmysql_setpos values(300,'MySQL3')"); + mystmt(hstmt,rc); + rc = tmysql_exec(hstmt,"insert into tmysql_setpos values(400,'MySQL4')"); + mystmt(hstmt,rc); + rc = tmysql_exec(hstmt,"insert into tmysql_setpos values(300,'MySQL3')"); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLSetCursorName(hstmt,"venu",SQL_NTS); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select * from tmysql_setpos"); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,1,SQL_C_LONG,&nData,100,NULL); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,2,SQL_C_CHAR,szData,100,NULL); + mystmt(hstmt,rc); + + rc = SQLExtendedFetch(hstmt,SQL_FETCH_ABSOLUTE,3,&pcrow,NULL); + mystmt(hstmt,rc); + + fprintf(stdout," pcrow:%d\n",pcrow); + + fprintf(stdout," row1:%d,%s\n",nData,szData); + + rc = SQLSetPos(hstmt,1,SQL_POSITION,SQL_LOCK_NO_CHANGE); + mystmt(hstmt,rc); + + nData = 1000; + strcpy((char *)szData , "updated"); + + rc = SQLSetPos(hstmt,3,SQL_UPDATE,SQL_LOCK_NO_CHANGE); + mystmt_err(hstmt,rc == SQL_ERROR,rc); + + rc = SQLSetPos(hstmt,1,SQL_UPDATE,SQL_LOCK_NO_CHANGE); + mystmt(hstmt,rc); + + rc = SQLRowCount(hstmt,&nlen); + mystmt(hstmt,rc); + + fprintf(stdout," rows affected:%ld\n",nlen); + my_assert(nlen == 1); + + rc = SQLFreeStmt(hstmt,SQL_UNBIND); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select * from tmysql_setpos"); + mystmt(hstmt,rc); + + myresult(hstmt); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLExecDirect(hstmt,"DELETE FROM tmysql_setpos WHERE col2 = 'updated'",SQL_NTS); + mystmt(hstmt,rc); + + nlen=0; + rc = SQLRowCount(hstmt,&nlen); + mystmt(hstmt,rc); + fprintf(stdout,"\n total rows affected:%ld",nlen); + my_assert(nlen == 1); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = tmysql_exec(hstmt,"select * from tmysql_setpos"); + mystmt(hstmt,rc); + + my_assert(5 == myresult(hstmt)); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); +} + +static void t_setpos_upd_decimal(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLINTEGER rec; + + myheader("t_setpos_upd_decimal"); + + tmysql_exec(hstmt,"drop table t_setpos_upd_decimal"); + rc = tmysql_exec(hstmt,"create table t_setpos_upd_decimal(record decimal(3,0),\ + num1 float, num2 decimal(6,0),num3 decimal(10,3))"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into t_setpos_upd_decimal values(001,12.3,134,0.100)"); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + /* MS SQL Server to work...*/ + SQLSetStmtAttr(hstmt, SQL_ATTR_CONCURRENCY, (SQLPOINTER) SQL_CONCUR_ROWVER, 0); + SQLSetStmtAttr(hstmt, SQL_ATTR_CURSOR_TYPE, (SQLPOINTER) SQL_CURSOR_DYNAMIC, 0); + SQLSetStmtOption(hstmt,SQL_SIMULATE_CURSOR,SQL_SC_NON_UNIQUE); + + rc = tmysql_exec(hstmt,"select record from t_setpos_upd_decimal"); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,1,SQL_C_LONG,&rec,100,NULL); + mystmt(hstmt,rc); + + rc = SQLExtendedFetch(hstmt,SQL_FETCH_NEXT,1,NULL,NULL); + mystmt(hstmt,rc); + fprintf(stdout," row1: %d",rec); + + rc = SQLSetPos(hstmt,1,SQL_POSITION,SQL_LOCK_NO_CHANGE); + mystmt(hstmt,rc); + + rec = 100; + + rc = SQLSetPos(hstmt,1,SQL_UPDATE,SQL_LOCK_NO_CHANGE); + mystmt_r(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_UNBIND); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select * from t_setpos_upd_decimal"); + mystmt(hstmt,rc); + + myresult(hstmt); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); +} +static void tmysql_specialcols(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + + myheader("tmysql_specialcols"); + + tmysql_exec(hstmt,"drop table tmysql_specialcols"); + rc = tmysql_exec(hstmt,"create table tmysql_specialcols(col1 int primary key, col2 varchar(30), col3 int)"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"create index tmysql_ind1 on tmysql_specialcols(col1)"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into tmysql_specialcols values(100,'venu',1)"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into tmysql_specialcols values(200,'MySQL',2)"); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select * from tmysql_specialcols"); + mystmt(hstmt,rc); + + myresult(hstmt); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLSpecialColumns(hstmt, + SQL_BEST_ROWID, + NULL,0, + NULL,0, + "tmysql_specialcols",SQL_NTS, + SQL_SCOPE_SESSION, + SQL_NULLABLE); + mystmt(hstmt,rc); + + myresult(hstmt); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"drop table tmysql_specialcols"); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); +} +static void tmysql_bindcol(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + int nodata; + long nlen, nidata = 200, length; + char szodata[20],szidata[20]="MySQL"; + + myheader("tmysql_bindcol"); + + tmysql_exec(hstmt,"drop table tmysql_bindcol"); + + rc = tmysql_exec(hstmt,"create table tmysql_bindcol(col1 int primary key, col2 varchar(30))"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into tmysql_bindcol values(100,'venu')"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into tmysql_bindcol values(200,'MySQL')"); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = tmysql_prepare(hstmt,"select * from tmysql_bindcol where col2 = ? AND col1 = ?"); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,1,SQL_C_LONG,&nodata,0,&nlen); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,2,SQL_C_CHAR,szodata,200,&nlen); + mystmt(hstmt,rc); + + rc = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT, SQL_C_CHAR,SQL_VARCHAR, + 0,0,szidata,0,&length); + mystmt(hstmt,rc); + + rc = SQLBindParameter(hstmt,2,SQL_PARAM_INPUT, SQL_C_LONG,SQL_INTEGER, + 0,0,&nidata,20,NULL); + mystmt(hstmt,rc); + + length= SQL_NTS; + rc = SQLExecute(hstmt); + mystmt(hstmt,rc); + + rc = SQLFetch(hstmt); + mystmt(hstmt,rc); + + fprintf(stdout," outdata: %d, %s(%ld)\n", nodata,szodata,nlen); + my_assert(nodata == 200); + + rc = SQLFetch(hstmt); + + my_assert(rc == SQL_NO_DATA_FOUND); + + rc = SQLFreeStmt(hstmt,SQL_UNBIND); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_RESET_PARAMS); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"drop table tmysql_bindcol"); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); +} +static void tmysql_pos_delete(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLHSTMT hstmt1; + SQLUINTEGER pcrow; + SQLUSMALLINT rgfRowStatus; + + myheader("tmysql_pos_delete"); + + rc = SQLAllocStmt(hdbc,&hstmt1); + mycon(hdbc,rc); + + tmysql_exec(hstmt,"drop table tmysql_pos_delete"); + rc = tmysql_exec(hstmt,"create table tmysql_pos_delete(col1 int , col2 varchar(30))"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into tmysql_pos_delete values(100,'venu')"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into tmysql_pos_delete values(200,'MySQL')"); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLSetCursorName(hstmt,"venu_cur",8); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select * from tmysql_pos_delete"); + mystmt(hstmt,rc); + + rc = SQLExtendedFetch(hstmt,SQL_FETCH_NEXT,1,&pcrow,NULL); + mystmt(hstmt,rc); + + rc = SQLSetPos(hstmt,1,SQL_POSITION,SQL_LOCK_NO_CHANGE); + mystmt(hstmt,rc); + + rc = SQLExecDirect(hstmt1," DfffELETE FROM tmysql_pos_delete WHERE CURRENT OF venu_cur",SQL_NTS); + mystmt_r(hstmt1,rc); + + rc = SQLExecDirect(hstmt1," DELETE FROM tmysql_pos_delete WHERE CURRENT OF venu_cur curs",SQL_NTS); + mystmt_r(hstmt1,rc); + + rc = SQLExecDirect(hstmt1," DELETE FROM tmysql_pos_delete WHERE ONE CURRENT OF venu_cur",SQL_NTS); + mystmt_r(hstmt1,rc); + + rc = SQLExecDirect(hstmt1," DELETE FROM tmysql_pos_delete WHERE CURRENT OF venu_cur",SQL_NTS); + mystmt(hstmt1,rc); + + SQLNumResultCols(hstmt1,&rgfRowStatus); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + rc = SQLFreeStmt(hstmt1,SQL_CLOSE); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = tmysql_exec(hstmt,"select * from tmysql_pos_delete"); + mystmt(hstmt,rc); + + my_assert(1 == myresult(hstmt)); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt1,SQL_DROP); + mystmt(hstmt1,rc); +} +static void tmysql_pos_update(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLHSTMT hstmt1; + SQLUINTEGER pcrow; + SQLUSMALLINT rgfRowStatus; + + myheader("tmysql_pos_update"); + + rc = SQLAllocStmt(hdbc,&hstmt1); + mycon(hdbc,rc); + + tmysql_exec(hstmt,"drop table tmysql_pos_delete"); + rc = tmysql_exec(hstmt,"create table tmysql_pos_delete(col1 int , col2 varchar(30))"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into tmysql_pos_delete values(100,'venu')"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into tmysql_pos_delete values(200,'MySQL')"); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLSetCursorName(hstmt,"venu_cur",SQL_NTS); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select * from tmysql_pos_delete"); + mystmt(hstmt,rc); + + rc = SQLExtendedFetch(hstmt,SQL_FETCH_ABSOLUTE,2,&pcrow,NULL); + mystmt(hstmt,rc); + + rc = SQLExecDirect(hstmt1," UPerrDATE tmysql_pos_delete SET col1= 999, col2 = 'update' WHERE CURRENT OF venu_cur",SQL_NTS); + mystmt_r(hstmt1,rc); + + rc = SQLExecDirect(hstmt1," UPerrDATE tmysql_pos_delete SET col1= 999, col2 = 'update' WHERE CURRENT OF",SQL_NTS); + mystmt_r(hstmt1,rc); + + rc = SQLExecDirect(hstmt1," UPDATE tmysql_pos_delete SET col1= 999, col2 = 'update' WHERE CURRENT OF venu_cur",SQL_NTS); + mystmt(hstmt1,rc); + + SQLNumResultCols(hstmt1,&rgfRowStatus); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + rc = SQLFreeStmt(hstmt1,SQL_CLOSE); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = tmysql_exec(hstmt,"select * from tmysql_pos_delete"); + mystmt(hstmt,rc); + + rc = SQLFetch(hstmt); + mystmt(hstmt,rc); + + rc = SQLFetch(hstmt); + mystmt(hstmt,rc); + { + SQLCHAR szData[20]; + my_assert(999 == my_fetch_int(hstmt,1)); + my_assert(!strcmp("update",my_fetch_str(hstmt,szData,2))); + } + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt1,SQL_DROP); + mystmt(hstmt1,rc); +} +static void tmysql_mtab_setpos_del(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLINTEGER nData = 500; + SQLLEN nlen; + SQLCHAR szData[255]={0}; + SQLUINTEGER pcrow; + + myheader("tmysql_mtab_setpos_del"); + + tmysql_exec(hstmt,"drop table tmysql_t1"); + tmysql_exec(hstmt,"drop table tmysql_t2"); + rc = tmysql_exec(hstmt,"create table tmysql_t1(col1 int, col2 varchar(20))"); + mystmt(hstmt,rc); + rc = tmysql_exec(hstmt,"create table tmysql_t2(col1 int, col2 varchar(20))"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into tmysql_t1 values(1,'t1_one')"); + mystmt(hstmt,rc); + rc = tmysql_exec(hstmt,"insert into tmysql_t1 values(2,'t1_two')"); + mystmt(hstmt,rc); + rc = tmysql_exec(hstmt,"insert into tmysql_t1 values(3,'t1_three')"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into tmysql_t2 values(2,'t2_one')"); + mystmt(hstmt,rc); + rc = tmysql_exec(hstmt,"insert into tmysql_t2 values(3,'t2_two')"); + mystmt(hstmt,rc); + rc = tmysql_exec(hstmt,"insert into tmysql_t2 values(4,'t2_three')"); + mystmt(hstmt,rc); + + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLSetCursorName(hstmt,"venu",SQL_NTS); + mystmt(hstmt,rc); + + /* FULL JOIN */ + rc = tmysql_exec(hstmt,"select tmysql_t1.*,tmysql_t2.* from tmysql_t1,tmysql_t2"); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,1,SQL_C_LONG,&nData,100,NULL); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,2,SQL_C_CHAR,szData,100,&nlen); + mystmt(hstmt,rc); + + rc = SQLExtendedFetch(hstmt,SQL_FETCH_ABSOLUTE,3,&pcrow,NULL); + mystmt(hstmt,rc); + + fprintf(stdout," pcrow:%d\n",pcrow); + + fprintf(stdout," row1:%d,%s\n",nData,szData); + + rc = SQLSetPos(hstmt,1,SQL_POSITION,SQL_LOCK_NO_CHANGE); + mystmt(hstmt,rc); + + /* not yet supported..*/ + rc = SQLSetPos(hstmt,4,SQL_DELETE,SQL_LOCK_NO_CHANGE); + mystmt_err(hstmt,rc==SQL_ERROR,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); +} +static void tmysql_showkeys(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + + myheader("tmysql_showkeys\n"); + + tmysql_exec(hstmt,"drop table tmysql_spk"); + + rc = tmysql_exec(hstmt,"create table tmysql_spk(col1 int primary key)"); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"SHOW KEYS FROM tmysql_spk"); + mystmt(hstmt,rc); + + my_assert(1 == myresult(hstmt)); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); +} +static void tmysql_setpos_pkdel(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLINTEGER nData = 500; + SQLLEN nlen; + SQLCHAR szData[255]={0}; + SQLUINTEGER pcrow; + + myheader("tmysql_setpos_pkdel"); + + tmysql_exec(hstmt,"drop table tmysql_setpos1"); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = tmysql_exec(hstmt,"create table tmysql_setpos1(col1 int primary key, col2 varchar(30))"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into tmysql_setpos1 values(100,'MySQL1')"); + mystmt(hstmt,rc); + rc = tmysql_exec(hstmt,"insert into tmysql_setpos1 values(200,'MySQL2')"); + mystmt(hstmt,rc); + rc = tmysql_exec(hstmt,"insert into tmysql_setpos1 values(300,'MySQL3')"); + mystmt(hstmt,rc); + rc = tmysql_exec(hstmt,"insert into tmysql_setpos1 values(400,'MySQL4')"); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLSetCursorName(hstmt,"venu",SQL_NTS); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select * from tmysql_setpos1"); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,1,SQL_C_LONG,&nData,100,NULL); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,2,SQL_C_CHAR,szData,100,&nlen); + mystmt(hstmt,rc); + + rc = SQLExtendedFetch(hstmt,SQL_FETCH_NEXT,1,&pcrow,NULL); + mystmt(hstmt,rc); + rc = SQLExtendedFetch(hstmt,SQL_FETCH_NEXT,1,&pcrow,NULL); + mystmt(hstmt,rc); + rc = SQLExtendedFetch(hstmt,SQL_FETCH_NEXT,1,&pcrow,NULL); + mystmt(hstmt,rc); + rc = SQLExtendedFetch(hstmt,SQL_FETCH_NEXT,1,&pcrow,NULL); + mystmt(hstmt,rc); + + fprintf(stdout," pcrow:%d\n",pcrow); + + fprintf(stdout," row1:%d,%s\n",nData,szData); + + rc = SQLSetPos(hstmt,4,SQL_POSITION,SQL_LOCK_NO_CHANGE); + mystmt_err(hstmt,rc==SQL_ERROR,rc); + + rc = SQLSetPos(hstmt,1,SQL_DELETE,SQL_LOCK_NO_CHANGE); + mystmt(hstmt,rc); + + rc = SQLRowCount(hstmt,&nlen); + mystmt(hstmt,rc); + + fprintf(stdout," rows affected:%ld\n",nlen); + + rc = SQLFreeStmt(hstmt,SQL_UNBIND); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select * from tmysql_setpos1"); + mystmt(hstmt,rc); + + my_assert( 3 == myresult(hstmt)); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); +} +static void t_alias_setpos_pkdel(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLINTEGER nData = 500; + SQLLEN nlen; + SQLCHAR szData[255]={0}; + SQLUINTEGER pcrow; + + myheader("t_alias_setpos_pkdel"); + + tmysql_exec(hstmt,"drop table t_alias_setpos_del"); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = tmysql_exec(hstmt,"create table t_alias_setpos_del(col1 int primary key, col2 varchar(30))"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into t_alias_setpos_del values(100,'MySQL1')"); + mystmt(hstmt,rc); + rc = tmysql_exec(hstmt,"insert into t_alias_setpos_del values(200,'MySQL2')"); + mystmt(hstmt,rc); + rc = tmysql_exec(hstmt,"insert into t_alias_setpos_del values(300,'MySQL3')"); + mystmt(hstmt,rc); + rc = tmysql_exec(hstmt,"insert into t_alias_setpos_del values(400,'MySQL4')"); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLSetCursorName(hstmt,"venu",SQL_NTS); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select col1 as id, col2 as name from t_alias_setpos_del"); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,1,SQL_C_LONG,&nData,100,NULL); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,2,SQL_C_CHAR,szData,100,&nlen); + mystmt(hstmt,rc); + + rc = SQLExtendedFetch(hstmt,SQL_FETCH_ABSOLUTE,4,&pcrow,NULL); + mystmt(hstmt,rc); + + fprintf(stdout," pcrow:%d\n",pcrow); + + fprintf(stdout," row1:%d,%s\n",nData,szData); + + rc = SQLSetPos(hstmt,1,SQL_POSITION,SQL_LOCK_NO_CHANGE); + mystmt(hstmt,rc); + + rc = SQLSetPos(hstmt,1,SQL_DELETE,SQL_LOCK_NO_CHANGE); + mystmt(hstmt,rc); + + rc = SQLRowCount(hstmt,&nlen); + mystmt(hstmt,rc); + + fprintf(stdout," rows affected:%ld\n",nlen); + + rc = SQLFreeStmt(hstmt,SQL_UNBIND); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select * from t_alias_setpos_del"); + mystmt(hstmt,rc); + + my_assert( 3 == myresult(hstmt)); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); +} +static void t_alias_setpos_del(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLINTEGER nData[4]; + SQLLEN nlen; + SQLCHAR szData[4][10]; + + myheader("t_alias_setpos_del"); + + tmysql_exec(hstmt,"drop table t_alias_setpos_del"); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = tmysql_exec(hstmt,"create table t_alias_setpos_del(col1 int, col2 varchar(30))"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into t_alias_setpos_del values(100,'MySQL1')"); + mystmt(hstmt,rc); + rc = tmysql_exec(hstmt,"insert into t_alias_setpos_del values(200,'MySQL2')"); + mystmt(hstmt,rc); + rc = tmysql_exec(hstmt,"insert into t_alias_setpos_del values(300,'MySQL3')"); + mystmt(hstmt,rc); + rc = tmysql_exec(hstmt,"insert into t_alias_setpos_del values(400,'MySQL4')"); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLSetStmtOption(hstmt,SQL_ROWSET_SIZE,4); + mystmt(hstmt,rc); + + rc = SQLSetCursorName(hstmt,"venu",SQL_NTS); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select col1 as id, col2 as name from t_alias_setpos_del"); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,1,SQL_C_LONG,&nData,100,NULL); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,2,SQL_C_CHAR,szData,100,&nlen); + mystmt(hstmt,rc); + + rc = SQLExtendedFetch(hstmt,SQL_FETCH_NEXT,1,NULL,NULL); + mystmt(hstmt,rc); + + fprintf(stdout," row1 : %d, %s\n",nData[0],szData[0]); + fprintf(stdout," row2 : %d, %s\n",nData[1],szData[1]); + fprintf(stdout," row3 : %d, %s\n",nData[2],szData[2]); + fprintf(stdout," row4 : %d, %s\n",nData[3],szData[3]); + + rc = SQLSetPos(hstmt,1,SQL_POSITION,SQL_LOCK_NO_CHANGE); + mystmt(hstmt,rc); + + rc = SQLSetPos(hstmt,1,SQL_DELETE,SQL_LOCK_NO_CHANGE); + mystmt(hstmt,rc); + + rc = SQLRowCount(hstmt,&nlen); + mystmt(hstmt,rc); + + fprintf(stdout," rows affected:%ld\n",nlen); + + rc = SQLFreeStmt(hstmt,SQL_UNBIND); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select * from t_alias_setpos_del"); + mystmt(hstmt,rc); + + my_assert( 3 == myresult(hstmt)); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLSetStmtOption(hstmt,SQL_ROWSET_SIZE,1); + mystmt(hstmt,rc); + +} + +static void tmysql_setpos_pkdel1(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLINTEGER nData = 500; + SQLLEN nlen; + SQLCHAR szData[255]={0}; + SQLUINTEGER pcrow; + + myheader("tmysql_setpos_pkdel1"); + + tmysql_exec(hstmt,"drop table tmysql_setpos1"); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = tmysql_exec(hstmt,"create table tmysql_setpos1(col1 int primary key, col3 int,col2 varchar(30))"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into tmysql_setpos1 values(100,10,'MySQL1')"); + mystmt(hstmt,rc); + rc = tmysql_exec(hstmt,"insert into tmysql_setpos1 values(200,20,'MySQL2')"); + mystmt(hstmt,rc); + rc = tmysql_exec(hstmt,"insert into tmysql_setpos1 values(300,20,'MySQL3')"); + mystmt(hstmt,rc); + rc = tmysql_exec(hstmt,"insert into tmysql_setpos1 values(400,20,'MySQL4')"); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLSetCursorName(hstmt,"venu",SQL_NTS); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select col2,col3 from tmysql_setpos1"); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,1,SQL_C_LONG,&nData,100,NULL); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,2,SQL_C_CHAR,szData,100,&nlen); + mystmt(hstmt,rc); + + rc = SQLExtendedFetch(hstmt,SQL_FETCH_ABSOLUTE,4,&pcrow,NULL); + mystmt(hstmt,rc); + + fprintf(stdout," pcrow:%d\n",pcrow); + + fprintf(stdout," row1:%d,%s\n",nData,szData); + + rc = SQLSetPos(hstmt,1,SQL_POSITION,SQL_LOCK_NO_CHANGE); + mystmt(hstmt,rc); + + rc = SQLSetPos(hstmt,1,SQL_DELETE,SQL_LOCK_NO_CHANGE); + mystmt(hstmt,rc); + + rc = SQLRowCount(hstmt,&nlen); + mystmt(hstmt,rc); + + fprintf(stdout," rows affected:%ld\n",nlen); + + rc = SQLFreeStmt(hstmt,SQL_UNBIND); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select * from tmysql_setpos1"); + mystmt(hstmt,rc); + + my_assert( 3 == myresult(hstmt)); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); +} +static void tmysql_setpos_pkdel2(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLINTEGER nData = 500; + SQLLEN nlen; + SQLCHAR szData[255]={0}; + SQLUINTEGER pcrow; + + myheader("tmysql_setpos_pkdel2"); + + tmysql_exec(hstmt,"drop table tmysql_setpos1"); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = tmysql_exec(hstmt,"create table tmysql_setpos1(col1 int, col3 int,col2 varchar(30) primary key)"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into tmysql_setpos1 values(100,10,'MySQL1')"); + mystmt(hstmt,rc); + rc = tmysql_exec(hstmt,"insert into tmysql_setpos1 values(200,20,'MySQL2')"); + mystmt(hstmt,rc); + rc = tmysql_exec(hstmt,"insert into tmysql_setpos1 values(300,20,'MySQL3')"); + mystmt(hstmt,rc); + rc = tmysql_exec(hstmt,"insert into tmysql_setpos1 values(400,20,'MySQL4')"); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLSetCursorName(hstmt,"venu",SQL_NTS); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select col2,col3 from tmysql_setpos1"); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,1,SQL_C_LONG,&nData,100,NULL); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,2,SQL_C_CHAR,szData,100,&nlen); + mystmt(hstmt,rc); + + rc = SQLExtendedFetch(hstmt,SQL_FETCH_NEXT,1,&pcrow,NULL); + mystmt(hstmt,rc); + rc = SQLExtendedFetch(hstmt,SQL_FETCH_NEXT,1,&pcrow,NULL); + mystmt(hstmt,rc); + rc = SQLExtendedFetch(hstmt,SQL_FETCH_NEXT,1,&pcrow,NULL); + mystmt(hstmt,rc); + rc = SQLExtendedFetch(hstmt,SQL_FETCH_NEXT,1,&pcrow,NULL); + mystmt(hstmt,rc); + + fprintf(stdout," pcrow:%d\n",pcrow,NULL); + + fprintf(stdout," row1:%d,%s\n",nData,szData); + + rc = SQLSetPos(hstmt,1,SQL_POSITION,SQL_LOCK_NO_CHANGE); + mystmt(hstmt,rc); + + rc = SQLSetPos(hstmt,1,SQL_DELETE,SQL_LOCK_NO_CHANGE); + mystmt(hstmt,rc); + + rc = SQLRowCount(hstmt,&nlen); + mystmt(hstmt,rc); + + fprintf(stdout," rows affected:%ld\n",nlen); + + rc = SQLFreeStmt(hstmt,SQL_UNBIND); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select * from tmysql_setpos1"); + mystmt(hstmt,rc); + + my_assert( 3 == myresult(hstmt)); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); +} +static void t_refresh(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + + myheader("t_refresh"); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLSetConnectOption(hdbc,SQL_AUTOCOMMIT,SQL_AUTOCOMMIT_OFF); + mycon(hdbc,rc); + + tmysql_exec(hstmt,"drop table if exists t_refresh"); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = tmysql_exec(hstmt,"create table t_refresh(col1 int ,col2 varchar(30)) TYPE = InnoDB"); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = tmysql_exec(hstmt,"insert into t_refresh values(10,'venu')"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into t_refresh values(20,'mysql')"); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select * from t_refresh"); + mystmt(hstmt,rc); + + my_assert( 2 == myresult(hstmt)); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLSetConnectOption(hdbc,SQL_AUTOCOMMIT,SQL_AUTOCOMMIT_ON); + mycon(hdbc,rc); +} +static void tmysql_setpos_pkdel3(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLINTEGER nData = 500; + SQLLEN nlen; + SQLCHAR szData[255]={0}; + SQLUINTEGER pcrow; + + myheader("tmysql_setpos_pkdel3"); + + tmysql_exec(hstmt,"drop table tmysql_setpos1"); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = tmysql_exec(hstmt,"create table tmysql_setpos1(col1 int, col3 int,col2 varchar(30) primary key)"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into tmysql_setpos1 values(100,10,'MySQL1')"); + mystmt(hstmt,rc); + rc = tmysql_exec(hstmt,"insert into tmysql_setpos1 values(200,20,'MySQL2')"); + mystmt(hstmt,rc); + rc = tmysql_exec(hstmt,"insert into tmysql_setpos1 values(300,20,'MySQL3')"); + mystmt(hstmt,rc); + rc = tmysql_exec(hstmt,"insert into tmysql_setpos1 values(400,20,'MySQL4')"); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLSetCursorName(hstmt,"venu",SQL_NTS); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select col1 from tmysql_setpos1"); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,1,SQL_C_LONG,&nData,100,NULL); + mystmt(hstmt,rc); + + rc = SQLExtendedFetch(hstmt,SQL_FETCH_ABSOLUTE,4,&pcrow,NULL); + mystmt(hstmt,rc); + + fprintf(stdout," pcrow:%d\n",pcrow); + + fprintf(stdout," row1:%d,%s\n",nData,szData); + + rc = SQLSetPos(hstmt,1,SQL_DELETE,SQL_LOCK_NO_CHANGE); + mystmt(hstmt,rc); + + rc = SQLRowCount(hstmt,&nlen); + mystmt(hstmt,rc); + + fprintf(stdout," rows affected:%ld\n",nlen); + + rc = SQLFreeStmt(hstmt,SQL_UNBIND); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select * from tmysql_setpos1"); + mystmt(hstmt,rc); + + my_assert( 3 == myresult(hstmt)); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); +} +static void t_mul_pkdel(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLINTEGER nData = 500; + SQLLEN nlen; + SQLCHAR szData[255]={0}; + SQLUINTEGER pcrow; + + myheader("t_mul_pkdel"); + + tmysql_exec(hstmt,"drop table t_mul_pkdel"); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = tmysql_exec(hstmt,"create table t_mul_pkdel(col1 int NOT NULL,col3 int,col2 varchar(30) NOT NULL,primary key(col1,col2))"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into t_mul_pkdel values(100,10,'MySQL1')"); + mystmt(hstmt,rc); + rc = tmysql_exec(hstmt,"insert into t_mul_pkdel values(200,20,'MySQL2')"); + mystmt(hstmt,rc); + rc = tmysql_exec(hstmt,"insert into t_mul_pkdel values(300,20,'MySQL3')"); + mystmt(hstmt,rc); + rc = tmysql_exec(hstmt,"insert into t_mul_pkdel values(400,20,'MySQL4')"); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLSetCursorName(hstmt,"venu",SQL_NTS); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select col1,col2 from t_mul_pkdel"); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,1,SQL_C_LONG,&nData,100,NULL); + mystmt(hstmt,rc); + + rc = SQLExtendedFetch(hstmt,SQL_FETCH_NEXT,1,&pcrow,NULL); + mystmt(hstmt,rc); + + fprintf(stdout," pcrow:%d\n",pcrow); + + fprintf(stdout," row1:%d,%s\n",nData,szData); + + rc = SQLSetPos(hstmt,1,SQL_POSITION,SQL_LOCK_NO_CHANGE); + mystmt(hstmt,rc); + + rc = SQLSetPos(hstmt,1,SQL_DELETE,SQL_LOCK_UNLOCK); + mystmt_err(hstmt,rc==SQL_ERROR,rc); + + rc = SQLSetPos(hstmt,1,SQL_DELETE,SQL_LOCK_NO_CHANGE); + mystmt(hstmt,rc); + + rc = SQLRowCount(hstmt,&nlen); + mystmt(hstmt,rc); + + fprintf(stdout," rows affected:%ld\n",nlen); + + rc = SQLFreeStmt(hstmt,SQL_UNBIND); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select * from t_mul_pkdel"); + mystmt(hstmt,rc); + + my_assert( 3 == myresult(hstmt)); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); +} +static void t_mul_pkdel1(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLINTEGER nData = 500; + SQLLEN nlen; + SQLCHAR szData[255]={0}; + SQLUINTEGER pcrow; + + myheader("t_mul_pkdel1"); + + tmysql_exec(hstmt,"drop table t_mul_pkdel"); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = tmysql_exec(hstmt,"create table t_mul_pkdel(col1 int NOT NULL,col3 int,col2 varchar(30) NOT NULL,primary key(col1,col2))"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into t_mul_pkdel values(100,10,'MySQL1')"); + mystmt(hstmt,rc); + rc = tmysql_exec(hstmt,"insert into t_mul_pkdel values(200,20,'MySQL2')"); + mystmt(hstmt,rc); + rc = tmysql_exec(hstmt,"insert into t_mul_pkdel values(300,20,'MySQL3')"); + mystmt(hstmt,rc); + rc = tmysql_exec(hstmt,"insert into t_mul_pkdel values(400,20,'MySQL4')"); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLSetCursorName(hstmt,"venu",SQL_NTS); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select col1 from t_mul_pkdel"); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,1,SQL_C_LONG,&nData,100,NULL); + mystmt(hstmt,rc); + + rc = SQLExtendedFetch(hstmt,SQL_FETCH_ABSOLUTE,4,&pcrow,NULL); + mystmt(hstmt,rc); + + fprintf(stdout," pcrow:%d\n",pcrow); + + fprintf(stdout," row1:%d,%s\n",nData,szData); + + rc = SQLSetPos(hstmt,4,SQL_DELETE,SQL_LOCK_NO_CHANGE); + mystmt_err(hstmt,rc==SQL_ERROR,rc); + + rc = SQLSetPos(hstmt,1,SQL_DELETE,SQL_LOCK_NO_CHANGE); + mystmt(hstmt,rc); + + rc = SQLRowCount(hstmt,&nlen); + mystmt(hstmt,rc); + + fprintf(stdout," rows affected:%ld\n",nlen); + + rc = SQLFreeStmt(hstmt,SQL_UNBIND); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select * from t_mul_pkdel"); + mystmt(hstmt,rc); + + my_assert( 3 == myresult(hstmt)); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); +} +static void t_max_select(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLCHAR szData[255]; + SQLINTEGER i; + + myheader("t_max_select"); + + tmysql_exec(hstmt,"drop table t_max_select"); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = tmysql_exec(hstmt,"create table t_max_select(col1 int ,col2 varchar(30))"); + mystmt(hstmt,rc); + + rc = SQLPrepare(hstmt,"insert into t_max_select values(?,?)",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT,SQL_C_LONG, + SQL_INTEGER,0,0,&i,0,NULL); + mystmt(hstmt,rc); + + rc = SQLBindParameter(hstmt,2,SQL_PARAM_INPUT,SQL_C_CHAR, + SQL_CHAR,0,0,szData,sizeof(szData),NULL); + mystmt(hstmt,rc); + + fprintf(stdout," inserting 1000 rows, it will take some time\n"); + for(i = 1; i <= 1000; i++) + { + fprintf(stdout," \r %d", i); + sprintf((char *)szData,"MySQL%d",i); + rc = SQLExecute(hstmt); + mystmt(hstmt,rc); + } + fprintf(stdout,"\n"); + + rc = SQLFreeStmt(hstmt,SQL_RESET_PARAMS); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = tmysql_exec(hstmt,"select * from t_max_select"); + mystmt(hstmt,rc); + + my_assert( 1000 == myrowcount(hstmt)); + + rc = SQLFreeStmt(hstmt,SQL_UNBIND); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); +} +static void t_tran(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + + myheader("t_tran"); + + if (!server_supports_trans(hdbc)) + return; + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLSetConnectOption(hdbc,SQL_AUTOCOMMIT,SQL_AUTOCOMMIT_OFF); + mycon(hdbc,rc); + + tmysql_exec(hstmt,"drop table if exists t_tran"); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = tmysql_exec(hstmt,"create table t_tran(col1 int ,col2 varchar(30)) TYPE = InnoDB"); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = tmysql_exec(hstmt,"insert into t_tran values(10,'venu')"); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = tmysql_exec(hstmt,"insert into t_tran values(20,'mysql')"); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_ROLLBACK); + mycon(hdbc,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select * from t_tran"); + mystmt(hstmt,rc); + + my_assert( 1 == myresult(hstmt)); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLSetConnectOption(hdbc,SQL_AUTOCOMMIT,SQL_AUTOCOMMIT_ON); + mycon(hdbc,rc); +} +static void t_max_con(SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLINTEGER i, max_connections, used_connections, test_connections; + SQLHENV env; + SQLHDBC dbc[101]; + + myheader("t_max_con"); + + /* Get max_connections */ + rc = SQLExecDirect(hstmt, "SHOW VARIABLES like 'max_connections'",SQL_NTS); + mystmt(hstmt, rc); + + rc = SQLFetch(hstmt); + mystmt(hstmt, rc); + + rc = SQLGetData(hstmt, 2, SQL_C_LONG, &max_connections, 0, NULL); + mystmt(hstmt,rc); + + rc = SQLFetch(hstmt); + myassert(rc == SQL_NO_DATA_FOUND); + + SQLFreeStmt(hstmt, SQL_UNBIND); + SQLFreeStmt(hstmt, SQL_CLOSE); + fprintf(stdout,"\n total max connections supported: %d", max_connections); + + /* get number of connections used */ + rc = SQLExecDirect(hstmt, "SHOW STATUS like 'threads_connected'",SQL_NTS); + mystmt(hstmt, rc); + + rc = SQLFetch(hstmt); + mystmt(hstmt, rc); + + rc = SQLGetData(hstmt, 2, SQL_C_LONG, &used_connections, 0, NULL); + mystmt(hstmt,rc); + + rc = SQLFetch(hstmt); + myassert(rc == SQL_NO_DATA_FOUND); + + SQLFreeStmt(hstmt, SQL_UNBIND); + SQLFreeStmt(hstmt, SQL_CLOSE); + + fprintf(stdout,"\n total connections used : %d", used_connections); + + test_connections= max_connections-used_connections; + fprintf(stdout,"\n total connections to be tested : %d", test_connections); + + if (test_connections >= 100) + { + fprintf(stdout,"\n test can't be performed due to max_connections are very high"); + return; + } + + rc = SQLAllocEnv(&env); + myenv(env,rc); + + rc = SQLSetEnvAttr(env,SQL_ATTR_ODBC_VERSION,(SQLPOINTER)SQL_OV_ODBC3,0); + myenv(env,rc); + + fprintf(stdout,"\n"); + + for (i=0; i <= test_connections; i++) + { + rc = SQLAllocConnect(env, &dbc[i]); + myenv(env,rc); + + fprintf(stdout," %d", i); + rc = SQLConnect(dbc[i], mydsn, SQL_NTS, myuid, SQL_NTS, mypwd, SQL_NTS); + mycon(dbc[i],rc); + } + rc = SQLAllocConnect(env, &dbc[i]); + myenv(env,rc); + + fprintf(stdout,"\n establishing '%d'th connection, it should fail",i); + rc = SQLConnect(dbc[i], mydsn, SQL_NTS, myuid, SQL_NTS, mypwd, SQL_NTS); + myerror(rc, SQL_HANDLE_DBC, dbc[i]); + if (rc != SQL_ERROR) + fprintf(stderr,"\n test failed"); + + rc = SQLFreeHandle(SQL_HANDLE_DBC,dbc[i]); + mycon(dbc[i],rc); + + fprintf(stdout,"\n freeing all connections\n"); + for (i=0; i<= test_connections; i++) + { + fprintf(stdout," %d", i); + + SQLDisconnect(dbc[i]); + SQLFreeHandle(SQL_HANDLE_DBC,dbc[i]); + } + SQLFreeHandle(SQL_HANDLE_ENV,env); + SQLFreeStmt(hstmt, SQL_UNBIND); + SQLFreeStmt(hstmt, SQL_CLOSE); +} + +static void t_tstotime(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQL_TIMESTAMP_STRUCT ts; + SQLCHAR szData[50]; + + ts.day = 02; + ts.month = 8; + ts.year = 2001; + ts.hour = 18; + ts.minute = 20; + ts.second = 45; + ts.fraction = 05; + + myheader("t_tstotime"); + + tmysql_exec(hstmt,"drop table t_tstotime"); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = tmysql_exec(hstmt,"create table t_tstotime(col1 date ,col2 time, col3 timestamp(14))"); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + /* TIMESTAMP TO DATE, TIME and TS CONVERSION */ + rc = SQLPrepare(hstmt,"insert into t_tstotime(col1,col2,col3) values(?,?,?)",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT,SQL_C_TIMESTAMP, + SQL_DATE,0,0,&ts,sizeof(ts),NULL); + mystmt(hstmt,rc); + + rc = SQLBindParameter(hstmt,2,SQL_PARAM_INPUT,SQL_C_TIMESTAMP, + SQL_TIME,0,0,&ts,sizeof(ts),NULL); + mystmt(hstmt,rc); + + rc = SQLBindParameter(hstmt,3,SQL_PARAM_INPUT,SQL_C_TIMESTAMP, + SQL_TIMESTAMP,0,0,&ts,sizeof(ts),NULL); + mystmt(hstmt,rc); + + rc = SQLExecute(hstmt); + mystmt(hstmt,rc); + + ts.day++; + ts.month++; + ts.year++; + ts.hour++; + ts.minute++; + ts.second++; + ts.fraction++; + + rc = SQLExecute(hstmt); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_RESET_PARAMS); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = tmysql_exec(hstmt,"select * from t_tstotime"); + mystmt(hstmt,rc); + + my_assert( 2 == myresult(hstmt)); + + rc = SQLFreeStmt(hstmt,SQL_UNBIND); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select * from t_tstotime"); + mystmt(hstmt,rc); + + rc = SQLFetch(hstmt); + mystmt(hstmt,rc); + + fprintf(stdout,"\n"); + + my_assert(!strcmp("2001-08-02",my_fetch_str(hstmt,(SQLCHAR *)szData,1))); + my_assert(!strcmp("18:20:45",my_fetch_str(hstmt,(SQLCHAR *)szData,2))); + my_assert(!strcmp("2001-08-02 18:20:45",my_fetch_str(hstmt,(SQLCHAR *)szData,3))); + + rc = SQLFetch(hstmt); + mystmt(hstmt,rc); + + fprintf(stdout,"\n"); + + my_assert(!strcmp("2002-09-03",my_fetch_str(hstmt,(SQLCHAR *)szData,1))); + my_assert(!strcmp("19:21:46",my_fetch_str(hstmt,(SQLCHAR *)szData,2))); + my_assert(!strcmp("2002-09-03 19:21:46",my_fetch_str(hstmt,(SQLCHAR *)szData,3))); + + rc = SQLFreeStmt(hstmt,SQL_UNBIND); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); +} +static void t_tstotime1(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLCHAR ts[40] = "2001-08-02 18:20:45.05", szData[50]; + + myheader("t_tstotime1"); + + tmysql_exec(hstmt,"drop table t_tstotime1"); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = tmysql_exec(hstmt,"create table t_tstotime1(col1 date ,col2 time, col3 timestamp(14))"); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + /* TIMESTAMP TO DATE, TIME and TS CONVERSION */ + rc = SQLPrepare(hstmt,"insert into t_tstotime1 values(?,?,?)",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT,SQL_C_CHAR, + SQL_DATE,0,0,&ts,sizeof(ts),NULL); + mystmt(hstmt,rc); + rc = SQLBindParameter(hstmt,2,SQL_PARAM_INPUT,SQL_C_CHAR, + SQL_TIME,0,0,&ts,sizeof(ts),NULL); + mystmt(hstmt,rc); + rc = SQLBindParameter(hstmt,3,SQL_PARAM_INPUT,SQL_C_CHAR, + SQL_TIMESTAMP,0,0,&ts,sizeof(ts),NULL); + mystmt(hstmt,rc); + + rc = SQLExecute(hstmt); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_RESET_PARAMS); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = tmysql_exec(hstmt,"select * from t_tstotime1"); + mystmt(hstmt,rc); + + my_assert( 1 == myresult(hstmt)); + + rc = SQLFreeStmt(hstmt,SQL_UNBIND); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_RESET_PARAMS); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select * from t_tstotime1"); + mystmt(hstmt,rc); + + rc = SQLFetch(hstmt); + mystmt(hstmt,rc); + + fprintf(stdout,"\n"); + + my_assert(!strcmp("2001-08-02",my_fetch_str(hstmt,(SQLCHAR *)szData,1))); + my_assert(!strcmp("2001-08-02 18:20:45",my_fetch_str(hstmt,(SQLCHAR *)szData,3))); + + rc = SQLFreeStmt(hstmt,SQL_UNBIND); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); +} + +static void t_enumset(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLCHAR szEnum[40]="MYSQL_E1"; + SQLCHAR szSet[40]="THREE,ONE,TWO"; + + myheader("t_enumset"); + + tmysql_exec(hstmt,"drop table t_enumset"); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = tmysql_exec(hstmt,"create table t_enumset(col1 enum('MYSQL_E1','MYSQL_E2'),col2 set('ONE','TWO','THREE'))"); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLExecDirect(hstmt,"insert into t_enumset values('MYSQL_E2','TWO,THREE')",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLPrepare(hstmt,"insert into t_enumset values(?,?)",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT,SQL_C_CHAR,SQL_CHAR,0,0,&szEnum,sizeof(szEnum),NULL); + mystmt(hstmt,rc); + + rc = SQLBindParameter(hstmt,2,SQL_PARAM_INPUT,SQL_C_CHAR,SQL_CHAR,0,0,&szSet,sizeof(szSet),NULL); + mystmt(hstmt,rc); + + rc = SQLExecute(hstmt); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_RESET_PARAMS); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = tmysql_exec(hstmt,"select * from t_enumset"); + mystmt(hstmt,rc); + + my_assert( 2 == myresult(hstmt)); + + rc = SQLFreeStmt(hstmt,SQL_UNBIND); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); +} + +static void t_bigint(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLCHAR id[20]="999"; + SQLLEN nlen; + + myheader("t_bingint"); + + tmysql_exec(hstmt,"drop table t_bingint"); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = tmysql_exec(hstmt,"create table t_bingint(id int(20) NOT NULL auto_increment,name varchar(20) default 'venu', primary key(id))"); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + /* TIMESTAMP TO DATE, TIME and TS CONVERSION */ + rc = tmysql_prepare(hstmt,"insert into t_bingint values(?,'venuxyz')"); + mystmt(hstmt,rc); + + nlen = 4; + rc = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT,SQL_C_LONG, + SQL_BIGINT,20,0,&id,0,&nlen); + mystmt(hstmt,rc); + + rc = SQLExecute(hstmt); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_RESET_PARAMS); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into t_bingint values(10,'mysql1')"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into t_bingint values(20,'mysql2')"); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLSpecialColumns(hstmt,SQL_ROWVER,NULL,SQL_NTS,NULL,SQL_NTS, + "t_bingint",SQL_NTS,SQL_SCOPE_TRANSACTION,SQL_NULLABLE); + + mycon(hdbc,rc); + + my_assert( 0 == myresult(hstmt)); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLColumns(hstmt,NULL,SQL_NTS,NULL,SQL_NTS,"t_bingint",SQL_NTS,NULL,SQL_NTS); + + mycon(hdbc,rc); + + my_assert( 2 == myresult(hstmt)); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLStatistics(hstmt,NULL,SQL_NTS,NULL,SQL_NTS,"t_bingint",SQL_NTS,SQL_INDEX_ALL,SQL_QUICK); + + mycon(hdbc,rc); + + my_assert( 1 == myresult(hstmt)); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLGetTypeInfo(hstmt,SQL_BIGINT); + mycon(hdbc,rc); + + my_assert( 4 == myresult(hstmt)); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLGetTypeInfo(hstmt,SQL_BIGINT); + mycon(hdbc,rc); + + my_assert( 4 == myresult(hstmt)); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select * from t_bingint"); + mystmt(hstmt,rc); + + rc = SQLFetch(hstmt); + mystmt(hstmt,rc); + + rc = SQLGetData(hstmt,1,SQL_C_DEFAULT,&id,10,&nlen); + mystmt(hstmt,rc); + + fprintf(stdout,"\n id:%s,nlen:%ld,%ld\n",id,nlen,sizeof(SQL_BIGINT)); + + rc = SQLFreeStmt(hstmt,SQL_UNBIND); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); +} +static void t_odbc3_envattr() +{ + SQLRETURN rc; + SQLHENV henv; + SQLHDBC hdbc; + SQLPOINTER ov_version; + + myheader("t_odbc3_envattr"); + + rc = SQLAllocEnv(&henv); + myenv(henv,rc); + + rc = SQLSetEnvAttr(henv,SQL_ATTR_OUTPUT_NTS,(SQLPOINTER)SQL_FALSE,0); + myenv_err(henv,rc == SQL_ERROR,rc); + + rc = SQLSetEnvAttr(henv,SQL_ATTR_OUTPUT_NTS,(SQLPOINTER)SQL_TRUE,0); + myenv(henv,rc); + + rc = SQLAllocConnect(henv,&hdbc); + myenv(henv,rc); + + rc = SQLSetEnvAttr(henv,SQL_ATTR_ODBC_VERSION,(SQLPOINTER)SQL_OV_ODBC3,0); + myenv_err(henv,rc == SQL_ERROR,rc); + + rc = SQLGetEnvAttr(henv,SQL_ATTR_ODBC_VERSION,&ov_version,0,0); + myenv(henv,rc); + fprintf(stdout,"\n default odbc version:%d",ov_version); + my_assert(ov_version == (SQLPOINTER)SQL_OV_ODBC2); + + rc = SQLFreeConnect(hdbc); + mycon(hdbc,rc); + + rc = SQLSetEnvAttr(henv,SQL_ATTR_ODBC_VERSION,(SQLPOINTER)SQL_OV_ODBC3,0); + myenv(henv,rc); + + rc = SQLGetEnvAttr(henv,SQL_ATTR_ODBC_VERSION,&ov_version,0,0); + myenv(henv,rc); + fprintf(stdout,"\n new odbc version:%d",ov_version); + my_assert(ov_version == (SQLPOINTER)SQL_OV_ODBC3); + + rc = SQLFreeEnv(henv); + myenv(henv,rc); + + rc = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv); + myenv(henv,rc); + + rc = SQLSetEnvAttr(henv,SQL_ATTR_ODBC_VERSION,(SQLPOINTER)SQL_OV_ODBC3,0); + myenv(henv,rc); + + rc = SQLAllocConnect(henv,&hdbc); + myenv(henv,rc); + + rc = SQLSetEnvAttr(henv,SQL_ATTR_ODBC_VERSION,(SQLPOINTER)SQL_OV_ODBC3,0); + myenv_err(henv,rc == SQL_ERROR,rc); + + rc = SQLGetEnvAttr(henv,SQL_ATTR_ODBC_VERSION,&ov_version,0,0); + myenv(henv,rc); + fprintf(stdout,"\n default odbc version:%d",ov_version); + my_assert(ov_version == (SQLPOINTER)SQL_OV_ODBC3); + + rc = SQLFreeHandle(SQL_HANDLE_DBC, hdbc); + mycon(hdbc,rc); + + rc = SQLFreeHandle(SQL_HANDLE_ENV, henv); + myenv(henv,rc); +} +static void t_odbc3_handle() +{ + SQLRETURN rc; + SQLHENV henv; + SQLHDBC hdbc; + SQLHSTMT hstmt; + SQLPOINTER ov_version; + + myheader("t_odbc3_handle"); + + rc = SQLAllocHandle(SQL_HANDLE_ENV,SQL_NULL_HANDLE,&henv); + myenv(henv,rc); + +#if 0 + rc = SQLAllocHandle(SQL_HANDLE_DBC,henv,&hdbc); + myenv_err(henv,rc == SQL_ERROR,rc); + + rc = SQLGetEnvAttr(henv,SQL_ATTR_ODBC_VERSION,&ov_version,0,0); + myenv(henv,rc); + fprintf(stdout,"\n default odbc version:%d",ov_version); + my_assert(ov_version == (SQLPOINTER)SQL_OV_ODBC2); +#endif + + rc = SQLSetEnvAttr(henv,SQL_ATTR_ODBC_VERSION,(SQLPOINTER)SQL_OV_ODBC3,0); + myenv(henv,rc); + + rc = SQLAllocHandle(SQL_HANDLE_DBC,henv,&hdbc); + myenv(henv,rc); + + rc = SQLSetEnvAttr(henv,SQL_ATTR_ODBC_VERSION,(SQLPOINTER)SQL_OV_ODBC3,0); + myenv_err(henv,rc == SQL_ERROR,rc); + + rc = SQLGetEnvAttr(henv,SQL_ATTR_ODBC_VERSION,&ov_version,0,0); + myenv(henv,rc); + fprintf(stdout,"\n default odbc version:%d",ov_version); + my_assert(ov_version == (SQLPOINTER)SQL_OV_ODBC3); + + rc = SQLConnect(hdbc, mydsn, SQL_NTS, myuid, SQL_NTS, mypwd, SQL_NTS); + mycon(hdbc,rc); + + rc = SQLAllocHandle(SQL_HANDLE_STMT,hdbc,&hstmt); + mycon(hdbc, rc); + + rc = SQLDisconnect(hdbc); + mycon(hdbc, rc); + + rc = SQLFreeHandle(SQL_HANDLE_DBC,hdbc); + mycon(hdbc,rc); + + rc = SQLFreeHandle(SQL_HANDLE_ENV,henv); + myenv(henv,rc); +} +static void t_getcursor(SQLHDBC hdbc) +{ + SQLRETURN rc; + SQLHSTMT hstmt1,hstmt2,hstmt3; + SQLCHAR curname[50]; + SQLSMALLINT nlen; + + myheader("t_getcursor"); + + rc = SQLAllocHandle(SQL_HANDLE_STMT,hdbc,&hstmt1); + mycon(hdbc, rc); + rc = SQLAllocHandle(SQL_HANDLE_STMT,hdbc,&hstmt2); + mycon(hdbc, rc); + rc = SQLAllocHandle(SQL_HANDLE_STMT,hdbc,&hstmt3); + mycon(hdbc, rc); + + rc = SQLGetCursorName(hstmt1,curname,50,&nlen); + if (rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO) + { + fprintf(stdout,"\n default cursor name : %s(%d)",curname,nlen); + myassert(nlen == 8); + myassert(!strcmp(curname,"SQL_CUR0")); + + rc = SQLGetCursorName(hstmt3,curname,50,&nlen); + mystmt(hstmt1,rc); + fprintf(stdout,"\n default cursor name : %s(%d)",curname,nlen); + + rc = SQLGetCursorName(hstmt1,curname,4,&nlen); + mystmt_err(hstmt1,rc == SQL_SUCCESS_WITH_INFO, rc); + fprintf(stdout,"\n truncated cursor name: %s(%d)",curname,nlen); + myassert(nlen == 8); + myassert(!strcmp(curname,"SQL")); + + rc = SQLGetCursorName(hstmt1,curname,0,&nlen); + mystmt_err(hstmt1,rc == SQL_SUCCESS_WITH_INFO, rc); + fprintf(stdout,"\n untouched cursor name: %s(%d)",curname,nlen); + myassert(nlen == 8); + + rc = SQLGetCursorName(hstmt1,curname,8,&nlen); + mystmt_err(hstmt1,rc == SQL_SUCCESS_WITH_INFO, rc); + fprintf(stdout,"\n truncated cursor name: %s(%d)",curname,nlen); + myassert(nlen == 8); + myassert(!strcmp(curname,"SQL_CUR")); + + rc = SQLGetCursorName(hstmt1,curname,9,&nlen); + mystmt(hstmt1,rc); + fprintf(stdout,"\n full cursor name : %s(%d)",curname,nlen); + myassert(nlen == 8); + myassert(!strcmp(curname,"SQL_CUR0")); + } + + rc = SQLSetCursorName(hstmt1,"venucur123",7); + mystmt(hstmt1,rc); + + rc = SQLGetCursorName(hstmt1,curname,8,&nlen); + mystmt(hstmt1,rc); + fprintf(stdout,"\n full setcursor name : %s(%d)",curname,nlen); + myassert(nlen == 7); + myassert(!strcmp(curname,"venucur")); + + rc = SQLFreeHandle(SQL_HANDLE_STMT,hstmt1); + mystmt(hstmt1,rc); +} +static void t_getcursor1(SQLHDBC hdbc) +{ + SQLRETURN rc; + SQLHSTMT hstmt1; + SQLCHAR curname[50]; + SQLSMALLINT nlen,index;; + + myheader("t_getcursor1"); + + for(index=0; index < 100; index++) + { + rc = SQLAllocHandle(SQL_HANDLE_STMT,hdbc,&hstmt1); + mycon(hdbc, rc); + + rc = SQLGetCursorName(hstmt1,curname,50,&nlen); + if (rc != SQL_SUCCESS) + break; + fprintf(stdout,"\n %s(%d) ",curname,nlen); + + rc = SQLFreeHandle(SQL_HANDLE_STMT,hstmt1); + mystmt(hstmt1,rc); + } +} +static void t_gettypeinfo(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLSMALLINT pccol; + + myheader("t_gettypeinfo"); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLGetTypeInfo(hstmt,SQL_ALL_TYPES); + mystmt(hstmt,rc); + + rc = SQLNumResultCols(hstmt,&pccol); + mystmt(hstmt,rc); + fprintf(stdout,"\n total columns: %d",pccol); + myassert(pccol == 19); + myresult(hstmt); + + rc = SQLFreeStmt(hstmt,SQL_RESET_PARAMS); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); +} +static void t_getinfo(SQLHDBC hdbc) +{ + SQLRETURN rc; + SQLCHAR rgbValue[100]; + SQLSMALLINT pcbInfo; + + myheader("t_getinfo"); + + rc = SQLGetInfo(hdbc,SQL_DRIVER_ODBC_VER,rgbValue,100,&pcbInfo); + mycon(hdbc,rc); + fprintf(stdout,"\n SQL_DRIVER_ODBC_VER: %s(%d)",rgbValue,pcbInfo); +} +static void t_stmt_attr_status(SQLHDBC hdbc,SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLUSMALLINT rowStatusPtr[3]; + SQLUINTEGER rowsFetchedPtr; + + myheader("t_stmt_attr_status"); + + tmysql_exec(hstmt,"drop table t_stmtstatus"); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = tmysql_exec(hstmt,"create table t_stmtstatus(id int, name char(20))"); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = tmysql_exec(hstmt,"insert into t_stmtstatus values(10,'data1')"); + mystmt(hstmt,rc); + rc = tmysql_exec(hstmt,"insert into t_stmtstatus values(20,'data2')"); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLSetStmtAttr(hstmt,SQL_ATTR_CURSOR_SCROLLABLE,(SQLPOINTER)SQL_NONSCROLLABLE,0); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select * from t_stmtstatus"); + mystmt(hstmt,rc); + + rc = SQLSetStmtAttr(hstmt,SQL_ATTR_ROWS_FETCHED_PTR,&rowsFetchedPtr,0); + mystmt(hstmt,rc); + + rc = SQLSetStmtAttr(hstmt,SQL_ATTR_ROW_STATUS_PTR,&rowStatusPtr,0); + mystmt(hstmt,rc); + + rc = SQLFetchScroll(hstmt,SQL_FETCH_ABSOLUTE,2); + mystmt_err(hstmt,rc == SQL_ERROR,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLSetStmtAttr(hstmt,SQL_ATTR_CURSOR_SCROLLABLE,(SQLPOINTER)SQL_SCROLLABLE,0); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select * from t_stmtstatus"); + mystmt(hstmt,rc); + + rc = SQLFetchScroll(hstmt,SQL_FETCH_ABSOLUTE,2); + mystmt(hstmt,rc); + + fprintf(stdout,"\n total rows fetched: %d",rowsFetchedPtr); + fprintf(stdout,"\n row 0 status : %d",rowStatusPtr[0]); + fprintf(stdout,"\n row 1 status : %d",rowStatusPtr[1]); + fprintf(stdout,"\n row 2 status : %d",rowStatusPtr[2]); + myassert(rowsFetchedPtr == 1); + myassert(rowStatusPtr[0] == 0); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLSetStmtAttr(hstmt,SQL_ATTR_ROWS_FETCHED_PTR,(SQLPOINTER)0,0); + mystmt(hstmt,rc); + + rc = SQLSetStmtAttr(hstmt,SQL_ATTR_ROW_STATUS_PTR,(SQLPOINTER)0,0); + mystmt(hstmt,rc); +} +static void t_max_rows(SQLHDBC hdbc,SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLINTEGER i; + + myheader("t_max_rows"); + + tmysql_exec(hstmt,"drop table t_max_rows"); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = tmysql_exec(hstmt,"create table t_max_rows(id int)"); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLPrepare(hstmt,"insert into t_max_rows values(?)",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT,SQL_C_ULONG,SQL_INTEGER,0,0,&i,0,NULL); + mystmt(hstmt,rc); + + for(i=0; i < 10; i++) + { + rc = SQLExecute(hstmt); + mystmt(hstmt,rc); + } + + SQLFreeStmt(hstmt,SQL_RESET_PARAMS); + SQLFreeStmt(hstmt,SQL_CLOSE); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLSetStmtAttr(hstmt,SQL_ATTR_MAX_ROWS,(SQLPOINTER)0,0); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select count(*) from t_max_rows"); + mystmt(hstmt,rc); + myassert( 1 == myresult(hstmt) ); + SQLFreeStmt(hstmt,SQL_CLOSE); + + rc = tmysql_exec(hstmt,"select * from t_max_rows"); + mystmt(hstmt,rc); + myassert( 10 == myresult(hstmt) ); + SQLFreeStmt(hstmt,SQL_CLOSE); + + /* MAX rows through connection attribute */ + rc = SQLSetStmtAttr(hstmt,SQL_ATTR_MAX_ROWS,(SQLPOINTER)5,0); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select * from t_max_rows"); + mystmt(hstmt,rc); + myassert( 5 == myrowcount(hstmt)); + + SQLFreeStmt(hstmt,SQL_CLOSE); + + rc = SQLSetStmtAttr(hstmt,SQL_ATTR_MAX_ROWS,(SQLPOINTER)15,0); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select * from t_max_rows"); + mystmt(hstmt,rc); + myassert( 10 == myrowcount(hstmt)); + + SQLFreeStmt(hstmt,SQL_CLOSE); + + rc = SQLSetStmtAttr(hstmt,SQL_ATTR_MAX_ROWS,(SQLPOINTER)0,0); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select * from t_max_rows"); + mystmt(hstmt,rc); + myassert( 10 == myrowcount(hstmt)); + + SQLFreeStmt(hstmt,SQL_CLOSE); + + SQLFreeStmt(hstmt,SQL_CLOSE); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); +} +static void t_prepare(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + int nodata; + long nlen, nidata = 200; + char szodata[20],szidata[20]="MySQL"; + short pccol; + + myheader("t_prepare"); + + SQLFreeStmt(hstmt,SQL_CLOSE); + + tmysql_exec(hstmt,"drop table t_prepare"); + + rc = tmysql_exec(hstmt,"create table t_prepare(col1 int primary key, col2 varchar(30), col3 set(\"one\", \"two\"))"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into t_prepare values(100,'venu','one')"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into t_prepare values(200,'MySQL','two')"); + mystmt(hstmt,rc); + + rc = SQLPrepare(hstmt,"select * from t_prepare where col2 = ? AND col1 = ?",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLNumResultCols(hstmt,&pccol); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,1,SQL_C_LONG,&nodata,0,&nlen); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,2,SQL_C_CHAR,szodata,200,&nlen); + mystmt(hstmt,rc); + + rc = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT, SQL_C_CHAR,SQL_VARCHAR, + 0,0,szidata,20,&nlen); + mystmt(hstmt,rc); + + rc = SQLBindParameter(hstmt,2,SQL_PARAM_INPUT, SQL_C_LONG,SQL_INTEGER, + 0,0,&nidata,20,NULL); + mystmt(hstmt,rc); + + nlen= strlen(szidata); + rc = SQLExecute(hstmt); + mystmt(hstmt,rc); + + rc = SQLFetch(hstmt); + mystmt(hstmt,rc); + + fprintf(stdout," outdata: %d, %s(%d)\n", nodata,szodata,nlen); + my_assert(nodata == 200); + + rc = SQLFetch(hstmt); + my_assert(rc == SQL_NO_DATA_FOUND); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_UNBIND); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_RESET_PARAMS); + mystmt(hstmt,rc); +} +static void t_prepare1(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + long nidata = 1000; + + myheader("t_prepare1"); + + tmysql_exec(hstmt,"drop table t_prepare1"); + + rc = tmysql_exec(hstmt,"create table t_prepare1(col1 int primary key, col2 varchar(30))"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into t_prepare1 values(100,'venu')"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into t_prepare1 values(200,'MySQL')"); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = tmysql_prepare(hstmt,"insert into t_prepare1(col1) values(?)"); + mystmt(hstmt,rc); + + rc = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT, SQL_C_LONG,SQL_INTEGER, + 0,0,&nidata,0,NULL); + mystmt(hstmt,rc); + + rc = SQLExecute(hstmt); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_RESET_PARAMS); + mystmt(hstmt,rc); + + rc = SQLExecDirect(hstmt,"SELECT * FROM t_prepare1",SQL_NTS); + mystmt(hstmt,rc); + + myassert(3 == myresult(hstmt));/* unless prepare is supported..*/ + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); +} +static void test_diagrec( SQLSMALLINT HandleType,SQLHANDLE Handle, + SQLSMALLINT RecNumber,SQLSMALLINT BufferLength, + SQLRETURN return_value_expected) +{ + SQLRETURN rc; + SQLCHAR sqlstate[6]={0}; + SQLCHAR message[255]={0}; + SQLINTEGER native_err=0; + SQLSMALLINT msglen=0; + + rc = SQLGetDiagRec(HandleType,Handle,RecNumber, + (char *)&sqlstate,&native_err, + (char *)&message,BufferLength,&msglen); + + fprintf(stdout,"\n %d@%s(%d)",rc,message,msglen); + myassert(return_value_expected == rc); +} +static void t_diagrec(SQLHENV henv,SQLHDBC hdbc,SQLHSTMT hstmt) +{ + SQLRETURN rc; + + myheader("t_diagrec"); + + fprintf(stdout," ** SQL_HANDLE_STMT ** \n"); + + rc = SQLExecDirect(hstmt,"DROP TABLE ODBC3_NON_EXISTANTi_TAB",SQL_NTS); + myassert(rc == SQL_ERROR); + + test_diagrec(SQL_HANDLE_STMT,hstmt,2,0,SQL_NO_DATA_FOUND); + test_diagrec(SQL_HANDLE_STMT,hstmt,1,255,SQL_SUCCESS); + test_diagrec(SQL_HANDLE_STMT,hstmt,1,0,SQL_SUCCESS_WITH_INFO); + test_diagrec(SQL_HANDLE_STMT,hstmt,1,10,SQL_SUCCESS_WITH_INFO); + test_diagrec(SQL_HANDLE_STMT,hstmt,1,-1,SQL_ERROR); +#if 0 + fprintf(stdout," ** SQL_HANDLE_ENV **\n"); + + rc = SQLFreeEnv(henv); + myassert(rc == SQL_ERROR); + + test_diagrec(SQL_HANDLE_ENV,henv,2,0,SQL_NO_DATA_FOUND); + test_diagrec(SQL_HANDLE_ENV,henv,1,255,SQL_SUCCESS); + test_diagrec(SQL_HANDLE_ENV,henv,1,0,SQL_SUCCESS_WITH_INFO); + test_diagrec(SQL_HANDLE_ENV,henv,1,10,SQL_SUCCESS_WITH_INFO); + test_diagrec(SQL_HANDLE_ENV,henv,1,-1,SQL_ERROR); + + fprintf(stdout," ** SQL_HANDLE_DBC **\n"); + + rc = SQLFreeConnect(hdbc); + myassert(rc == SQL_ERROR); + + test_diagrec(SQL_HANDLE_DBC,hdbc,2,0,SQL_NO_DATA_FOUND); + test_diagrec(SQL_HANDLE_DBC,hdbc,1,255,SQL_SUCCESS); + test_diagrec(SQL_HANDLE_DBC,hdbc,1,0,SQL_SUCCESS_WITH_INFO); + test_diagrec(SQL_HANDLE_DBC,hdbc,1,10,SQL_SUCCESS_WITH_INFO); + test_diagrec(SQL_HANDLE_DBC,hdbc,1,-1,SQL_ERROR); +#endif +} +#if 0 +static void t_diaglist(SQLHDBC hdbc,SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLCHAR sqlstate[6]={0}; + SQLCHAR message[255]={0}; + SQLINTEGER native_err=0; + SQLSMALLINT msglen=0; + + myheader("t_diaglist"); + + rc = SQLSetPos(hstmt,100,SQL_DELETE,SQL_LOCK_NO_CHANGE); + myassert(rc == SQL_ERROR); + + rc = SQLGetDiagRec(3,hstmt,1, + (char *)&sqlstate,&native_err, + (char *)&message,255,&msglen); + mystmt(hstmt,rc); + fprintf(stdout,"\n %d@%s(%d)",rc,message,msglen); + + rc = SQLExecDirect(hstmt,"SELECT * FROM tupd",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLSetPos(hstmt,3,10,SQL_LOCK_NO_CHANGE); + myassert(rc == SQL_ERROR); + + rc = SQLGetDiagRec(3,hstmt,1, + (char *)&sqlstate,&native_err, + (char *)&message,255,&msglen); + mystmt(hstmt,rc); + fprintf(stdout,"\n %d@%s(%d)",rc,message,msglen); + + SQLFreeStmt(hstmt,SQL_CLOSE); +} +#endif + +static void t_scroll(SQLHDBC hdbc,SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLINTEGER i; + + myheader("t_scroll"); + + tmysql_exec(hstmt,"drop table t_scroll"); + + rc = tmysql_exec(hstmt,"create table t_scroll(col1 int)"); + mystmt(hstmt,rc); + + rc = SQLPrepare(hstmt,"insert into t_scroll values(?)",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT, SQL_C_ULONG, + SQL_INTEGER,0,0,&i,0,NULL); + mystmt(hstmt,rc); + + for( i = 1; i <= 5; i++ ) + { + rc = SQLExecute(hstmt); + mystmt(hstmt,rc); + } + + SQLFreeStmt(hstmt,SQL_RESET_PARAMS); + SQLFreeStmt(hstmt,SQL_CLOSE); + + rc = SQLEndTran(SQL_HANDLE_DBC,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLExecDirect(hstmt,"select * from t_scroll",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,1,SQL_C_LONG,&i,0,NULL); + mystmt(hstmt,rc); + + rc = SQLFetchScroll(hstmt,SQL_FETCH_LAST,0);/* 5 */ + mystmt(hstmt,rc); + my_assert(i == 5); + + rc = SQLFetchScroll(hstmt,SQL_FETCH_PREV,0);/* 4 */ + mystmt(hstmt,rc); + my_assert(i == 4); + + rc = SQLFetchScroll(hstmt,SQL_FETCH_RELATIVE,-3);/* 1 */ + mystmt(hstmt,rc); + my_assert(i == 1); + + rc = SQLFetchScroll(hstmt,SQL_FETCH_RELATIVE,-1);/* 0 */ + mystmt_err(hstmt,rc == SQL_NO_DATA_FOUND, rc); + + rc = SQLFetchScroll(hstmt,SQL_FETCH_PREV,1); /* 0 */ + mystmt_err(hstmt,rc == SQL_NO_DATA_FOUND, rc); + + rc = SQLFetchScroll(hstmt,SQL_FETCH_FIRST,-1);/* 0 */ + mystmt(hstmt,rc); + my_assert(i == 1); + + rc = SQLFetchScroll(hstmt,SQL_FETCH_ABSOLUTE,4);/* 4 */ + mystmt(hstmt,rc); + my_assert(i == 4); + + rc = SQLFetchScroll(hstmt,SQL_FETCH_RELATIVE,2);/* 4 */ + mystmt_err(hstmt,rc == SQL_NO_DATA_FOUND, rc); + + rc = SQLFetchScroll(hstmt,SQL_FETCH_PREV,2);/* last */ + mystmt(hstmt,rc); + my_assert(i == 5); + + rc = SQLFetchScroll(hstmt,SQL_FETCH_NEXT,2);/* last+1 */ + mystmt_err(hstmt,rc == SQL_NO_DATA_FOUND, rc); + + rc = SQLFetchScroll(hstmt,SQL_FETCH_ABSOLUTE,-7);/* 0 */ + mystmt_err(hstmt,rc == SQL_NO_DATA_FOUND, rc); + + rc = SQLFetchScroll(hstmt,SQL_FETCH_FIRST,2);/* 1 */ + mystmt(hstmt,rc); + my_assert(i == 1); + + rc = SQLFetchScroll(hstmt,SQL_FETCH_PREV,2);/* 0 */ + mystmt_err(hstmt,rc == SQL_NO_DATA_FOUND, rc); + + rc = SQLFetchScroll(hstmt,SQL_FETCH_NEXT,0);/* 1*/ + mystmt(hstmt,rc); + my_assert(i == 1); + + rc = SQLFetchScroll(hstmt,SQL_FETCH_PREV,0);/* 0 */ + mystmt_err(hstmt,rc == SQL_NO_DATA_FOUND, rc); + + rc = SQLFetchScroll(hstmt,SQL_FETCH_RELATIVE,-1); /* 0 */ + mystmt_err(hstmt,rc == SQL_NO_DATA_FOUND, rc); + + rc = SQLFetchScroll(hstmt,SQL_FETCH_RELATIVE,1); /* 1 */ + mystmt(hstmt,rc); + my_assert(i == 1); /* MyODBC .39 returns 2 instead of 1 */ + + rc = SQLFetchScroll(hstmt,SQL_FETCH_RELATIVE,-1);/* 0 */ + mystmt_err(hstmt,rc == SQL_NO_DATA_FOUND, rc); + + rc = SQLFetchScroll(hstmt,SQL_FETCH_RELATIVE,1);/* 1 */ + mystmt(hstmt,rc); + my_assert(i == 1); + + rc = SQLFetchScroll(hstmt,SQL_FETCH_RELATIVE,1);/* 2 */ + mystmt(hstmt,rc); + my_assert(i == 2); + + rc = SQLFetchScroll(hstmt,SQL_FETCH_RELATIVE,-2);/* 0 */ + mystmt_err(hstmt,rc == SQL_NO_DATA_FOUND, rc); + + rc = SQLFetchScroll(hstmt,SQL_FETCH_RELATIVE,6);/* last+1 */ + mystmt_err(hstmt,rc == SQL_NO_DATA_FOUND, rc); + + rc = SQLFetchScroll(hstmt,SQL_FETCH_PREV,6);/* last+1 */ + mystmt(hstmt, rc); + my_assert(i == 5); + + SQLFreeStmt(hstmt,SQL_RESET_PARAMS); + SQLFreeStmt(hstmt,SQL_UNBIND); + SQLFreeStmt(hstmt,SQL_CLOSE); +} +static void t_acc_crash(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLINTEGER id; + SQLCHAR name[20], data[30]; + SQL_TIMESTAMP_STRUCT ts; + + myheader("t_acc_crash"); + + tmysql_exec(hstmt,"drop table if exists t_acc_crash"); + rc = tmysql_exec(hstmt,"create table t_acc_crash(id int(11) not null auto_increment,\ + name char(20),\ + ts date,\ + primary key(id))"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into t_acc_crash(id,name) values(1,'venu')"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into t_acc_crash(name) values('monty')"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into t_acc_crash(name) values('mysql')"); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLSetStmtOption(hstmt, SQL_ROWSET_SIZE, 1); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select * from t_acc_crash order by id asc"); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,1,SQL_C_LONG,&id,0,NULL); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,2,SQL_C_CHAR,(SQLCHAR *)&name,20,NULL); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,3,SQL_C_DATE,&ts,30,NULL); + mystmt(hstmt,rc); + + rc = SQLFetchScroll(hstmt,SQL_FETCH_FIRST,1); + mystmt(hstmt,rc); + + id = 9; + strcpy(name,"updated"); + ts.year=2010;ts.month=9;ts.day=25; + + rc = SQLSetPos(hstmt,1,SQL_POSITION,SQL_LOCK_NO_CHANGE); + mystmt(hstmt,rc); + + rc = SQLSetPos(hstmt,1,SQL_UPDATE,SQL_LOCK_NO_CHANGE); + mystmt(hstmt,rc); + + SQLFreeStmt(hstmt,SQL_UNBIND); + SQLFreeStmt(hstmt,SQL_CLOSE); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = tmysql_exec(hstmt,"select * from t_acc_crash order by id desc"); + mystmt(hstmt,rc); + + rc = SQLFetch(hstmt); + mystmt(hstmt,rc); + + my_assert(9 == my_fetch_int(hstmt,1)); + my_assert(!strcmp("updated", my_fetch_str(hstmt,data,2))); + my_assert(!strcmp("2010-09-25", my_fetch_str(hstmt,data,3))); + + rc = SQLFreeStmt(hstmt,SQL_UNBIND); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); +} + +static void tmysql_pcbvalue(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLINTEGER nodata; + SQLLEN nlen, slen,tlen; + SQLCHAR szdata[20],sztdata[100]; + + myheader("tmysql_pcbvalue"); + + tmysql_exec(hstmt,"drop table tmysql_pcbvalue"); + + rc = tmysql_exec(hstmt,"create table tmysql_pcbvalue(col1 int primary key, col2 varchar(10),col3 text)"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into tmysql_pcbvalue values(100,'venu','mysql')"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into tmysql_pcbvalue values(200,'monty','mysql2')"); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + /* MS SQL Server to work...*/ + SQLSetStmtAttr(hstmt, SQL_ATTR_CONCURRENCY, (SQLPOINTER) SQL_CONCUR_ROWVER, 0); + SQLSetStmtAttr(hstmt, SQL_ATTR_CURSOR_TYPE, (SQLPOINTER) SQL_CURSOR_KEYSET_DRIVEN, 0); + + rc = SQLExecDirect(hstmt,"select * from tmysql_pcbvalue",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLSetStmtOption(hstmt,SQL_ROWSET_SIZE,1); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,1,SQL_C_LONG,&nodata,0,&nlen); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,2,SQL_C_CHAR,szdata,20,&slen); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,3,SQL_C_CHAR,sztdata,100,&tlen); + mystmt(hstmt,rc); + + rc = SQLExtendedFetch(hstmt,SQL_FETCH_FIRST,1,0,NULL); + mystmt(hstmt,rc); + fprintf(stdout," row1: %d(%ld), %s(%ld), %s(%ld)\n", nodata,nlen,szdata,slen,sztdata,tlen); + + strcpy(szdata,"updated-one"); + + rc = SQLSetPos(hstmt,1,SQL_UPDATE,SQL_LOCK_NO_CHANGE); + mystmt(hstmt,rc); + + rc = SQLExtendedFetch(hstmt,SQL_FETCH_NEXT,1,0,0); + mystmt(hstmt,rc); + + fprintf(stdout," row2: %d(%ld), %s(%ld),%s(%ld)\n", nodata,nlen,szdata,slen,sztdata,tlen); + + rc = SQLExtendedFetch(hstmt,SQL_FETCH_NEXT,1,0,0); + myassert(rc == SQL_NO_DATA_FOUND); + + rc = SQLFreeStmt(hstmt,SQL_UNBIND); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLExecDirect(hstmt,"select * from tmysql_pcbvalue",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLFetch(hstmt); + mystmt(hstmt,rc); + + rc = SQLGetData(hstmt,2,SQL_C_CHAR,szdata,20,&slen); + mystmt(hstmt,rc); + fprintf(stdout," updated data:%s(%ld)",szdata,slen); + my_assert(slen == 4); + my_assert(strcmp(szdata,"upda")==0); + + rc = SQLFreeStmt(hstmt,SQL_UNBIND); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); +} +static void my_setpos_upd_pk_order(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLINTEGER nData = 500; + SQLLEN nlen; + SQLCHAR szData[255]={0}; + SQLUINTEGER pcrow; + + myheader("my_setpos_upd_pk_order"); + + tmysql_exec(hstmt,"drop table my_setpos_upd_pk_order"); + rc = tmysql_exec(hstmt,"create table my_setpos_upd_pk_order(col1 int not null, col2 varchar(30) NOT NULL, primary key(col2,col1))"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into my_setpos_upd_pk_order values(100,'MySQL1')"); + mystmt(hstmt,rc); + rc = tmysql_exec(hstmt,"insert into my_setpos_upd_pk_order values(200,'MySQL2')"); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLSetCursorName(hstmt,"venu",SQL_NTS); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select * from my_setpos_upd_pk_order"); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,1,SQL_C_LONG,&nData,100,NULL); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,2,SQL_C_CHAR,szData,100,NULL); + mystmt(hstmt,rc); + + rc = SQLExtendedFetch(hstmt,SQL_FETCH_ABSOLUTE,2,&pcrow,NULL); + mystmt(hstmt,rc); + + fprintf(stdout," pcrow:%d\n",pcrow); + + fprintf(stdout," row1:%d,%s\n",nData,szData); + + rc = SQLSetPos(hstmt,1,SQL_POSITION,SQL_LOCK_NO_CHANGE); + mystmt(hstmt,rc); + + nData = 1000; + strcpy((char *)szData , "updated"); + + rc = SQLSetPos(hstmt,1,SQL_UPDATE,SQL_LOCK_NO_CHANGE); + mystmt(hstmt,rc); + + rc = SQLRowCount(hstmt,&nlen); + mystmt(hstmt,rc); + + fprintf(stdout," rows affected:%ld\n",nlen); + + rc = SQLFreeStmt(hstmt,SQL_UNBIND); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select * from my_setpos_upd_pk_order"); + mystmt(hstmt,rc); + + myresult(hstmt); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLExecDirect(hstmt,"DELETE FROM my_setpos_upd_pk_order WHERE col2 = 'updated'",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLRowCount(hstmt,&nlen); + mystmt(hstmt,rc); + fprintf(stdout,"\n total rows affected:%ld",nlen); + my_assert(nlen == 1); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); +} +static void my_setpos_upd_pk_order1(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLINTEGER nData = 500; + SQLCHAR szData[255]={0}; + SQLUINTEGER pcrow; + + myheader("my_setpos_upd_pk_order1"); + + tmysql_exec(hstmt,"drop table my_setpos_upd_pk_order"); + rc = tmysql_exec(hstmt,"create table my_setpos_upd_pk_order(col1 int not null, col2 varchar(30) NOT NULL, col3 int not null, primary key(col2,col1,col3))"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into my_setpos_upd_pk_order values(100,'MySQL1',1)"); + mystmt(hstmt,rc); + rc = tmysql_exec(hstmt,"insert into my_setpos_upd_pk_order values(200,'MySQL2',2)"); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLSetCursorName(hstmt,"venu",SQL_NTS); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select * from my_setpos_upd_pk_order"); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,1,SQL_C_LONG,&nData,100,NULL); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,2,SQL_C_CHAR,szData,100,NULL); + mystmt(hstmt,rc); + + rc = SQLExtendedFetch(hstmt,SQL_FETCH_ABSOLUTE,2,&pcrow,NULL); + mystmt(hstmt,rc); + + fprintf(stdout," pcrow:%d\n",pcrow); + + fprintf(stdout," row1:%d,%s\n",nData,szData); + + rc = SQLSetPos(hstmt,1,SQL_POSITION,SQL_LOCK_NO_CHANGE); + mystmt(hstmt,rc); + + nData = 1000; + strcpy((char *)szData , "updated"); + + rc = SQLSetPos(hstmt,1,SQL_UPDATE,SQL_LOCK_NO_CHANGE); + mystmt_err(hstmt,rc == SQL_ERROR, rc); + + rc = SQLFreeStmt(hstmt,SQL_UNBIND); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); +} +static void tmysql_pos_update_ex(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLHSTMT hstmt1; + SQLUINTEGER pcrow; + SQLUSMALLINT rgfRowStatus; + SQLCHAR cursor[30],sql[100],data[]="updated"; + + myheader("tmysql_pos_update_ex"); + + rc = SQLAllocStmt(hdbc,&hstmt1); + mycon(hdbc,rc); + + tmysql_exec(hstmt,"drop table t_pos_updex"); + rc = tmysql_exec(hstmt,"create table t_pos_updex(col1 int NOT NULL primary key, col2 varchar(30))"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into t_pos_updex values(100,'venu')"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into t_pos_updex values(200,'MySQL')"); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select * from t_pos_updex"); + mystmt(hstmt,rc); + + rc = SQLExtendedFetch(hstmt,SQL_FETCH_ABSOLUTE,2,&pcrow,NULL); + mystmt(hstmt,rc); + + rc = SQLSetPos(hstmt,1,SQL_POSITION,SQL_LOCK_NO_CHANGE); + mystmt(hstmt,rc); + + rc = SQLBindParameter(hstmt1,1,SQL_PARAM_INPUT,SQL_C_CHAR,SQL_CHAR,0,0,data,20,NULL); + mystmt(hstmt1,rc); + + rc = SQLGetCursorName(hstmt,cursor,30,NULL); + mystmt(hstmt,rc); + + sprintf(sql,"UPDATE t_pos_updex SET col1= 999, col2 = ? WHERE CURRENT OF %s",cursor); + + rc = SQLExecDirect(hstmt1,sql,SQL_NTS); + mystmt(hstmt1,rc); + + SQLNumResultCols(hstmt1,&rgfRowStatus); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + rc = SQLFreeStmt(hstmt1,SQL_CLOSE); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = tmysql_exec(hstmt,"select * from t_pos_updex"); + mystmt(hstmt,rc); + + rc = SQLFetch(hstmt); + mystmt(hstmt,rc); + + rc = SQLFetch(hstmt); + mystmt(hstmt,rc); + { + SQLCHAR szData[20]; + my_assert(999 == my_fetch_int(hstmt,1)); + my_assert(!strcmp("updated",my_fetch_str(hstmt,szData,2))); + } + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt1,SQL_DROP); + mystmt(hstmt1,rc); +} + +static void tmysql_pos_update_ex1(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLHSTMT hstmt1; + SQLUINTEGER pcrow; + SQLUSMALLINT rgfRowStatus; + SQLCHAR cursor[30],sql[100],data[]="updated"; + + myheader("tmysql_pos_update_ex1"); + + rc = SQLAllocStmt(hdbc,&hstmt1); + mycon(hdbc,rc); + + tmysql_exec(hstmt,"drop table t_pos_updex"); + rc = tmysql_exec(hstmt,"create table t_pos_updex(col1 int, col2 varchar(30))"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into t_pos_updex values(100,'venu')"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into t_pos_updex values(200,'MySQL')"); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select * from t_pos_updex"); + mystmt(hstmt,rc); + + rc = SQLExtendedFetch(hstmt,SQL_FETCH_ABSOLUTE,2,&pcrow,NULL); + mystmt(hstmt,rc); + + rc = SQLSetPos(hstmt,1,SQL_POSITION,SQL_LOCK_NO_CHANGE); + mystmt(hstmt,rc); + + rc = SQLBindParameter(hstmt1,1,SQL_PARAM_INPUT,SQL_C_CHAR,SQL_CHAR,0,0,data,20,NULL); + mystmt(hstmt1,rc); + + rc = SQLGetCursorName(hstmt,cursor,30,NULL); + mystmt(hstmt,rc); + + sprintf(sql,"UPDATE t_pos_updex SET col1= 999, col2 = ? WHERE CURRENT OF %s",cursor); + + rc = SQLExecDirect(hstmt1,sql,SQL_NTS); + mystmt(hstmt1,rc); + + SQLNumResultCols(hstmt1,&rgfRowStatus); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + rc = SQLFreeStmt(hstmt1,SQL_CLOSE); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = tmysql_exec(hstmt,"select * from t_pos_updex"); + mystmt(hstmt,rc); + + rc = SQLFetch(hstmt); + mystmt(hstmt,rc); + + rc = SQLFetch(hstmt); + mystmt(hstmt,rc); + { + SQLCHAR szData[20]; + my_assert(999 == my_fetch_int(hstmt,1)); + my_assert(!strcmp("updated",my_fetch_str(hstmt,szData,2))); + } + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt1,SQL_DROP); + mystmt(hstmt1,rc); +} + +static void tmysql_pos_update_ex2(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLHSTMT hstmt1; + SQLUINTEGER pcrow; + SQLUSMALLINT rgfRowStatus; + SQLCHAR cursor[30],sql[100],data[]="updated"; + + myheader("tmysql_pos_update_ex2"); + + rc = SQLAllocStmt(hdbc,&hstmt1); + mycon(hdbc,rc); + + tmysql_exec(hstmt,"drop table t_pos_updex"); + rc = tmysql_exec(hstmt,"create table t_pos_updex(col1 int NOT NULL, col2 varchar(30), col3 int NOT NULL,primary key(col1,col3))"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into t_pos_updex values(100,'venu',1)"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into t_pos_updex values(200,'MySQL',2)"); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select col1,col2 from t_pos_updex"); + mystmt(hstmt,rc); + + rc = SQLExtendedFetch(hstmt,SQL_FETCH_ABSOLUTE,2,&pcrow,NULL); + mystmt(hstmt,rc); + + rc = SQLSetPos(hstmt,1,SQL_POSITION,SQL_LOCK_NO_CHANGE); + mystmt(hstmt,rc); + + rc = SQLBindParameter(hstmt1,1,SQL_PARAM_INPUT,SQL_C_CHAR,SQL_CHAR,0,0,data,20,NULL); + mystmt(hstmt1,rc); + + rc = SQLGetCursorName(hstmt,cursor,30,NULL); + mystmt(hstmt,rc); + + sprintf(sql,"UPDATE t_pos_updex SET col1= 999, col2 = ? WHERE CURRENT OF %s",cursor); + + rc = SQLExecDirect(hstmt1,sql,SQL_NTS); + mystmt(hstmt1,rc); + + SQLNumResultCols(hstmt1,&rgfRowStatus); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + rc = SQLFreeStmt(hstmt1,SQL_CLOSE); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = tmysql_exec(hstmt,"select * from t_pos_updex"); + mystmt(hstmt,rc); + + rc = SQLFetch(hstmt); + mystmt(hstmt,rc); + + rc = SQLFetch(hstmt); + mystmt(hstmt,rc); + { + SQLCHAR szData[20]; + my_assert(999 == my_fetch_int(hstmt,1)); + my_assert(!strcmp("updated",my_fetch_str(hstmt,szData,2))); + } + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt1,SQL_DROP); + mystmt(hstmt1,rc); +} + +static void tmysql_pos_update_ex3(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLHSTMT hstmt1; + SQLUINTEGER pcrow; + SQLCHAR cursor[30],sql[100]; + + myheader("tmysql_pos_update_ex3"); + + rc = SQLAllocStmt(hdbc,&hstmt1); + mycon(hdbc,rc); + + tmysql_exec(hstmt,"drop table t_pos_updex"); + rc = tmysql_exec(hstmt,"create table t_pos_updex(col1 int NOT NULL primary key, col2 varchar(30))"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into t_pos_updex values(100,'venu')"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into t_pos_updex values(200,'MySQL')"); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select * from t_pos_updex"); + mystmt(hstmt,rc); + + rc = SQLExtendedFetch(hstmt,SQL_FETCH_ABSOLUTE,2,&pcrow,NULL); + mystmt(hstmt,rc); + + rc = SQLSetPos(hstmt,1,SQL_POSITION,SQL_LOCK_NO_CHANGE); + mystmt(hstmt,rc); + + rc = SQLGetCursorName(hstmt,cursor,30,NULL); + mystmt(hstmt,rc); + + sprintf(sql,"UPDATE t_pos_updex SET col1= 999, col2 = ? WHERE CURRENT OF %s",cursor); + + rc = SQLExecDirect(hstmt1,sql,SQL_NTS); + mystmt_err(hstmt1,rc == SQL_ERROR,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt1,SQL_DROP); + mystmt(hstmt1,rc); +} + + +static void t_msdev_bug(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLCHAR catalog[30]; + SQLINTEGER len; + + myheader("t_msdev_bug"); + + rc = SQLGetConnectOption(hdbc,SQL_CURRENT_QUALIFIER,&catalog); + mycon(hdbc,rc); + fprintf(stdout," SQL_CURRENT_QUALIFIER:%s\n",catalog); + + rc = SQLGetConnectAttr(hdbc,SQL_ATTR_CURRENT_CATALOG,&catalog,30,&len); + mycon(hdbc,rc); + fprintf(stdout," SQL_ATTR_CURRENT_CATRALOG:%s(%d)\n",catalog,len); +} + +static void t_setpos_position(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLINTEGER nData = 500; + SQLLEN nlen; + SQLCHAR szData[255]={0}; + SQLUINTEGER pcrow; + + myheader("t_setpos_position"); + + tmysql_exec(hstmt,"drop table t_setpos_position"); + rc = tmysql_exec(hstmt,"create table t_setpos_position(col1 int, col2 varchar(30))"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into t_setpos_position values(100,'MySQL1')"); + mystmt(hstmt,rc); + rc = tmysql_exec(hstmt,"insert into t_setpos_position values(200,'MySQL2')"); + mystmt(hstmt,rc); + rc = tmysql_exec(hstmt,"insert into t_setpos_position values(300,'MySQL3')"); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLSetCursorName(hstmt,"venu",SQL_NTS); + mystmt(hstmt,rc); + + SQLSetStmtAttr(hstmt, SQL_ATTR_CONCURRENCY, (SQLPOINTER) SQL_CONCUR_ROWVER, 0); + SQLSetStmtAttr(hstmt, SQL_ATTR_CURSOR_TYPE, (SQLPOINTER) SQL_CURSOR_DYNAMIC, 0); + SQLSetStmtOption(hstmt,SQL_SIMULATE_CURSOR,SQL_SC_NON_UNIQUE); + + rc = tmysql_exec(hstmt,"select * from t_setpos_position"); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,1,SQL_C_LONG,&nData,100,NULL); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,2,SQL_C_CHAR,szData,100,NULL); + mystmt(hstmt,rc); + + rc = SQLExtendedFetch(hstmt,SQL_FETCH_NEXT,1,&pcrow,NULL); + mystmt(hstmt,rc); + + rc = SQLExtendedFetch(hstmt,SQL_FETCH_NEXT,1,&pcrow,NULL); + mystmt(hstmt,rc); + + fprintf(stdout," pcrow:%d\n",pcrow); + fprintf(stdout," row1:%d,%s\n",nData,szData); + + rc = SQLSetPos(hstmt,1,SQL_POSITION,SQL_LOCK_NO_CHANGE); + mystmt(hstmt,rc); + + nData = 1000; + strcpy((char *)szData , "updated"); + + rc = SQLSetPos(hstmt,3,SQL_UPDATE,SQL_LOCK_NO_CHANGE); + mystmt_err(hstmt,rc == SQL_ERROR,rc); + + rc = SQLSetPos(hstmt,2,SQL_UPDATE,SQL_LOCK_NO_CHANGE); + mystmt_err(hstmt,rc == SQL_ERROR,rc); + + rc = SQLSetPos(hstmt,1,SQL_UPDATE,SQL_LOCK_NO_CHANGE); + mystmt(hstmt,rc); + + rc = SQLRowCount(hstmt,&nlen); + mystmt(hstmt,rc); + + fprintf(stdout," rows affected:%ld\n",nlen); + + rc = SQLFreeStmt(hstmt,SQL_UNBIND); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select * from t_setpos_position"); + mystmt(hstmt,rc); + + myresult(hstmt); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLExecDirect(hstmt,"DELETE FROM t_setpos_position WHERE col2 = 'updated'",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLRowCount(hstmt,&nlen); + mystmt(hstmt,rc); + fprintf(stdout,"\n total rows affected:%ld",nlen); + my_assert(nlen == 1); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = tmysql_exec(hstmt,"select * from t_setpos_position"); + mystmt(hstmt,rc); + + my_assert(2 == myresult(hstmt)); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); +} + +static void t_error(SQLHDBC hdbc,SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLCHAR state[6], errmsg[300]; + SQLINTEGER native; + SQLSMALLINT pclen; + SQLHENV henvl; + + myheader("t_error"); + + if (!server_is_mysql(hdbc)) + return; + + rc = SQLExecDirect(hstmt,"drop table NON_EXISTANT_TABLE_t_error",SQL_NTS); + myassert(rc == SQL_ERROR); + + rc = SQLGetDiagRec(SQL_HANDLE_STMT, hstmt, 1, (SQLCHAR *)&state, + &native, (SQLCHAR *)&errmsg,255,&pclen); + mystmt(hstmt,rc); + fprintf(stdout,"\n state : %s\n native : %d\n error : %s\n errlen : %d\n", + state, native, errmsg, pclen); + myassert(strcmp(state,"42S02") == 0); + myassert(native == 1051); + + rc = SQLGetDiagRec(SQL_HANDLE_STMT, hstmt, 1, (SQLCHAR *)&state, + &native, (SQLCHAR *)&errmsg,255,&pclen); + mystmt(hstmt,rc); + fprintf(stdout,"\n state : %s\n native : %d\n error : %s\n errlen : %d\n", + state, native, errmsg, pclen); + myassert(strcmp(state,"42S02") == 0); + myassert(native == 1051); + + rc = SQLError(NULL,NULL,hstmt,(SQLCHAR *)&state,&native, + (SQLCHAR *)&errmsg,255,&pclen); + mystmt(hstmt,rc); + fprintf(stdout,"\n state : %s\n native : %d\n error : %s\n errlen : %d\n", + state, native, errmsg, pclen); + myassert(strcmp(state,"42S02") == 0); + myassert(native == 1051); + + rc = SQLError(NULL,NULL,hstmt,(SQLCHAR *)&state,&native, + (SQLCHAR *)&errmsg,255,&pclen); + myassert(rc == SQL_NO_DATA_FOUND); + + SQLFreeStmt(hstmt, SQL_CLOSE); + + /* env and dbc related */ + rc = SQLAllocHandle(SQL_HANDLE_ENV,SQL_NULL_HANDLE,&henvl); + myassert(rc == SQL_SUCCESS); + + rc = SQLSetEnvAttr(henvl, SQL_ATTR_ODBC_VERSION,(SQLPOINTER)SQL_OV_ODBC3,0); + myassert(rc == SQL_SUCCESS); + + rc = SQLSetEnvAttr(henvl,SQL_ATTR_CP_MATCH, (SQLPOINTER)100,0); + myassert(rc == SQL_ERROR); + + rc = SQLGetDiagRec(SQL_HANDLE_ENV, henvl, 1, (SQLCHAR *)&state, + &native, (SQLCHAR *)&errmsg,255,&pclen); + myassert(rc == SQL_SUCCESS); + fprintf(stdout,"\n state : %s\n native : %d\n error : %s\n errlen : %d\n", + state, native, errmsg, pclen); + myassert(strcmp(state,"HY024") == 0 || strcmp(state,"HYC00")==0); + + rc = SQLGetDiagRec(SQL_HANDLE_ENV, henvl, 1, (SQLCHAR *)&state, + &native, (SQLCHAR *)&errmsg,255,&pclen); + myassert(rc == SQL_SUCCESS); + fprintf(stdout,"\n state : %s\n native : %d\n error : %s\n errlen : %d\n", + state, native, errmsg, pclen); + myassert(strcmp(state,"HY024") == 0 || strcmp(state,"HYC00")==0); + + rc = SQLError(henvl,NULL,NULL,(SQLCHAR *)&state,&native, + (SQLCHAR *)&errmsg,255,&pclen); + myassert(rc == SQL_SUCCESS); + fprintf(stdout,"\n state : %s\n native : %d\n error : %s\n errlen : %d\n", + state, native, errmsg, pclen); + myassert(strcmp(state,"HY024") == 0 || strcmp(state,"HYC00")==0); + + rc = SQLError(NULL,NULL,hstmt,(SQLCHAR *)&state,&native, + (SQLCHAR *)&errmsg,255,&pclen); + myassert(rc == SQL_NO_DATA_FOUND); + SQLFreeEnv(henvl); +} + +static void t_pos_column_ignore(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLHSTMT hstmt1; + SQLCHAR szData[]="updated"; + SQLINTEGER nData, pcrow; + SQLLEN pcbValue, nlen; + + myheader("t_pos_column_ignore"); + + rc = SQLAllocStmt(hdbc,&hstmt1); + mycon(hdbc,rc); + + tmysql_exec(hstmt,"drop table t_pos_column_ignore"); + rc = tmysql_exec(hstmt,"create table t_pos_column_ignore(col1 int NOT NULL primary key, col2 varchar(30))"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into t_pos_column_ignore values(10,'venu')"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into t_pos_column_ignore values(100,'MySQL')"); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + SQLSetStmtAttr(hstmt, SQL_ATTR_CONCURRENCY, (SQLPOINTER) SQL_CONCUR_ROWVER, 0); + SQLSetStmtAttr(hstmt, SQL_ATTR_CURSOR_TYPE, (SQLPOINTER) SQL_CURSOR_KEYSET_DRIVEN, 0); + + /* ignore all columns */ + rc = tmysql_exec(hstmt,"select * from t_pos_column_ignore order by col1 asc"); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,1,SQL_C_LONG,&nData,100,&pcbValue); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,2,SQL_C_CHAR,szData,100,&pcbValue); + mystmt(hstmt,rc); + + rc = SQLExtendedFetch(hstmt,SQL_FETCH_NEXT,1,&pcrow,NULL); + mystmt(hstmt,rc); + + rc = SQLSetPos(hstmt,1,SQL_POSITION,SQL_LOCK_NO_CHANGE); + mystmt(hstmt,rc); + + nData = 99; + strcpy((char *)szData , "updated"); + + pcbValue = SQL_COLUMN_IGNORE; + rc = SQLSetPos(hstmt,1,SQL_UPDATE,SQL_LOCK_NO_CHANGE); + mystmt(hstmt,rc); + + rc = SQLRowCount(hstmt,&nlen); + mystmt(hstmt,rc); + + fprintf(stdout," rows affected:%ld\n",nlen); + myassert(nlen == 0); + + rc = SQLFreeStmt(hstmt,SQL_UNBIND); + mystmt(hstmt,rc); + + SQLFreeStmt(hstmt1,SQL_CLOSE); + SQLFreeStmt(hstmt,SQL_CLOSE); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = tmysql_exec(hstmt,"select * from t_pos_column_ignore order by col1 asc"); + mystmt(hstmt,rc); + + rc = SQLFetch(hstmt); + mystmt(hstmt,rc); + { + SQLCHAR szData[20]; + my_assert(10 == my_fetch_int(hstmt,1)); + my_assert(!strcmp("venu",my_fetch_str(hstmt,szData,2))); + } + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + /* ignore only one column */ + + rc = tmysql_exec(hstmt,"select * from t_pos_column_ignore order by col1 asc"); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,1,SQL_C_LONG,&nData,100,NULL); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,2,SQL_C_CHAR,szData,100,&pcbValue); + mystmt(hstmt,rc); + + rc = SQLExtendedFetch(hstmt,SQL_FETCH_NEXT,1,&pcrow,NULL); + mystmt(hstmt,rc); + + rc = SQLSetPos(hstmt,1,SQL_POSITION,SQL_LOCK_NO_CHANGE); + mystmt(hstmt,rc); + + nData = 99; + strcpy((char *)szData , "updated"); + + pcbValue = SQL_COLUMN_IGNORE; + rc = SQLSetPos(hstmt,1,SQL_UPDATE,SQL_LOCK_NO_CHANGE); + mystmt(hstmt,rc); + + rc = SQLRowCount(hstmt,&nlen); + mystmt(hstmt,rc); + + fprintf(stdout," rows affected:%ld\n",nlen); + + rc = SQLFreeStmt(hstmt,SQL_UNBIND); + mystmt(hstmt,rc); + + SQLFreeStmt(hstmt1,SQL_CLOSE); + SQLFreeStmt(hstmt,SQL_CLOSE); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = tmysql_exec(hstmt,"select * from t_pos_column_ignore order by col1 asc"); + mystmt(hstmt,rc); + + rc = SQLFetch(hstmt); + mystmt(hstmt,rc); + { + SQLCHAR szData[20]; + my_assert(99 == my_fetch_int(hstmt,1)); + my_assert(!strcmp("venu",my_fetch_str(hstmt,szData,2))); + } + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt1,SQL_DROP); + mystmt(hstmt1,rc); +} + + +static void t_longlong1(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLINTEGER session_id, ctn; + + myheader("t_longlong1"); + + tmysql_exec(hstmt,"drop table t_longlong"); + rc = tmysql_exec(hstmt,"create table t_longlong (\ + session_id bigint not null,\ + ctn bigint not null)"); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + SQLSetStmtAttr(hstmt, SQL_ATTR_CONCURRENCY, (SQLPOINTER) SQL_CONCUR_ROWVER, 0); + SQLSetStmtAttr(hstmt, SQL_ATTR_CURSOR_TYPE, (SQLPOINTER) SQL_CURSOR_STATIC, 0); + + rc = SQLPrepare(hstmt,"insert into t_longlong values (?,?)",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLBindParameter( hstmt, 1, SQL_PARAM_INPUT, SQL_C_UBIGINT, + SQL_BIGINT, 20, 0, &session_id, 20, NULL ); + + rc = SQLBindParameter( hstmt, 2, SQL_PARAM_INPUT, SQL_C_UBIGINT, + SQL_BIGINT, 20, 0, &ctn, 20, NULL ); + + for (session_id=50; session_id < 100; session_id++) + { + ctn += session_id; + rc = SQLExecute(hstmt); + mystmt(hstmt,rc); + } + + rc = SQLFreeStmt(hstmt,SQL_RESET_PARAMS); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = tmysql_exec(hstmt,"select * from t_longlong"); + mystmt(hstmt,rc); + + my_assert( 50 == myresult(hstmt)); + + rc = SQLFreeStmt(hstmt,SQL_UNBIND); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); +} + + +static void t_time(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQL_TIME_STRUCT tm; + SQLCHAR str[20]; + + myheader("t_time"); + + tmysql_exec(hstmt,"drop table t_time"); + rc = tmysql_exec(hstmt,"create table t_time(tm time, ts timestamp(14))"); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLPrepare(hstmt,"insert into t_time values (?,?)",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLBindParameter( hstmt, 1, SQL_PARAM_INPUT, SQL_C_TIME, + SQL_TIME, 0, 0, &tm, 0, NULL ); + mystmt(hstmt,rc); + + rc = SQLBindParameter( hstmt, 2, SQL_PARAM_INPUT, SQL_C_TIME, + SQL_TIMESTAMP, 0, 0, &tm, 15, NULL ); + mystmt(hstmt,rc); + + tm.hour = 20; + tm.minute = 59; + tm.second = 45; + + rc = SQLExecute(hstmt); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_RESET_PARAMS); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLExecDirect(hstmt,"select tm from t_time",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLFetch(hstmt); + mystmt(hstmt,rc); + + rc = SQLGetData(hstmt,1,SQL_C_CHAR,&str,100,NULL); + mystmt(hstmt,rc); + fprintf(stdout,"\n time:%s",str); + my_assert(strcmp(str,"20:59:45")==0); + + rc = SQLFetch(hstmt); + my_assert(rc == SQL_NO_DATA_FOUND); + + rc = SQLFreeStmt(hstmt,SQL_UNBIND); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); +} + +static void t_numeric(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQL_NUMERIC_STRUCT num; + + myheader("t_numeric"); + + tmysql_exec(hstmt,"drop table t_decimal"); + rc = tmysql_exec(hstmt,"create table t_decimal(d1 decimal(10,6))"); + mystmt(hstmt,rc); + rc = tmysql_exec(hstmt,"insert into t_decimal values(10.2)"); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLPrepare(hstmt,"insert into t_decimal values (?)",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLBindParameter( hstmt, 1, SQL_PARAM_INPUT, SQL_C_NUMERIC, + SQL_DECIMAL, 10, 4, &num, 0, NULL ); + mystmt_r(hstmt,rc); + + SQLFreeStmt(hstmt, SQL_CLOSE); + + rc = SQLPrepare(hstmt,"insert into t_decimal values (?),(?)",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLBindParameter( hstmt, 1, SQL_PARAM_INPUT, SQL_C_LONG, + SQL_DECIMAL, 10, 4, &rc, 0, NULL ); + mystmt(hstmt,rc); + + rc = SQLBindParameter( hstmt, 2, SQL_PARAM_INPUT, SQL_C_NUMERIC, + SQL_DECIMAL, 10, 4, &num, 0, NULL ); + mystmt_r(hstmt,rc); + + SQLFreeStmt(hstmt, SQL_CLOSE); + SQLFreeStmt(hstmt, SQL_RESET_PARAMS); + + rc = SQLBindCol( hstmt, 1, SQL_C_NUMERIC, &num, 0, NULL ); + mystmt_r(hstmt,rc); + + SQLFreeStmt(hstmt, SQL_CLOSE); + SQLFreeStmt(hstmt, SQL_UNBIND); + + rc = SQLExecDirect(hstmt, "select * from t_decimal",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLFetch(hstmt); + mystmt(hstmt,rc); + + rc = SQLGetData( hstmt, 1, SQL_C_NUMERIC, &num, 0, NULL ); + mystmt_r(hstmt,rc); + + SQLFreeStmt(hstmt, SQL_UNBIND); + SQLFreeStmt(hstmt, SQL_RESET_PARAMS); + SQLFreeStmt(hstmt, SQL_CLOSE); +} + +static void t_decimal(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLCHAR str[20],s_data[]="189.4567"; + SQLDOUBLE d_data=189.4567; + SQLINTEGER i_data=189, l_data=-23; + SQLRETURN rc; + + myheader("t_decimal"); + + tmysql_exec(hstmt,"drop table t_decimal"); + rc = tmysql_exec(hstmt,"create table t_decimal(d1 decimal(10,6))"); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLPrepare(hstmt,"insert into t_decimal values (?),(?),(?),(?)",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLBindParameter( hstmt, 1, SQL_PARAM_INPUT, SQL_C_DOUBLE, + SQL_DECIMAL, 10, 4, &d_data, 0, NULL ); + mystmt(hstmt,rc); + + rc = SQLBindParameter( hstmt, 2, SQL_PARAM_INPUT, SQL_C_LONG, + SQL_DECIMAL, 10, 4, &i_data, 0, NULL ); + mystmt(hstmt,rc); + + rc = SQLBindParameter( hstmt, 3, SQL_PARAM_INPUT, SQL_C_CHAR, + SQL_DECIMAL, 10, 4, &s_data, 9, NULL ); + mystmt(hstmt,rc); + + rc = SQLBindParameter( hstmt, 4, SQL_PARAM_INPUT, SQL_C_LONG, + SQL_DECIMAL, 10, 4, &l_data, 0, NULL ); + mystmt(hstmt,rc); + + rc = SQLExecute(hstmt); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_RESET_PARAMS); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLExecDirect(hstmt,"select d1 from t_decimal",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLFetch(hstmt); + mystmt(hstmt,rc); + + rc = SQLGetData(hstmt,1,SQL_C_CHAR,&str,19,NULL); + mystmt(hstmt,rc); + fprintf(stdout,"\n decimal(SQL_C_DOUBLE) : %s",str); + my_assert(strncmp(str,"189.4567",8)==0); + + rc = SQLFetch(hstmt); + mystmt(hstmt,rc); + + rc = SQLGetData(hstmt,1,SQL_C_CHAR,&str,19,NULL); + mystmt(hstmt,rc); + fprintf(stdout,"\n decimal(SQL_C_INTEGER): %s",str); + my_assert(strncmp(str,"189.0000",5)==0); + + rc = SQLFetch(hstmt); + mystmt(hstmt,rc); + + rc = SQLGetData(hstmt,1,SQL_C_CHAR,&str,19,NULL); + mystmt(hstmt,rc); + fprintf(stdout,"\n decimal(SQL_C_CHAR) : %s",str); + my_assert(strncmp(str,"189.4567",8)==0); + + rc = SQLFetch(hstmt); + mystmt(hstmt,rc); + + rc = SQLGetData(hstmt,1,SQL_C_CHAR,&str,19,NULL); + mystmt(hstmt,rc); + fprintf(stdout,"\n decimal(SQL_C_LONG) : %s",str); + my_assert(strncmp(str,"-23.00",6)==0); + + rc = SQLFetch(hstmt); + my_assert(rc == SQL_NO_DATA_FOUND); + + rc = SQLFreeStmt(hstmt,SQL_UNBIND); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); +} + + +static void t_warning(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLCHAR szData[20]; + SQLLEN pcbValue; + + myheader("t_warning"); + + tmysql_exec(hstmt,"drop table t_warning"); + rc = tmysql_exec(hstmt,"create table t_warning(col2 char(20))"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into t_warning values('venu anuganti')"); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + SQLSetStmtAttr(hstmt, SQL_ATTR_CONCURRENCY, (SQLPOINTER) SQL_CONCUR_ROWVER, 0); + SQLSetStmtAttr(hstmt, SQL_ATTR_CURSOR_TYPE, (SQLPOINTER) SQL_CURSOR_KEYSET_DRIVEN, 0); + + /* ignore all columns */ + rc = tmysql_exec(hstmt,"select * from t_warning"); + mystmt(hstmt,rc); + + rc = SQLFetch(hstmt); + mystmt(hstmt, rc); + + rc = SQLGetData(hstmt,1,SQL_C_CHAR,szData,4,&pcbValue); + mystmt_err(hstmt, rc == SQL_SUCCESS_WITH_INFO, rc); + fprintf(stdout,"\n data: %s(%ld)",szData,pcbValue); + + rc = SQLGetData(hstmt,1,SQL_C_CHAR,szData,4,&pcbValue); + mystmt_err(hstmt, rc == SQL_SUCCESS_WITH_INFO, rc); + fprintf(stdout,"\n data: %s(%ld)",szData,pcbValue); + + rc = SQLGetData(hstmt,1,SQL_C_CHAR,szData,4,&pcbValue); + mystmt_err(hstmt, rc == SQL_SUCCESS_WITH_INFO, rc); + fprintf(stdout,"\n data: %s(%ld)",szData,pcbValue); + + rc = SQLGetData(hstmt,1,SQL_C_CHAR,szData,4,&pcbValue); + mystmt(hstmt,rc); + fprintf(stdout,"\n data: %s(%ld)",szData,pcbValue); + + rc = SQLFetch(hstmt); + mystmt_err(hstmt, rc == SQL_NO_DATA_FOUND, rc); + + SQLFreeStmt(hstmt,SQL_UNBIND); + SQLFreeStmt(hstmt,SQL_CLOSE); +} + +static void t_multistep(SQLHDBC hdbc, SQLHSTMT hstmt) +{ +#ifdef DBUG_OFF + SQLRETURN rc; + SQLCHAR szData[150]; + SQLLEN pcbValue; + SQLINTEGER id; + + myheader("t_multistep"); + + tmysql_exec(hstmt,"drop table t_multistep"); + rc = tmysql_exec(hstmt,"create table t_multistep(col1 int,col2 varchar(200))"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into t_multistep values(10,'MySQL - Open Source Database')"); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + SQLSetStmtAttr(hstmt, SQL_ATTR_CONCURRENCY, (SQLPOINTER) SQL_CONCUR_ROWVER, 0); + SQLSetStmtAttr(hstmt, SQL_ATTR_CURSOR_TYPE, (SQLPOINTER) SQL_CURSOR_KEYSET_DRIVEN, 0); + + rc = SQLBindCol(hstmt,1,SQL_C_LONG,&id,0,NULL); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select * from t_multistep"); + mystmt(hstmt,rc); + + rc = SQLFetch(hstmt); + mystmt(hstmt,rc); + fprintf(stdout,"\n id: %ld",id); + myassert(id == 10); + + rc = SQLGetData(hstmt,2,SQL_C_CHAR,szData,0,&pcbValue); + myassert(rc == SQL_SUCCESS_WITH_INFO); + fprintf(stdout,"\n length: %ld", pcbValue); + myassert(pcbValue == 28); + + rc = SQLGetData(hstmt,2,SQL_C_CHAR,szData,0,&pcbValue); + myassert(rc == SQL_SUCCESS_WITH_INFO); + fprintf(stdout,"\n length: %ld", pcbValue); + myassert(pcbValue == 28); + + rc = SQLGetData(hstmt,2,SQL_C_BINARY,szData,0,&pcbValue); + myassert(rc == SQL_SUCCESS_WITH_INFO); + fprintf(stdout,"\n length: %ld", pcbValue); + myassert(pcbValue == 28); + + rc = SQLGetData(hstmt,2,SQL_C_BINARY,szData,0,&pcbValue); + myassert(rc == SQL_SUCCESS_WITH_INFO); + fprintf(stdout,"\n length: %ld", pcbValue); + myassert(pcbValue == 28); + + rc = SQLGetData(hstmt,2,SQL_C_CHAR,szData,0,&pcbValue); + myassert(rc == SQL_SUCCESS_WITH_INFO); + fprintf(stdout,"\n length: %ld", pcbValue); + myassert(pcbValue == 28); + + rc = SQLGetData(hstmt,2,SQL_C_CHAR,szData,10,&pcbValue); + myassert(rc == SQL_SUCCESS_WITH_INFO); + fprintf(stdout,"\n data : %s (%ld)",szData,pcbValue); + myassert(pcbValue == 28); + myassert(strcmp(szData,"MySQL - O") == 0); + + pcbValue= 0; + rc = SQLGetData(hstmt,2,SQL_C_CHAR,szData,5,&pcbValue); + myassert(rc == SQL_SUCCESS_WITH_INFO); + fprintf(stdout,"\n data : %s (%ld)",szData,pcbValue); + myassert(pcbValue == 19); + myassert(strcmp(szData,"pen ") == 0); + + pcbValue= 0; + szData[0]='A'; + rc = SQLGetData(hstmt,2,SQL_C_CHAR,szData,0,&pcbValue); + myassert(rc == SQL_SUCCESS_WITH_INFO); + fprintf(stdout,"\n data : %s (%ld)",szData,pcbValue); + myassert(pcbValue == 15); + myassert(szData[0] == 'A'); + + rc = SQLGetData(hstmt,2,SQL_C_CHAR,szData,pcbValue+1,&pcbValue); + mystmt(hstmt,rc); + fprintf(stdout,"\n data : %s (%ld)",szData,pcbValue); + myassert(pcbValue == 15); + myassert(strcmp(szData,"Source Database") == 0); + + pcbValue= 99; + szData[0]='A'; + rc = SQLGetData(hstmt,2,SQL_C_CHAR,szData,0,&pcbValue); + myassert(rc == SQL_SUCCESS_WITH_INFO); + fprintf(stdout,"\n data : %s (%ld)",szData,pcbValue); + myassert(pcbValue == 0); + myassert(szData[0] == 'A'); + + + rc = SQLFetch(hstmt); + myassert(rc == SQL_NO_DATA_FOUND); + + SQLFreeStmt(hstmt,SQL_UNBIND); + SQLFreeStmt(hstmt,SQL_CLOSE); +#endif +} + +static void t_zerolength(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLCHAR szData[100], bData[100], bData1[100]; + SQLLEN pcbValue,pcbValue1,pcbValue2; + + myheader("t_zerolength"); + + tmysql_exec(hstmt,"drop table t_zerolength"); + rc = tmysql_exec(hstmt,"create table t_zerolength(str varchar(20), bin binary(20), blb blob)"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into t_zerolength values('','','')"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into t_zerolength values('venu','mysql','monty')"); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + SQLSetStmtAttr(hstmt, SQL_ATTR_CONCURRENCY, (SQLPOINTER) SQL_CONCUR_ROWVER, 0); + SQLSetStmtAttr(hstmt, SQL_ATTR_CURSOR_TYPE, (SQLPOINTER) SQL_CURSOR_KEYSET_DRIVEN, 0); + + rc = tmysql_exec(hstmt,"select * from t_zerolength"); + mystmt(hstmt,rc); + + rc = SQLFetch(hstmt); + mystmt(hstmt,rc); + + pcbValue= pcbValue1= 99; + rc = SQLGetData(hstmt,1,SQL_C_CHAR,szData,0,&pcbValue); + mystmt_err(hstmt,rc == SQL_SUCCESS_WITH_INFO,rc); + fprintf(stdout,"\n length: %ld", pcbValue); + myassert(pcbValue == 0); + + bData[0]=bData[1]='z'; + rc = SQLGetData(hstmt,2,SQL_C_BINARY,bData,0,&pcbValue1); + mystmt_err(hstmt,rc == SQL_SUCCESS_WITH_INFO,rc); + fprintf(stdout,"\n length: %ld", pcbValue1); + myassert(pcbValue1 == 0); + myassert(bData[0] == 'z'); + myassert(bData[1] == 'z'); + + bData1[0]=bData1[1]='z'; + rc = SQLGetData(hstmt,3,SQL_C_BINARY,bData1,0,&pcbValue2); + mystmt_err(hstmt,rc == SQL_SUCCESS_WITH_INFO,rc); + fprintf(stdout,"\n length: %ld", pcbValue2); + myassert(pcbValue2 == 0); + myassert(bData1[0] == 'z'); + myassert(bData1[1] == 'z'); + + pcbValue= pcbValue1= 99; + rc = SQLGetData(hstmt,1,SQL_C_CHAR,szData,1,&pcbValue); + mystmt(hstmt,rc); + fprintf(stdout,"\n data: %s, length: %ld", szData, pcbValue); + myassert(pcbValue == 0); + myassert(szData[0] == '\0'); + + bData[0]=bData[1]='z'; + rc = SQLGetData(hstmt,2,SQL_C_BINARY,bData,1,&pcbValue1); + mystmt(hstmt,rc); + fprintf(stdout,"\n data: %s, length: %ld", bData, pcbValue1); + myassert(pcbValue1 == 0); + myassert(bData[0]== '\0'); + + bData1[0]=bData1[1]='z'; + rc = SQLGetData(hstmt,3,SQL_C_CHAR,bData1,1,&pcbValue2); + mystmt(hstmt,rc); + fprintf(stdout,"\n data: %s, length: %ld", bData1, pcbValue2); + myassert(pcbValue2 == 0); + myassert(bData1[0] == '\0'); + myassert(bData1[1] == 'z'); + + rc = SQLFetch(hstmt); + mystmt(hstmt,rc); + + pcbValue= pcbValue1= 99; + szData[0]= bData[0]= 'z'; + rc = SQLGetData(hstmt,1,SQL_C_CHAR,szData,0,&pcbValue); + mystmt_err(hstmt,rc == SQL_SUCCESS_WITH_INFO,rc); + fprintf(stdout,"\n length: %ld", pcbValue); + myassert(pcbValue == 4); + myassert(szData[0] == 'z'); + + rc = SQLGetData(hstmt,2,SQL_C_BINARY,bData,0,&pcbValue1); + mystmt_err(hstmt,rc == SQL_SUCCESS_WITH_INFO,rc); + fprintf(stdout,"\n length: %ld", pcbValue1); + myassert(pcbValue1 == 5); + myassert(bData[0] == 'z'); + + bData[0]=bData1[1]='z'; + rc = SQLGetData(hstmt,3,SQL_C_BINARY,bData1,0,&pcbValue2); + mystmt_err(hstmt,rc == SQL_SUCCESS_WITH_INFO,rc); + fprintf(stdout,"\n length: %ld", pcbValue2); + myassert(pcbValue2 == 5); + + pcbValue= pcbValue1= 99; + szData[0]= szData[1]= bData[0]= bData[1]= 'z'; + rc = SQLGetData(hstmt,1,SQL_C_CHAR,szData,1,&pcbValue); + mystmt_err(hstmt,rc == SQL_SUCCESS_WITH_INFO,rc); + fprintf(stdout,"\n data: %s, length: %ld", szData,pcbValue); + myassert(pcbValue == 4); + myassert(szData[0] == '\0'); + + rc = SQLGetData(hstmt,2,SQL_C_BINARY,bData,1,&pcbValue1); + mystmt_err(hstmt,rc == SQL_SUCCESS_WITH_INFO,rc); + fprintf(stdout,"\n data; %s, length: %ld", bData, pcbValue1); + myassert(pcbValue1 == 5); + myassert(bData[0] == 'm'); + + bData[0]=bData1[1]='z'; + rc = SQLGetData(hstmt,3,SQL_C_BINARY,bData1,1,&pcbValue2); + mystmt_err(hstmt,rc == SQL_SUCCESS_WITH_INFO,rc); + fprintf(stdout,"\n length: %ld", pcbValue2); + myassert(pcbValue2 == 5); + myassert(bData1[0] == 'm'); + myassert(bData1[1] == 'z'); + + pcbValue= pcbValue1= 99; + rc = SQLGetData(hstmt,1,SQL_C_CHAR,szData,4,&pcbValue); + mystmt_err(hstmt,rc == SQL_SUCCESS_WITH_INFO,rc); + fprintf(stdout,"\n data: %s, length: %ld", szData, pcbValue); + myassert(pcbValue == 4); + myassert(strcmp(szData,"ven")==0); + + rc = SQLGetData(hstmt,2,SQL_C_BINARY,bData,4,&pcbValue1); + mystmt_err(hstmt,rc == SQL_SUCCESS_WITH_INFO,rc); + fprintf(stdout,"\n data: %s, length: %ld", bData, pcbValue1); + myassert(pcbValue1 == 5); + myassert(strncmp(bData,"mysq",4)==0); + + pcbValue= pcbValue1= 99; + rc = SQLGetData(hstmt,1,SQL_C_CHAR,szData,5,&pcbValue); + mystmt(hstmt,rc); + fprintf(stdout,"\n data: %s, length: %ld", szData, pcbValue); + myassert(pcbValue == 4); + myassert(strcmp(szData,"venu")==0); + + rc = SQLGetData(hstmt,2,SQL_C_BINARY,bData,5,&pcbValue1); + mystmt(hstmt,rc); + fprintf(stdout,"\n data: %s, length: %ld", bData, pcbValue1); + myassert(pcbValue1 == 5); + myassert(strncmp(bData,"mysql",5)==0); + + szData[0]= 'z'; + rc = SQLGetData(hstmt,3,SQL_C_CHAR,szData,0,&pcbValue); + mystmt_err(hstmt,rc == SQL_SUCCESS_WITH_INFO,rc); + fprintf(stdout,"\n data: %s, length: %ld", szData, pcbValue); + myassert(pcbValue == 5 || pcbValue == 10); + myassert(szData[0] == 'z'); + +#if TO_BE_FIXED_IN_DRIVER + szData[0]=szData[1]='z'; + rc = SQLGetData(hstmt,3,SQL_C_CHAR,szData,1,&pcbValue); + mystmt_err(hstmt,rc == SQL_SUCCESS_WITH_INFO,rc); + fprintf(stdout,"\n data: %s, length: %ld", szData, pcbValue); + myassert(pcbValue == 10); + myassert(szData[0] == 'm'); + myassert(szData[1] == 'z'); + + rc = SQLGetData(hstmt,3,SQL_C_CHAR,szData,4,&pcbValue); + mystmt_err(hstmt,rc == SQL_SUCCESS_WITH_INFO,rc); + fprintf(stdout,"\n data: %s, length: %ld", szData, pcbValue); + myassert(pcbValue == 10); + myassert(strncmp(szData,"mont",4) == 0); + + rc = SQLGetData(hstmt,3,SQL_C_CHAR,szData,5,&pcbValue); + mystmt(hstmt,rc); + fprintf(stdout,"\n data: %s, length: %ld", szData, pcbValue); + myassert(pcbValue == 10); + myassert(strncmp(szData,"monty",5) == 0); +#endif + + rc = SQLFetch(hstmt); + myassert(rc == SQL_NO_DATA_FOUND); + + SQLFreeStmt(hstmt,SQL_UNBIND); + SQLFreeStmt(hstmt,SQL_CLOSE); +} + + +static void t_pos_datetime_delete(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLHSTMT hstmt1; + SQLINTEGER int_data, cur_type; + SQLLEN row_count; + + myheader("t_pos_datetime_delete"); + + rc = SQLAllocStmt(hdbc,&hstmt1); + mycon(hdbc,rc); + + tmysql_exec(hstmt,"drop table t_pos_delete"); + rc = tmysql_exec(hstmt,"create table t_pos_delete(id int not null default '0',\ + name varchar(20) NOT NULL default '',\ + created datetime NOT NULL default '2000-01-01')"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into t_pos_delete values(1,'venu','2003-02-10 14:45:39')"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into t_pos_delete(name) values('')"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into t_pos_delete(id) values(2)"); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select * from t_pos_delete"); + mystmt(hstmt,rc); + + my_assert(3 == myresult(hstmt)); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + SQLSetStmtAttr(hstmt, SQL_ATTR_CONCURRENCY, (SQLPOINTER) SQL_CONCUR_ROWVER, 0); + SQLSetStmtAttr(hstmt, SQL_ATTR_CURSOR_TYPE, (SQLPOINTER) SQL_CURSOR_DYNAMIC, 0); + SQLSetStmtOption(hstmt,SQL_SIMULATE_CURSOR,SQL_SC_TRY_UNIQUE); + + SQLSetStmtAttr(hstmt1, SQL_ATTR_CONCURRENCY, (SQLPOINTER) SQL_CONCUR_ROWVER, 0); + SQLSetStmtAttr(hstmt1, SQL_ATTR_CURSOR_TYPE, (SQLPOINTER) SQL_CURSOR_DYNAMIC, 0); + SQLSetStmtOption(hstmt1,SQL_SIMULATE_CURSOR,SQL_SC_TRY_UNIQUE); + + rc = SQLSetCursorName(hstmt,"venu_cur",8); + mystmt(hstmt,rc); + + rc = SQLGetStmtAttr(hstmt, SQL_ATTR_CURSOR_TYPE, &cur_type, 0, NULL); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select * from t_pos_delete"); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,1,SQL_C_LONG,&int_data,0,NULL); + mystmt(hstmt,rc); + + rc = SQLExtendedFetch(hstmt,SQL_FETCH_NEXT,1,NULL,NULL); + mystmt(hstmt,rc); + fprintf(stdout,"\n current_row: %d", int_data); + myassert(int_data == 1); + + rc = SQLSetPos(hstmt,1,SQL_POSITION,SQL_LOCK_NO_CHANGE); + mystmt(hstmt,rc); + + rc = SQLExecDirect(hstmt1,"DELETE FROM t_pos_delete WHERE CURRENT OF venu_cur",SQL_NTS); + mystmt(hstmt1,rc); + + rc = SQLRowCount(hstmt1,&row_count); + mystmt(hstmt1,rc); + fprintf(stdout, "\n rows affected: %ld", row_count); + myassert(row_count == 1); + + rc = SQLExtendedFetch(hstmt,SQL_FETCH_NEXT,1,NULL,NULL); + mystmt(hstmt,rc); + fprintf(stdout,"\n current_row: %d", int_data); + if (cur_type == SQL_CURSOR_DYNAMIC) + myassert(int_data == 2); + else + myassert(int_data == 0); + + /*rc = SQLExtendedFetch(hstmt,SQL_FETCH_NEXT,1,NULL,NULL); + mystmt(hstmt,rc);*/ + + rc = SQLSetPos(hstmt,1,SQL_POSITION,SQL_LOCK_NO_CHANGE); + mystmt(hstmt,rc); + + rc = SQLExecDirect(hstmt1,"DELETE FROM t_pos_delete WHERE CURRENT OF venu_cur",SQL_NTS); + mystmt(hstmt1,rc); + + rc = SQLRowCount(hstmt1,&row_count); + mystmt(hstmt1,rc); + fprintf(stdout, "\n rows affected: %ld", row_count); + myassert(row_count == 1); + + SQLFreeStmt(hstmt,SQL_UNBIND); + SQLFreeStmt(hstmt,SQL_CLOSE); + SQLFreeStmt(hstmt1,SQL_CLOSE); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = tmysql_exec(hstmt,"select * from t_pos_delete"); + mystmt(hstmt,rc); + + my_assert(1 == myresult(hstmt)); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + if (cur_type == SQL_CURSOR_DYNAMIC) + verify_col_data(hstmt,"t_pos_delete","id","0"); + else + verify_col_data(hstmt,"t_pos_delete","id","2"); + + rc = SQLFreeStmt(hstmt1,SQL_DROP); + mystmt(hstmt1,rc); +} + + +static void t_pos_datetime_delete1(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLHSTMT hstmt1; + SQLLEN row_count; + SQLINTEGER int_data, cur_type; + + myheader("t_pos_datetime_delete1"); + + rc = SQLAllocStmt(hdbc,&hstmt1); + mycon(hdbc,rc); + + tmysql_exec(hstmt,"drop table t_pos_delete"); + rc = tmysql_exec(hstmt,"create table t_pos_delete(id int not null default '0',\ + name varchar(20) NOT NULL default '',\ + created datetime NOT NULL default '2000-01-01')"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into t_pos_delete values(1,'venu','2003-02-10 14:45:39')"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into t_pos_delete(name) values('')"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into t_pos_delete(id) values(2)"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into t_pos_delete(id) values(3)"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into t_pos_delete(id) values(4)"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"insert into t_pos_delete(id) values(5)"); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select * from t_pos_delete"); + mystmt(hstmt,rc); + + my_assert(6 == myresult(hstmt)); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + SQLSetStmtAttr(hstmt, SQL_ATTR_CONCURRENCY, (SQLPOINTER) SQL_CONCUR_ROWVER, 0); + SQLSetStmtAttr(hstmt, SQL_ATTR_CURSOR_TYPE, (SQLPOINTER) SQL_CURSOR_DYNAMIC, 0); + SQLSetStmtOption(hstmt,SQL_SIMULATE_CURSOR,SQL_SC_NON_UNIQUE); + + SQLSetStmtAttr(hstmt1, SQL_ATTR_CONCURRENCY, (SQLPOINTER) SQL_CONCUR_ROWVER, 0); + SQLSetStmtAttr(hstmt1, SQL_ATTR_CURSOR_TYPE, (SQLPOINTER) SQL_CURSOR_DYNAMIC, 0); + SQLSetStmtOption(hstmt1,SQL_SIMULATE_CURSOR,SQL_SC_NON_UNIQUE); + + rc = SQLSetCursorName(hstmt,"venu_cur",8); + mystmt(hstmt,rc); + + rc = SQLGetStmtAttr(hstmt, SQL_ATTR_CURSOR_TYPE, &cur_type, 0, NULL); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select * from t_pos_delete"); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,1,SQL_C_LONG,&int_data,0,NULL); + mystmt(hstmt,rc); + + rc = SQLExtendedFetch(hstmt,SQL_FETCH_ABSOLUTE,3,NULL,NULL); + mystmt(hstmt,rc); + fprintf(stdout,"\n current_row: %d", int_data); + myassert(int_data == 2); + + rc = SQLSetPos(hstmt,1,SQL_POSITION,SQL_LOCK_NO_CHANGE); + mystmt(hstmt,rc); + + rc = SQLExecDirect(hstmt1,"DELETE FROM t_pos_delete WHERE CURRENT OF venu_cur",SQL_NTS); + mystmt(hstmt1,rc); + + rc = SQLRowCount(hstmt1,&row_count); + mystmt(hstmt1,rc); + fprintf(stdout, "\n rows affected: %ld", row_count); + myassert(row_count == 1); + + rc = SQLExtendedFetch(hstmt,SQL_FETCH_NEXT,1,NULL,NULL); + mystmt(hstmt,rc); + fprintf(stdout,"\n current_row: %d", int_data); + + rc = SQLExtendedFetch(hstmt,SQL_FETCH_NEXT,1,NULL,NULL); + mystmt(hstmt,rc); + fprintf(stdout,"\n current_row: %d", int_data); + + /*rc = SQLExtendedFetch(hstmt,SQL_FETCH_NEXT,1,NULL,NULL); + mystmt(hstmt,rc);*/ + + rc = SQLSetPos(hstmt,1,SQL_POSITION,SQL_LOCK_NO_CHANGE); + mystmt(hstmt,rc); + + rc = SQLExecDirect(hstmt1,"DELETE FROM t_pos_delete WHERE CURRENT OF venu_cur",SQL_NTS); + mystmt(hstmt1,rc); + + rc = SQLRowCount(hstmt1,&row_count); + mystmt(hstmt1,rc); + fprintf(stdout, "\n rows affected: %ld", row_count); + myassert(row_count == 1); + + SQLFreeStmt(hstmt,SQL_UNBIND); + SQLFreeStmt(hstmt,SQL_CLOSE); + SQLFreeStmt(hstmt1,SQL_CLOSE); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = tmysql_exec(hstmt,"select * from t_pos_delete"); + mystmt(hstmt,rc); + + my_assert(4 == myresult(hstmt)); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt1,SQL_DROP); + mystmt(hstmt1,rc); +} + +#define TEST_ODBC_TEXT_LEN 3000 +static void t_text_fetch(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLINTEGER i, row_count; + SQLLEN length; + SQLCHAR data[TEST_ODBC_TEXT_LEN+1]; + + myheader("t_text_fetch"); + + SQLExecDirect(hstmt,"drop table t_text_fetch",SQL_NTS); + rc = SQLExecDirect(hstmt,"create table t_text_fetch(t1 tinytext, \ + t2 text, \ + t3 mediumtext, \ + t4 longtext)",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLPrepare(hstmt,"insert into t_text_fetch values(?,?,?,?)",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, + 0,0,(char *)data, TEST_ODBC_TEXT_LEN/3, NULL); + mystmt(hstmt,rc); + + rc = SQLBindParameter(hstmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, + 0,0,(char *)data, TEST_ODBC_TEXT_LEN/2, NULL); + mystmt(hstmt,rc); + + rc = SQLBindParameter(hstmt, 3, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, + 0,0,(char *)data, + (SQLINTEGER)(TEST_ODBC_TEXT_LEN/1.5), NULL); + mystmt(hstmt,rc); + + rc = SQLBindParameter(hstmt, 4, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, + 0,0,(char *)data, TEST_ODBC_TEXT_LEN-1, NULL); + mystmt(hstmt,rc); + + memset(data,'A',TEST_ODBC_TEXT_LEN); + data[TEST_ODBC_TEXT_LEN]='\0'; + + for (i=0; i < 10; i++) + { + rc = SQLExecute(hstmt); + mystmt(hstmt,rc); + } + + SQLFreeStmt(hstmt, SQL_RESET_PARAMS); + SQLFreeStmt(hstmt, SQL_CLOSE); + + rc = SQLExecDirect(hstmt,"SELECT * FROM t_text_fetch",SQL_NTS); + mystmt(hstmt,rc); + + row_count= 0; + rc = SQLFetch(hstmt); + while (rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO) + { + fprintf(stdout,"\n row '%d' (lengths: ", row_count); + rc = SQLGetData(hstmt,1,SQL_C_CHAR,(char *)data,TEST_ODBC_TEXT_LEN,&length); + mystmt(hstmt,rc); + fprintf(stdout,"%ld", length); + myassert(length == 255); + + rc = SQLGetData(hstmt,2,SQL_C_CHAR,(char *)data,TEST_ODBC_TEXT_LEN,&length); + mystmt(hstmt,rc); + fprintf(stdout,",%ld", length); + myassert(length == TEST_ODBC_TEXT_LEN/2); + + rc = SQLGetData(hstmt,3,SQL_C_CHAR,(char *)data,TEST_ODBC_TEXT_LEN,&length); + mystmt(hstmt,rc); + fprintf(stdout,",%ld", length); + myassert(length == (SQLINTEGER)(TEST_ODBC_TEXT_LEN/1.5)); + + rc = SQLGetData(hstmt,4,SQL_C_CHAR,(char *)data,TEST_ODBC_TEXT_LEN,&length); + mystmt(hstmt,rc); + fprintf(stdout,",%ld)", length); + myassert(length == TEST_ODBC_TEXT_LEN-1); + row_count++; + + rc = SQLFetch(hstmt); + } + fprintf(stdout,"\n total rows: %d", row_count); + myassert(row_count == i); + + SQLFreeStmt(hstmt, SQL_UNBIND); + SQLFreeStmt(hstmt, SQL_CLOSE); + + rc = SQLExecDirect(hstmt,"DROP TABLE t_text_fetch",SQL_NTS); + mystmt(hstmt,rc); +} + +/* To test SQLColumns misc case */ +static void t_columns(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLUSMALLINT NumPrecRadix, DataType, Nullable; + SQLULEN cbColumnSize, cbDecimalDigits, cbNumPrecRadix, + cbDataType, cbNullable; + SQLUINTEGER cbDatabaseName; + SQLRETURN rc; + SQLULEN ColumnSize; + SQLUINTEGER ColumnCount= 7, i; + SQLUSMALLINT DecimalDigits; + SQLCHAR ColumnName[MAX_NAME_LEN], DatabaseName[MAX_NAME_LEN]; + SQLUINTEGER Values[7][5][2]= + { + { {5,2}, {6,4}, {0,2}, {10,2}, {1,2}}, + { {12,2}, {5,4}, {0,-1}, {10,-1}, {1,2}}, + { {12,2}, {20,4}, {0,-1}, {10,-1}, {0,2}}, + { {3,2}, {10,4}, {2,2}, {10,2}, {1,2}}, + { {65530,2}, {4,4}, {0,2}, {10,2}, {0,2}}, + { {4,2}, {11,4}, {0,2}, {10,2}, {0,2}}, + { {65530,2}, {4,4}, {0,2}, {10,2}, {1,2}} + }; + + myheader("t_columns"); + + SQLFreeStmt(hstmt, SQL_CLOSE); + SQLExecDirect(hstmt,"DROP TABLE test_column",SQL_NTS); + + rc = SQLExecDirect(hstmt,"CREATE TABLE test_column(col0 smallint, \ + col1 char(5),\ + col2 varchar(20) not null,\ + col3 decimal(10,2),\ + col4 tinyint not null,\ + col5 integer primary key,\ + col6 tinyint not null unique auto_increment)",SQL_NTS); + mystmt(hstmt,rc); + + mystmt(hstmt,rc); + + rc= SQLSetStmtAttr(hstmt, SQL_ATTR_METADATA_ID, + (SQLPOINTER)SQL_FALSE, SQL_IS_UINTEGER); + mystmt(hstmt,rc); + + SQLSetStmtAttr(hstmt, SQL_ATTR_CURSOR_TYPE, (SQLPOINTER) SQL_CURSOR_STATIC, 0); + + rc= SQLGetConnectAttr(hdbc, SQL_ATTR_CURRENT_CATALOG,(SQLCHAR *)DatabaseName, + MAX_NAME_LEN, &cbDatabaseName);/* Current Catalog */ + mycon(hdbc,rc); + + for (i=0; i< ColumnCount; i++) + { + sprintf(ColumnName,"col%d",i); + + rc= SQLColumns(hstmt, + (SQLCHAR *)DatabaseName, (SQLUSMALLINT)cbDatabaseName, + SQL_NULL_HANDLE, 0, + (SQLCHAR *)"test_column", SQL_NTS, + (SQLCHAR *)ColumnName, SQL_NTS); + mystmt(hstmt,rc); + + /* 5 -- Data type */ + rc= SQLBindCol(hstmt, 5, SQL_C_SSHORT, &DataType, 0, &cbDataType); + mystmt(hstmt,rc); + + /* 7 -- Column Size */ + rc= SQLBindCol(hstmt, 7, SQL_C_ULONG, &ColumnSize, 0, &cbColumnSize); + mystmt(hstmt,rc); + + /* 9 -- Decimal Digits */ + rc= SQLBindCol(hstmt, 9, SQL_C_SSHORT, &DecimalDigits, 0, &cbDecimalDigits); + mystmt(hstmt,rc); + + /* 10 -- Num Prec Radix */ + rc= SQLBindCol(hstmt, 10, SQL_C_SSHORT, &NumPrecRadix, 0, &cbNumPrecRadix); + mystmt(hstmt,rc); + + /* 11 -- Nullable */ + rc= SQLBindCol(hstmt, 11, SQL_C_SSHORT, &Nullable, 0, &cbNullable); + mystmt(hstmt,rc); + + rc= SQLFetch(hstmt); + mystmt(hstmt,rc); + + fprintf(stdout,"\n Column %s:", ColumnName); + fprintf(stdout,"\n\t DataType = %d(%ld)", DataType, cbDataType); + fprintf(stdout,"\n\t ColumnSize = %d(%ld)", ColumnSize, cbColumnSize); + fprintf(stdout,"\n\t DecimalDigits= %d(%ld)", DecimalDigits, cbDecimalDigits); + fprintf(stdout,"\n\t NumPrecRadix = %d(%ld)", NumPrecRadix, cbNumPrecRadix); + fprintf(stdout,"\n\t Nullable = %s(%ld)\n", + Nullable == SQL_NO_NULLS ? "NO": "YES", cbNullable); + + myassert(DataType == Values[i][0][0]); + myassert(cbDataType == Values[i][0][1]); + + myassert(ColumnSize == Values[i][1][0]); + myassert(cbColumnSize == Values[i][1][1]); + + myassert(DecimalDigits == Values[i][2][0]); + myassert(cbDecimalDigits == Values[i][2][1]); + + myassert(NumPrecRadix == Values[i][3][0]); + myassert(cbNumPrecRadix == Values[i][3][1]); + + myassert(Nullable == Values[i][4][0]); + myassert(cbNullable == Values[i][4][1]); + + rc= SQLFetch(hstmt); + myassert(rc == SQL_NO_DATA); + + SQLFreeStmt(hstmt,SQL_UNBIND); + SQLFreeStmt(hstmt,SQL_CLOSE); + } + + SQLFreeStmt(hstmt,SQL_UNBIND); + SQLFreeStmt(hstmt,SQL_CLOSE); + + rc = SQLExecDirect(hstmt,"DROP TABLE test_column",SQL_NTS); + mystmt(hstmt,rc); + SQLFreeStmt(hstmt,SQL_CLOSE); +} + + +/* To test a convertion type */ +static void t_convert_type(SQLHENV henv, SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLSMALLINT SqlType, DateType; + SQLCHAR ColName[MAX_NAME_LEN]; + SQLCHAR DbVersion[MAX_NAME_LEN]; + SQLINTEGER OdbcVersion; + + myheader("t_convert_type"); + + SQLFreeStmt(hstmt, SQL_CLOSE); + + rc = SQLGetEnvAttr(henv,SQL_ATTR_ODBC_VERSION,&OdbcVersion,0,NULL); + myenv(henv,rc); + + fprintf(stdout,"\n odbc version:"); + if (OdbcVersion == SQL_OV_ODBC2) + { + fprintf(stdout," SQL_OV_ODBC2"); + DateType= SQL_DATE; + } + else + { + fprintf(stdout," SQL_OV_ODBC3"); + DateType= SQL_TYPE_DATE; + } + + rc = SQLGetInfo(hdbc,SQL_DBMS_VER,(SQLCHAR *)&DbVersion,MAX_NAME_LEN,NULL); + mycon(hdbc,rc); + + SQLExecDirect(hstmt,"DROP TABLE t_convert",SQL_NTS); + + rc = SQLExecDirect(hstmt,"CREATE TABLE t_convert(col0 integer, \ + col1 date,\ + col2 char(10))",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLExecDirect(hstmt,"INSERT INTO t_convert VALUES(10,'2002-10-24','venu')",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLExecDirect(hstmt,"INSERT INTO t_convert VALUES(20,'2002-10-23','venu1')",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLExecDirect(hstmt,"INSERT INTO t_convert VALUES(30,'2002-10-25','venu2')",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLExecDirect(hstmt,"INSERT INTO t_convert VALUES(40,'2002-10-24','venu3')",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLExecDirect(hstmt,"SELECT MAX(col0) FROM t_convert",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLDescribeCol(hstmt,1,(SQLCHAR *)&ColName,MAX_NAME_LEN,NULL,&SqlType,NULL,NULL,NULL); + mystmt(hstmt,rc); + + fprintf(stdout,"\n MAX(col0): %d", SqlType); + myassert(SqlType == SQL_INTEGER); + + SQLFreeStmt(hstmt,SQL_CLOSE); + + rc = SQLExecDirect(hstmt,"SELECT MAX(col1) FROM t_convert",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLDescribeCol(hstmt,1,(SQLCHAR *)&ColName,MAX_NAME_LEN,NULL,&SqlType,NULL,NULL,NULL); + mystmt(hstmt,rc); + + fprintf(stdout,"\n MAX(col1): %d", SqlType); + myassert(SqlType == DateType); + + SQLFreeStmt(hstmt,SQL_CLOSE); + + rc = SQLExecDirect(hstmt,"SELECT MAX(col2) FROM t_convert",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLDescribeCol(hstmt,1,(SQLCHAR *)&ColName,MAX_NAME_LEN,NULL,&SqlType,NULL,NULL,NULL); + mystmt(hstmt,rc); + + fprintf(stdout,"\n MAX(col0): %d", SqlType); + + SQLFreeStmt(hstmt,SQL_CLOSE); + + if (strncmp(DbVersion,"4.",2) >= 0) + { + rc = SQLExecDirect(hstmt,"SELECT CAST(MAX(col1) AS DATE) AS col1 FROM t_convert",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLDescribeCol(hstmt,1,(SQLCHAR *)&ColName,MAX_NAME_LEN,NULL,&SqlType,NULL,NULL,NULL); + mystmt(hstmt,rc); + + fprintf(stdout,"\n CAST(MAX(col1) AS DATE): %d", SqlType); + myassert(SqlType == DateType); + + SQLFreeStmt(hstmt,SQL_CLOSE); + + rc = SQLExecDirect(hstmt,"SELECT CONVERT(MAX(col1),DATE) AS col1 FROM t_convert",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLDescribeCol(hstmt,1,(SQLCHAR *)&ColName,MAX_NAME_LEN,NULL,&SqlType,NULL,NULL,NULL); + mystmt(hstmt,rc); + + fprintf(stdout,"\n CONVERT(MAX(col1),DATE): %d", SqlType); + myassert(SqlType == DateType); + + SQLFreeStmt(hstmt,SQL_CLOSE); + + rc = SQLExecDirect(hstmt,"SELECT CAST(MAX(col1) AS CHAR) AS col1 FROM t_convert",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLDescribeCol(hstmt,1,(SQLCHAR *)&ColName,MAX_NAME_LEN,NULL,&SqlType,NULL,NULL,NULL); + mystmt(hstmt,rc); + + fprintf(stdout,"\n CAST(MAX(col1) AS CHAR): %d", SqlType); + myassert(SqlType == SQL_VARCHAR); + + SQLFreeStmt(hstmt,SQL_CLOSE); + } + + rc = SQLExecDirect(hstmt,"DROP TABLE t_convert",SQL_NTS); + mystmt(hstmt,rc); + + SQLFreeStmt(hstmt,SQL_CLOSE); +} + +/* + Test the bug when two stmts are used with the don't cache results +*/ +static void t_cache_bug() +{ + SQLRETURN rc; + SQLHENV henv; + SQLHDBC hdbc; + SQLHSTMT hstmt1, hstmt2; + SQLCHAR conn[MAX_NAME_LEN]; + + myheader("t_cache_bug"); + + sprintf(conn,"DSN=%s;USER=%s;PASSWORD=%s;OPTION=1048579", + mydsn,myuid,mypwd); + mydrvconnect(&henv,&hdbc,&hstmt1,conn); + + tmysql_exec(hstmt1,"drop table t_cache"); + rc = tmysql_exec(hstmt1,"create table t_cache(id int)"); + mystmt(hstmt1,rc); + + rc = tmysql_exec(hstmt1,"insert into t_cache values(1)"); + mystmt(hstmt1,rc); + + rc = tmysql_exec(hstmt1,"insert into t_cache values(2)"); + mystmt(hstmt1,rc); + + rc = tmysql_exec(hstmt1,"insert into t_cache values(3)"); + mystmt(hstmt1,rc); + + rc = tmysql_exec(hstmt1,"insert into t_cache values(4)"); + mystmt(hstmt1,rc); + + rc = tmysql_exec(hstmt1,"insert into t_cache values(5)"); + mystmt(hstmt1,rc); + + rc = SQLExecDirect(hstmt1,"select * from t_cache",SQL_NTS); + mystmt(hstmt1,rc); + + rc = SQLFetch(hstmt1); + mystmt(hstmt1,rc); + + rc = SQLFetch(hstmt1); + mystmt(hstmt1,rc); + + rc = SQLAllocHandle(SQL_HANDLE_STMT,hdbc,&hstmt2); + mycon(hdbc,rc); + + rc = SQLColumns(hstmt2,test_db,SQL_NTS, + NULL,0,"t_cache",SQL_NTS, + NULL,0); + mystmt(hstmt2,rc); + + rc = SQLFetch(hstmt2); + mystmt(hstmt2,rc); + + rc = SQLFetch(hstmt1); + mystmt(hstmt1,rc); + + rc = SQLFetch(hstmt2); + myassert(rc == SQL_NO_DATA); + + rc = SQLFetch(hstmt1); + mystmt(hstmt2,rc); + + rc = SQLFreeHandle(SQL_HANDLE_STMT,hstmt2); + mystmt(hstmt2,rc); + + rc = SQLFetch(hstmt1); + mystmt(hstmt2,rc); + + rc = SQLFetch(hstmt1); + myassert(rc == SQL_NO_DATA); + + rc = SQLFreeStmt(hstmt1, SQL_DROP); + mystmt(hstmt1,rc); + + rc = SQLDisconnect(hdbc); + mycon(hdbc,rc); + + rc = SQLFreeConnect(hdbc); + mycon(hdbc,rc); + + rc = SQLFreeEnv(henv); + myenv(henv,rc); +} + +/* + Test the bug when two stmts are used with the don't cache results +*/ +static void t_non_cache_bug() +{ + SQLRETURN rc; + SQLHENV henv; + SQLHDBC hdbc; + SQLHSTMT hstmt1, hstmt2; + SQLCHAR conn[MAX_NAME_LEN]; + + myheader("t_non_cache_bug"); + + sprintf(conn,"DSN=%s;USER=%s;PASSWORD=%s;OPTION=3", + mydsn,myuid,mypwd); + mydrvconnect(&henv,&hdbc,&hstmt1,conn); + + tmysql_exec(hstmt1,"drop table t_cache"); + rc = tmysql_exec(hstmt1,"create table t_cache(id int)"); + mystmt(hstmt1,rc); + + rc = tmysql_exec(hstmt1,"insert into t_cache values(1)"); + mystmt(hstmt1,rc); + + rc = tmysql_exec(hstmt1,"insert into t_cache values(2)"); + mystmt(hstmt1,rc); + + rc = tmysql_exec(hstmt1,"insert into t_cache values(3)"); + mystmt(hstmt1,rc); + + rc = tmysql_exec(hstmt1,"insert into t_cache values(4)"); + mystmt(hstmt1,rc); + + rc = tmysql_exec(hstmt1,"insert into t_cache values(5)"); + mystmt(hstmt1,rc); + + rc = SQLExecDirect(hstmt1,"select * from t_cache",SQL_NTS); + mystmt(hstmt1,rc); + + rc = SQLFetch(hstmt1); + mystmt(hstmt1,rc); + + rc = SQLFetch(hstmt1); + mystmt(hstmt1,rc); + + rc = SQLAllocHandle(SQL_HANDLE_STMT,hdbc,&hstmt2); + mycon(hdbc,rc); + + rc = SQLColumns(hstmt2,test_db,SQL_NTS, + NULL,0,"t_cache",SQL_NTS, + NULL,0); + mystmt(hstmt2,rc); + + rc = SQLFetch(hstmt2); + mystmt(hstmt2,rc); + + rc = SQLFetch(hstmt1); + mystmt(hstmt1,rc); + + rc = SQLFetch(hstmt2); + myassert(rc == SQL_NO_DATA); + + rc = SQLFetch(hstmt1); + mystmt(hstmt2,rc); + + rc = SQLFreeHandle(SQL_HANDLE_STMT,hstmt2); + mystmt(hstmt2,rc); + + rc = SQLFetch(hstmt1); + mystmt(hstmt2,rc); + + rc = SQLFetch(hstmt1); + myassert(rc == SQL_NO_DATA); + + rc = SQLFreeStmt(hstmt1, SQL_DROP); + mystmt(hstmt1,rc); + + rc = SQLDisconnect(hdbc); + mycon(hdbc,rc); + + rc = SQLFreeConnect(hdbc); + mycon(hdbc,rc); + + rc = SQLFreeEnv(henv); + myenv(henv,rc); +} + +/* + Test the bug when blob size > 8k +*/ +static void t_blob_bug(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLCHAR *data; + SQLLEN length; + SQLINTEGER i; + const SQLINTEGER max_blob_size=1024*100; + + myheader("t_blob_bug"); + + SQLExecDirect(hstmt,"drop table t_blob",SQL_NTS); + rc = SQLExecDirect(hstmt,"create table t_blob(blb long varbinary)",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLPrepare(hstmt,"insert into t_blob values(?)",SQL_NTS); + mystmt(hstmt,rc); + + if (!(data = (SQLCHAR *)calloc(max_blob_size,sizeof(SQLCHAR)))) + { + SQLFreeStmt(hstmt,SQL_RESET_PARAMS); + SQLFreeStmt(hstmt,SQL_CLOSE); + return; + } + + rc = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT,SQL_C_CHAR,SQL_VARBINARY, + 0,0,data,0,&length); + mystmt(hstmt,rc); + + memset(data,'X',max_blob_size); + + fprintf(stdout,"\n inserting %d rows\n", max_blob_size / 1024); + for (length=1024; length <= max_blob_size; length+= 1024) + { + fprintf(stdout,"\r %ld", length/1024); + rc = SQLExecute(hstmt); + mystmt(hstmt,rc); + } + + SQLFreeStmt(hstmt,SQL_RESET_PARAMS); + SQLFreeStmt(hstmt,SQL_CLOSE); + + rc = SQLExecDirect(hstmt,"SELECT length(blb) FROM t_blob",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,1,SQL_C_LONG,&length,0,NULL); + mystmt(hstmt,rc); + + for (i= 1; i <= max_blob_size/1024; i++) + { + rc = SQLFetch(hstmt); + mystmt(hstmt,rc); + + fprintf(stdout,"\n row %d length: %ld", i, length); + myassert(length == i * 1024); + } + rc = SQLFetch(hstmt); + myassert(rc == SQL_NO_DATA); + + free(data); + + SQLFreeStmt(hstmt,SQL_UNBIND); + SQLFreeStmt(hstmt,SQL_CLOSE); +} + +/* + Test the bug SQLTables +*/ + +typedef struct t_table_bug +{ + SQLCHAR szColName[MAX_NAME_LEN]; + SQLSMALLINT pcbColName; + SQLSMALLINT pfSqlType; + SQLUINTEGER pcbColDef; + SQLSMALLINT pibScale; + SQLSMALLINT pfNullable; +} t_describe_col; + + +t_describe_col t_tables_bug_data[5] = +{ + {"TABLE_CAT", 9, SQL_VARCHAR, MYSQL_NAME_LEN, 0, SQL_NULLABLE}, + {"TABLE_SCHEM",11, SQL_VARCHAR, MYSQL_NAME_LEN, 0, SQL_NULLABLE}, + {"TABLE_NAME", 10, SQL_VARCHAR, MYSQL_NAME_LEN, 0, SQL_NULLABLE}, + {"TABLE_TYPE", 10, SQL_VARCHAR, MYSQL_NAME_LEN, 0, SQL_NULLABLE}, + {"REMARKS", 7, SQL_VARCHAR, MYSQL_NAME_LEN, 0, SQL_NULLABLE}, +}; + +static void t_tables_bug(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLSMALLINT i, ColumnCount, pcbColName, pfSqlType, pibScale, pfNullable; + SQLULEN pcbColDef; + SQLCHAR szColName[MAX_NAME_LEN]; + + myheader("t_tables_bug"); + + SQLFreeStmt(hstmt, SQL_CLOSE); + + rc = SQLTables(hstmt,NULL,0,NULL,0,NULL,0,"'TABLE'",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLNumResultCols(hstmt,&ColumnCount); + mystmt(hstmt,rc); + + fprintf(stdout, "\n total columns in SQLTables: %d", ColumnCount); + myassert(ColumnCount == 5); + + for (i= 1; i <= ColumnCount; i++) + { + rc = SQLDescribeCol(hstmt, (SQLUSMALLINT)i, + szColName,MAX_NAME_LEN,&pcbColName, + &pfSqlType,&pcbColDef,&pibScale,&pfNullable); + mystmt(hstmt,rc); + + fprintf(stdout, "\n Column Number'%d':", i); + fprintf(stdout, "\n\t Column Name : %s", szColName); + fprintf(stdout, "\n\t NameLengh : %d", pcbColName); + fprintf(stdout, "\n\t DataType : %d", pfSqlType); + fprintf(stdout, "\n\t ColumnSize : %ld", pcbColDef); + fprintf(stdout, "\n\t DecimalDigits : %d", pibScale); + fprintf(stdout, "\n\t Nullable : %d", pfNullable); + + myassert(strcmp(t_tables_bug_data[i-1].szColName,szColName) == 0); + myassert(t_tables_bug_data[i-1].pcbColName == pcbColName); + myassert(t_tables_bug_data[i-1].pfSqlType == pfSqlType); + myassert(t_tables_bug_data[i-1].pcbColDef == pcbColDef); + myassert(t_tables_bug_data[i-1].pibScale == pibScale); + myassert(t_tables_bug_data[i-1].pfNullable == pfNullable); + } + SQLFreeStmt(hstmt,SQL_CLOSE); +} + +/* + Test for a simple SQLPutData and SQLParamData handling for longtext +*/ +static void t_putdata(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLINTEGER pcbLength, c1; + SQLCHAR data[255]; + SQLPOINTER token; + + myheader("t_putdata"); + + + SQLExecDirect(hstmt,"drop table t_putdata",SQL_NTS); + rc = SQLExecDirect(hstmt,"create table t_putdata(c1 int, c2 long varchar)",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLPrepare(hstmt,"insert into t_putdata values(?,?)",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT,SQL_C_LONG, + SQL_INTEGER,0,0,&c1,0,NULL); + + rc = SQLBindParameter(hstmt,2,SQL_PARAM_INPUT,SQL_C_CHAR, + SQL_LONGVARCHAR,0,0, + (SQLPOINTER)1,0,&pcbLength); + + pcbLength = SQL_LEN_DATA_AT_EXEC(0); + + c1 = 10; + rc = SQLExecute(hstmt); + myassert(rc == SQL_NEED_DATA); + + rc = SQLParamData(hstmt, &token); + myassert(rc == SQL_NEED_DATA); + + strcpy(data,"mysql ab"); + rc = SQLPutData(hstmt,data,6); + mystmt(hstmt,rc); + + strcpy(data,"- the open source database company"); + rc = SQLPutData(hstmt,data,strlen(data)); + mystmt(hstmt,rc); + + rc = SQLParamData(hstmt, &token); + mystmt(hstmt,rc); + + SQLFreeStmt(hstmt, SQL_RESET_PARAMS); + SQLFreeStmt(hstmt, SQL_CLOSE); + + rc = SQLExecDirect(hstmt,"select c2 from t_putdata where c1= 10",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLFetch(hstmt); + mystmt(hstmt,rc); + + pcbLength= 0; + rc = SQLGetData(hstmt, 1, SQL_C_CHAR, data, sizeof(data), &pcbLength); + mystmt(hstmt,rc); + fprintf(stdout,"\n data: %s(%d)", data, pcbLength); + myassert(strcmp(data,"mysql - the open source database company")==0); + myassert(pcbLength == 40); + + SQLFreeStmt(hstmt, SQL_UNBIND); + SQLFreeStmt(hstmt, SQL_CLOSE); +} + +/* + Test for a simple SQLPutData and SQLParamData handling for longtext +*/ +static void t_putdata1(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLINTEGER pcbLength, c1; + SQLCHAR data[255]; + SQLPOINTER token; + + myheader("t_putdata1"); + + + SQLExecDirect(hstmt,"drop table t_putdata",SQL_NTS); + rc = SQLExecDirect(hstmt,"create table t_putdata(c1 int, c2 long varchar)",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLExecDirect(hstmt,"insert into t_putdata values(10,'venu')",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLPrepare(hstmt,"update t_putdata set c2= ? where c1 = ?",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT,SQL_C_CHAR, + SQL_LONGVARCHAR,0,0, + (SQLPOINTER)1,0,&pcbLength); + + rc = SQLBindParameter(hstmt,2,SQL_PARAM_INPUT,SQL_C_LONG, + SQL_INTEGER,0,0,&c1,0,NULL); + + pcbLength = SQL_LEN_DATA_AT_EXEC(0); + + c1 = 10; + rc = SQLExecute(hstmt); + myassert(rc == SQL_NEED_DATA); + + rc = SQLParamData(hstmt, &token); + myassert(rc == SQL_NEED_DATA); + + strcpy(data,"mysql ab"); + rc = SQLPutData(hstmt,data,6); + mystmt(hstmt,rc); + + strcpy(data,"- the open source database company"); + rc = SQLPutData(hstmt,data,strlen(data)); + mystmt(hstmt,rc); + + rc = SQLParamData(hstmt, &token); + mystmt(hstmt,rc); + + SQLFreeStmt(hstmt, SQL_RESET_PARAMS); + SQLFreeStmt(hstmt, SQL_CLOSE); + + rc = SQLExecDirect(hstmt,"select c2 from t_putdata where c1= 10",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLFetch(hstmt); + mystmt(hstmt,rc); + + pcbLength= 0; + rc = SQLGetData(hstmt, 1, SQL_C_CHAR, data, sizeof(data), &pcbLength); + mystmt(hstmt,rc); + fprintf(stdout,"\n data: %s(%d)", data, pcbLength); + myassert(strcmp(data,"mysql - the open source database company")==0); + myassert(pcbLength == 40); + + SQLFreeStmt(hstmt, SQL_UNBIND); + SQLFreeStmt(hstmt, SQL_CLOSE); +} +/* + Test for a simple SQLPutData and SQLParamData handling for longtext +*/ +static void t_putdata2(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLINTEGER pcbLength, c1; + SQLCHAR data[255]; + SQLPOINTER token; + + myheader("t_putdata2"); + + SQLExecDirect(hstmt,"drop table t_putdata",SQL_NTS); + rc = SQLExecDirect(hstmt,"create table t_putdata(c1 int, c2 long varchar, c3 long varchar)",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLPrepare(hstmt,"insert into t_putdata values(?,?,?)",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT,SQL_C_LONG, + SQL_INTEGER,0,0,&c1,0,NULL); + + rc = SQLBindParameter(hstmt,2,SQL_PARAM_INPUT,SQL_C_CHAR, + SQL_LONGVARCHAR,0,0, + (SQLPOINTER)1,0,&pcbLength); + + rc = SQLBindParameter(hstmt,3,SQL_PARAM_INPUT,SQL_C_CHAR, + SQL_LONGVARCHAR,0,0, + (SQLPOINTER)1,0,&pcbLength); + + pcbLength = SQL_LEN_DATA_AT_EXEC(0); + + c1 = 10; + rc = SQLExecute(hstmt); + myassert(rc == SQL_NEED_DATA); + + rc = SQLParamData(hstmt, &token); + myassert(rc == SQL_NEED_DATA); + + strcpy(data,"mysql ab"); + rc = SQLPutData(hstmt,data,6); + mystmt(hstmt,rc); + + strcpy(data,"- the open source database company"); + rc = SQLPutData(hstmt,data,strlen(data)); + mystmt(hstmt,rc); + + rc = SQLParamData(hstmt, &token); + myassert(rc == SQL_NEED_DATA); + + strcpy(data,"MySQL AB"); + rc = SQLPutData(hstmt,data, 8); + mystmt(hstmt,rc); + + rc = SQLParamData(hstmt, &token); + mystmt(hstmt,rc); + + SQLFreeStmt(hstmt, SQL_RESET_PARAMS); + SQLFreeStmt(hstmt, SQL_CLOSE); + + rc = SQLExecDirect(hstmt,"select c2,c3 from t_putdata where c1= 10",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLFetch(hstmt); + mystmt(hstmt,rc); + + pcbLength= 0; + rc = SQLGetData(hstmt, 1, SQL_C_CHAR, data, sizeof(data), &pcbLength); + mystmt(hstmt,rc); + fprintf(stdout,"\n data: %s(%d)", data, pcbLength); + myassert(strcmp(data,"mysql - the open source database company")==0); + myassert(pcbLength == 40); + + pcbLength= 0; + rc = SQLGetData(hstmt, 2, SQL_C_CHAR, data, sizeof(data), &pcbLength); + mystmt(hstmt,rc); + fprintf(stdout,"\n data: %s(%d)", data, pcbLength); + myassert(strcmp(data,"MySQL AB")==0); + myassert(pcbLength == 8); + + SQLFreeStmt(hstmt, SQL_RESET_PARAMS); + SQLFreeStmt(hstmt, SQL_UNBIND); + SQLFreeStmt(hstmt, SQL_CLOSE); +} +/* + Test for a simple time struct +*/ +static void t_time1(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQL_TIME_STRUCT tt; + SQLCHAR data[30]; + SQLINTEGER length; + + myheader("t_time1"); + + SQLExecDirect(hstmt,"drop table t_time",SQL_NTS); + rc = SQLExecDirect(hstmt,"create table t_time(t time, t1 timestamp, t2 datetime, t3 date)",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLPrepare(hstmt,"insert into t_time(t) values(?)",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT,SQL_C_TYPE_TIME, + SQL_TIME,0,0,&tt,0,NULL); + + + tt.hour= 00; + tt.minute= 00; + tt.second= 03; + + rc = SQLExecute(hstmt); + mystmt(hstmt, rc); + + tt.hour= 01; + tt.minute= 00; + tt.second= 00; + + rc = SQLExecute(hstmt); + mystmt(hstmt, rc); + + tt.hour= 19; + tt.minute= 00; + tt.second= 00; + + rc = SQLExecute(hstmt); + mystmt(hstmt, rc); + + tt.hour= 01; + tt.minute= 01; + tt.second= 00; + + rc = SQLExecute(hstmt); + mystmt(hstmt, rc); + + tt.hour= 01; + tt.minute= 00; + tt.second= 01; + + rc = SQLExecute(hstmt); + mystmt(hstmt, rc); + + tt.hour= 00; + tt.minute= 01; + tt.second= 00; + + rc = SQLExecute(hstmt); + mystmt(hstmt, rc); + + tt.hour= 00; + tt.minute= 11; + tt.second= 12; + + rc = SQLExecute(hstmt); + mystmt(hstmt, rc); + + tt.hour= 01; + tt.minute= 01; + tt.second= 01; + + rc = SQLExecute(hstmt); + mystmt(hstmt, rc); + + tt.hour= 00; + tt.minute= 00; + tt.second= 00; + + rc = SQLExecute(hstmt); + mystmt(hstmt, rc); + + tt.hour= 10; + tt.minute= 11; + tt.second= 12; + + rc = SQLExecute(hstmt); + mystmt(hstmt, rc); + + SQLFreeStmt(hstmt, SQL_RESET_PARAMS); + SQLFreeStmt(hstmt, SQL_CLOSE); + + rc = SQLExecDirect(hstmt,"select t from t_time",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLFetch(hstmt); + mystmt(hstmt,rc); + + rc = SQLGetData(hstmt, 1, SQL_C_CHAR, data, sizeof(data), &length); + mystmt(hstmt,rc); + fprintf(stdout,"\n time: %s(%d)", data, length); + myassert(strcmp(data,"00:00:03")==0); + myassert(length == 8); + + rc = SQLFetch(hstmt); + mystmt(hstmt,rc); + + rc = SQLGetData(hstmt, 1, SQL_C_CHAR, data, sizeof(data), &length); + mystmt(hstmt,rc); + fprintf(stdout,"\n time: %s(%d)", data, length); + myassert(strcmp(data,"01:00:00")==0); + myassert(length == 8); + + rc = SQLFetch(hstmt); + mystmt(hstmt,rc); + + rc = SQLGetData(hstmt, 1, SQL_C_CHAR, data, sizeof(data), &length); + mystmt(hstmt,rc); + fprintf(stdout,"\n time: %s(%d)", data, length); + myassert(strcmp(data,"19:00:00")==0); + myassert(length == 8); + + rc = SQLFetch(hstmt); + mystmt(hstmt,rc); + + rc = SQLGetData(hstmt, 1, SQL_C_CHAR, data, sizeof(data), &length); + mystmt(hstmt,rc); + fprintf(stdout,"\n time: %s(%d)", data, length); + myassert(strcmp(data,"01:01:00")==0); + myassert(length == 8); + + rc = SQLFetch(hstmt); + mystmt(hstmt,rc); + + rc = SQLGetData(hstmt, 1, SQL_C_CHAR, data, sizeof(data), &length); + mystmt(hstmt,rc); + fprintf(stdout,"\n time: %s(%d)", data, length); + myassert(strcmp(data,"01:00:01")==0); + myassert(length == 8); + + rc = SQLFetch(hstmt); + mystmt(hstmt,rc); + + rc = SQLGetData(hstmt, 1, SQL_C_CHAR, data, sizeof(data), &length); + mystmt(hstmt,rc); + fprintf(stdout,"\n time: %s(%d)", data, length); + myassert(strcmp(data,"00:01:00")==0); + myassert(length == 8); + + rc = SQLFetch(hstmt); + mystmt(hstmt,rc); + + rc = SQLGetData(hstmt, 1, SQL_C_CHAR, data, sizeof(data), &length); + mystmt(hstmt,rc); + fprintf(stdout,"\n time: %s(%d)", data, length); + myassert(strcmp(data,"00:11:12")==0); + myassert(length == 8); + + rc = SQLFetch(hstmt); + mystmt(hstmt,rc); + + rc = SQLGetData(hstmt, 1, SQL_C_CHAR, data, sizeof(data), &length); + mystmt(hstmt,rc); + fprintf(stdout,"\n time: %s(%d)", data, length); + myassert(strcmp(data,"01:01:01")==0); + myassert(length == 8); + + rc = SQLFetch(hstmt); + mystmt(hstmt,rc); + + rc = SQLGetData(hstmt, 1, SQL_C_CHAR, data, sizeof(data), &length); + mystmt(hstmt,rc); + fprintf(stdout,"\n time: %s(%d)", data, length); + + myassert(strcmp(data,"00:00:00")==0); + myassert(length == 8); + + rc = SQLFetch(hstmt); + mystmt(hstmt,rc); + + rc = SQLGetData(hstmt, 1, SQL_C_CHAR, data, sizeof(data), &length); + mystmt(hstmt,rc); + fprintf(stdout,"\n time: %s(%d)", data, length); + myassert(strcmp(data,"10:11:12")==0); + myassert(length == 8); + + rc = SQLFetch(hstmt); + myassert(rc == SQL_NO_DATA); + + SQLFreeStmt(hstmt, SQL_UNBIND); + SQLFreeStmt(hstmt, SQL_CLOSE); + + rc = SQLExecDirect(hstmt,"delete from t_time",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLExecDirect(hstmt,"insert into t_time(t1) values('2003-05-12 10:11:12')",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLExecDirect(hstmt,"select t1 from t_time", SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLFetch(hstmt); + mystmt(hstmt,rc); + + rc = SQLGetData(hstmt, 1, SQL_C_TIME, &tt, sizeof(tt), &length); + mystmt(hstmt,rc); + fprintf(stdout,"\n time: %d:%d:%d(%d)", tt.hour, tt.minute, tt.second, length); + + myassert(tt.hour == 10 && tt.minute == 11 && tt.second == 12); + myassert(length == sizeof(SQL_TIME_STRUCT)); + + rc = SQLFetch(hstmt); + myassert(rc == SQL_NO_DATA); + + SQLFreeStmt(hstmt, SQL_UNBIND); + SQLFreeStmt(hstmt, SQL_CLOSE); + + rc = SQLExecDirect(hstmt,"delete from t_time",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLExecDirect(hstmt,"insert into t_time(t2) values('03-12-28 05:59:59')",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLExecDirect(hstmt,"select t2 from t_time", SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLFetch(hstmt); + mystmt(hstmt,rc); + + rc = SQLGetData(hstmt, 1, SQL_C_TIME, &tt, sizeof(tt), &length); + mystmt(hstmt,rc); + fprintf(stdout,"\n time: %d:%d:%d(%d)", tt.hour, tt.minute, tt.second, length); + myassert(tt.hour == 05 && tt.minute == 59 && tt.second == 59); + myassert(length == sizeof(SQL_TIME_STRUCT)); + + rc = SQLFetch(hstmt); + myassert(rc == SQL_NO_DATA); + + SQLFreeStmt(hstmt, SQL_UNBIND); + SQLFreeStmt(hstmt, SQL_CLOSE); + + rc = SQLExecDirect(hstmt,"delete from t_time",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLExecDirect(hstmt,"insert into t_time(t3) values('2003-05-12 10:11:12')",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLExecDirect(hstmt,"select t3 from t_time", SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLFetch(hstmt); + mystmt(hstmt,rc); + + rc = SQLGetData(hstmt, 1, SQL_C_TIME, &tt, sizeof(tt), &length); + mystmt(hstmt,rc); + fprintf(stdout,"\n time: %d:%d:%d(%d)", tt.hour, tt.minute, tt.second, length); + myassert(tt.hour == 00 || tt.minute == 00 || tt.second == 00); + myassert(length == sizeof(SQL_TIME_STRUCT)); + + rc = SQLFetch(hstmt); + myassert(rc == SQL_NO_DATA); + + SQLFreeStmt(hstmt, SQL_UNBIND); + SQLFreeStmt(hstmt, SQL_CLOSE); +} + +/* + test for SQL_ATTR_ROW_ARRAY_SIZE +*/ +void t_row_array_size(SQLHDBC hdbc,SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLINTEGER i,nrows,iarray[15]; + const int max_rows=9; + + myheader("t_row_array_size"); + + SQLExecDirect(hstmt,"drop table t_row_array_size",SQL_NTS); + + rc = SQLExecDirect(hstmt,"create table t_row_array_size(id int)",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLPrepare(hstmt,"insert into t_row_array_size values(?)",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT, SQL_C_ULONG, + SQL_INTEGER,0,0,&i,0,NULL); + mystmt(hstmt,rc); + + for( i = 1; i <= max_rows; i++ ) + { + rc = SQLExecute(hstmt); + mystmt(hstmt,rc); + } + + SQLFreeStmt(hstmt,SQL_RESET_PARAMS); + SQLFreeStmt(hstmt,SQL_CLOSE); + + rc = SQLEndTran(SQL_HANDLE_DBC,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + /* set row_size as 2 */ + rc = SQLSetStmtAttr(hstmt,SQL_ATTR_ROW_ARRAY_SIZE,(SQLPOINTER)2,SQL_IS_UINTEGER); + mystmt(hstmt,rc); + + rc = SQLSetStmtAttr(hstmt,SQL_ATTR_ROWS_FETCHED_PTR,&nrows,SQL_IS_POINTER); + mystmt(hstmt,rc); + + rc = SQLExecDirect(hstmt,"select * from t_row_array_size",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,1,SQL_C_LONG,&iarray,0,NULL); + mystmt(hstmt,rc); + + /* row 1-2 */ + rc = SQLFetch(hstmt); + mystmt(hstmt,rc); + my_assert(nrows == 2); + my_assert(iarray[0]==1); + my_assert(iarray[1]==2); + + /* row 3-4 */ + rc = SQLFetch(hstmt); + mystmt(hstmt,rc); + my_assert(nrows == 2); + my_assert(iarray[0]==3); + my_assert(iarray[1]==4); + + /* row 5-6 */ + rc = SQLFetchScroll(hstmt,SQL_FETCH_NEXT,1);/* 1 */ + mystmt(hstmt,rc); + my_assert(nrows == 2); + my_assert(iarray[0]==5); + my_assert(iarray[1]==6); + + /* row 7-8 */ + rc = SQLFetch(hstmt); + mystmt(hstmt,rc); + my_assert(nrows == 2); + my_assert(iarray[0]==7); + my_assert(iarray[1]==8); + + /* row 9 */ + rc = SQLFetch(hstmt); + mystmt(hstmt,rc); + my_assert(nrows == 1); + my_assert(iarray[0]==9); + + rc = SQLFetch(hstmt);/* end */ + mystmt_err(hstmt,rc==SQL_NO_DATA_FOUND,rc); + + SQLFreeStmt(hstmt,SQL_UNBIND); + SQLFreeStmt(hstmt,SQL_CLOSE); + + rc = SQLSetStmtAttr(hstmt,SQL_ATTR_ROW_ARRAY_SIZE,(SQLPOINTER)1,0); + mystmt(hstmt,rc); + + rc = SQLSetStmtAttr(hstmt,SQL_ATTR_ROWS_FETCHED_PTR,(SQLPOINTER)0,SQL_IS_POINTER); + mystmt(hstmt,rc); +} + +/* + Test for SQL_ATTR_ROWS_FETCHED_PTR +*/ +static void t_rows_fetched_ptr(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLCHAR name[255]; + SQLSMALLINT pccol; + SQLRETURN rc; + SQLINTEGER rows_fetched, data[4], pcb_value[4], i; + SQLUSMALLINT row_status[4]; + + myheader("t_rows_fetched_ptr"); + + SQLExecDirect(hstmt,"drop table t_rows_fetched_ptr",SQL_NTS); + + rc = SQLExecDirect(hstmt,"create table t_rows_fetched_ptr(id int)",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLPrepare(hstmt,"insert into t_rows_fetched_ptr values(?)",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT, SQL_C_ULONG, + SQL_INTEGER,0,0,&i,0,NULL); + mystmt(hstmt,rc); + + for( i = 1; i <= 3; i++ ) + { + rc = SQLExecute(hstmt); + mystmt(hstmt,rc); + } + + SQLFreeStmt(hstmt,SQL_RESET_PARAMS); + SQLFreeStmt(hstmt,SQL_CLOSE); + + rc = SQLEndTran(SQL_HANDLE_DBC,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLExecDirect(hstmt,"select * from t_rows_fetched_ptr",SQL_NTS); + mystmt(hstmt, rc); + + rc = SQLNumResultCols(hstmt, &pccol); + mystmt(hstmt, rc); + fprintf(stdout,"\n total columns: %d", pccol); + myassert(pccol == 1); + + pccol= 0; + rc = SQLColAttribute(hstmt, 1, SQL_DESC_COUNT, 0, 0, 0, &pccol); + mystmt(hstmt, rc); + fprintf(stdout,"\n desc count: %d", pccol); + myassert(pccol == 1); + + rc = SQLColAttribute(hstmt, 1, SQL_DESC_NAME, &name, 255, 0, &pccol); + mystmt(hstmt, rc); + fprintf(stdout,"\n desc name: %s", name); + assert(strcmp(name,"id") ==0 || strcmp(name, "ID") == 0); + + rc = SQLSetStmtAttr(hstmt, SQL_ATTR_ROWS_FETCHED_PTR, &rows_fetched, SQL_IS_POINTER); + mystmt(hstmt, rc); + + rc = SQLSetStmtAttr(hstmt, SQL_ATTR_ROW_ARRAY_SIZE, (SQLPOINTER)2, SQL_IS_UINTEGER); + mystmt(hstmt, rc); + + rc = SQLSetStmtAttr(hstmt, SQL_ATTR_ROW_STATUS_PTR, &row_status, SQL_IS_POINTER); + mystmt(hstmt, rc); + + rc = SQLBindCol(hstmt, 1, SQL_C_LONG, (SQLPOINTER)data, 0, (SQLINTEGER *)pcb_value); + mystmt(hstmt, rc); + + rc = SQLFetch(hstmt); + mystmt(hstmt, rc); + + fprintf(stdout,"\n fetched ptr: %d", rows_fetched); + myassert(rows_fetched == 2); + + for( i = 0; i < rows_fetched; i++ ) + { + fprintf(stdout,"\n row[%d]:", i); + fprintf(stdout,"\n\t value : %d (%d)", data[i], pcb_value[i]); + fprintf(stdout,"\n\t status: %d", row_status[i]); + myassert(row_status[i] == SQL_ROW_SUCCESS); + } + + rc = SQLFetch(hstmt); + mystmt(hstmt, rc); + + fprintf(stdout,"\n fetched ptr: %d", rows_fetched); + myassert(rows_fetched == 1); + + for( i = 0; i < rows_fetched; i++ ) + { + fprintf(stdout,"\n row[%d]:", i); + fprintf(stdout,"\n\t value : %d (%d)", data[i], pcb_value[i]); + fprintf(stdout,"\n\t status: %d", row_status[0]); + myassert(row_status[i] == SQL_ROW_SUCCESS); + } + myassert(row_status[1] == SQL_ROW_NOROW); + + rc = SQLFetch(hstmt); + myassert(rc == SQL_NO_DATA); + + SQLFreeStmt(hstmt, SQL_UNBIND); + SQLFreeStmt(hstmt, SQL_CLOSE); + + rc = SQLSetStmtAttr(hstmt,SQL_ATTR_ROW_ARRAY_SIZE,(SQLPOINTER)1,0); + mystmt(hstmt,rc); + + rc = SQLSetStmtAttr(hstmt,SQL_ATTR_ROWS_FETCHED_PTR,(SQLPOINTER)0,SQL_IS_POINTER); + mystmt(hstmt,rc); + + rc = SQLSetStmtAttr(hstmt,SQL_ATTR_ROW_STATUS_PTR,(SQLPOINTER)0,0); + mystmt(hstmt,rc); +} + +static void t_empty_str_bug(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLINTEGER id, name_len, desc_len; + SQLCHAR name[20], desc[20]; + + myheader("t_empty_str_bug"); + + tmysql_exec(hstmt,"drop table t_empty_str_bug"); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = tmysql_exec(hstmt,"CREATE TABLE t_empty_str_bug(Id int NOT NULL,\ + Name varchar(10) default NULL, \ + Description varchar(10) default NULL, \ + PRIMARY KEY (Id))"); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLSetCursorName(hstmt,"venu",SQL_NTS); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select * from t_empty_str_bug"); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,1,SQL_C_LONG,&id,0,NULL); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,2,SQL_C_CHAR,&name,100,&name_len); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,3,SQL_C_CHAR,&desc,100,&desc_len); + mystmt(hstmt,rc); + + rc = SQLExtendedFetch(hstmt,SQL_FETCH_NEXT,1,NULL,NULL); + myassert(rc == SQL_NO_DATA_FOUND); + + id= 10; + strcpy(name,"MySQL AB");name_len= SQL_NTS; + strcpy(desc,"");desc_len= SQL_COLUMN_IGNORE; + + rc = SQLSetPos(hstmt,1,SQL_ADD,SQL_LOCK_NO_CHANGE); + mystmt(hstmt,rc); + + rc = SQLRowCount(hstmt,&name_len); + mystmt(hstmt,rc); + + fprintf(stdout," rows affected:%d\n",name_len); + myassert(name_len == 1); + + rc = SQLFreeStmt(hstmt,SQL_UNBIND); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select * from t_empty_str_bug"); + mystmt(hstmt,rc); + + my_assert( 1 == myresult(hstmt)); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"select * from t_empty_str_bug"); + mystmt(hstmt,rc); + + rc = SQLExtendedFetch(hstmt,SQL_FETCH_ABSOLUTE,1,NULL,NULL); + mystmt(hstmt,rc); + + name[0]='\0'; + my_assert(10 == my_fetch_int(hstmt,1)); + my_assert(!strcmp((const char *)"MySQL AB",my_fetch_str(hstmt,name,2))); + my_assert(!strcmp((const char *)"MySQL AB",my_fetch_str(hstmt,name,3))); /* NULL */ + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); +} + +static void t_current_catalog(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLCHAR cur_db[255], db[255]; + SQLRETURN rc; + SQLUINTEGER len; + + myheader("t_current_catalog"); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = SQLGetConnectAttr(hdbc, SQL_ATTR_CURRENT_CATALOG, (char *)db, 255, &len); + mycon(hdbc,rc); + fprintf(stdout,"\n current_catalog: %s (%ld)", db, len); + myassert(strcmp(db, test_db) == 0 || strlen(test_db) == len); + + rc = SQLSetConnectAttr(hdbc, SQL_ATTR_CURRENT_CATALOG, (char *)db, SQL_NTS); + mycon(hdbc,rc); + + SQLExecDirect(hstmt, "DROP DATABASE t_odbc_test_cur_catalog", SQL_NTS); + + strcpy(cur_db, "t_odbc_test_cur_catalog"); + rc = SQLSetConnectAttr(hdbc, SQL_ATTR_CURRENT_CATALOG, (char *)cur_db, SQL_NTS); + mycon_r(hdbc,rc); + + rc = SQLExecDirect(hstmt, "CREATE DATABASE t_odbc_test_cur_catalog", SQL_NTS); + mystmt(hstmt,rc); + + strcpy(cur_db, "t_odbc_test_cur_catalog"); + rc = SQLSetConnectAttr(hdbc, SQL_ATTR_CURRENT_CATALOG, (char *)cur_db, SQL_NTS); + mycon(hdbc,rc); + + rc = SQLGetConnectAttr(hdbc, SQL_ATTR_CURRENT_CATALOG, (char *)db, 255, &len); + mycon(hdbc,rc); + fprintf(stdout,"\n current_catalog: %s (%ld)", db, len); + myassert(strcmp(cur_db, db) == 0 || strlen(cur_db) == len); + + strcpy(cur_db, "t_odbc_test_cur_catalog-test-12455"); + rc = SQLSetConnectAttr(hdbc, SQL_ATTR_CURRENT_CATALOG, (char *)cur_db, SQL_NTS); + mycon_r(hdbc,rc); + + rc = SQLSetConnectAttr(hdbc, SQL_ATTR_CURRENT_CATALOG, (char *)cur_db, len); + mycon(hdbc,rc); + + /* reset for further tests */ + rc = SQLSetConnectAttr(hdbc, SQL_ATTR_CURRENT_CATALOG, (char *)test_db, SQL_NTS); + mycon(hdbc,rc); + + rc = SQLExecDirect(hstmt, "DROP DATABASE t_odbc_test_cur_catalog", SQL_NTS); + mycon(hstmt,rc); +} + +#if 0 /* to be enabled only for 3.52 which has true prepared statements */ +static void desc_param_check(SQLHSTMT hstmt, + SQLUSMALLINT pno, + SQLSMALLINT dtype, + SQLUINTEGER psize, + SQLSMALLINT ddigits, + SQLSMALLINT lnullable) +{ + SQLRETURN rc; + SQLUINTEGER ParamSize; + SQLSMALLINT ParamType, DecDigits, Nullable; + + rc = SQLDescribeParam(hstmt, pno, &ParamType, &ParamSize, &DecDigits, &Nullable); + mystmt(hstmt,rc); + + fprintf(stdout,"\n\n parameter %d:", pno); + fprintf(stdout,"\n\t type : %d", ParamType); + fprintf(stdout,"\n\t size : %ld", ParamSize); + fprintf(stdout,"\n\t decimals: %d", DecDigits); + fprintf(stdout,"\n\t nullable: %s", Nullable ? "SQL_NULLABLE": "SQL_NO_NULLS"); + + myassert(dtype == ParamType); + myassert(psize == ParamSize); + myassert(ddigits == DecDigits); + myassert(lnullable == Nullable); +} + + +/* To test SQLDescribeParam */ +static void t_desc_param(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLSMALLINT ParamCount; + + myheader("t_desc_param"); + + SQLFreeStmt(hstmt, SQL_CLOSE); + + SQLExecDirect(hstmt,"DROP TABLE t_desc_param",SQL_NTS); + + rc = SQLExecDirect(hstmt,"CREATE TABLE t_desc_param(c1 integer, \ + c2 binary(2) NOT NULL,\ + c3 char(10), \ + c4 varchar(5),\ + c5 decimal(10,3) NOT NULL,\ + c6 tinyint,\ + c7 smallint,\ + c8 numeric(4,2),\ + c9 real,\ + c10 float(5),\ + c11 bigint NOT NULL,\ + c12 varbinary(12))",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLPrepare(hstmt,"INSERT INTO t_desc_param VALUES(?,?,?,?,?,?,?,?,?,?,?,?)",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLNumParams(hstmt, &ParamCount); + mystmt(hstmt,rc); + fprintf(stdout,"\n total parameters: %d", ParamCount); + my_assert(ParamCount == 12); + + desc_param_check(hstmt, 1, SQL_INTEGER, 10, 0, SQL_NULLABLE); + desc_param_check(hstmt, 2, SQL_BINARY, 2, 0, SQL_NO_NULLS); + desc_param_check(hstmt, 3, SQL_CHAR, 10, 0, SQL_NULLABLE); + desc_param_check(hstmt, 4, SQL_VARCHAR, 5, 0, SQL_NULLABLE); + desc_param_check(hstmt, 5, SQL_DECIMAL, 10, 3, SQL_NO_NULLS); + desc_param_check(hstmt, 6, SQL_TINYINT, 3, 0, SQL_NULLABLE); + desc_param_check(hstmt, 7, SQL_SMALLINT, 5, 0, SQL_NULLABLE); + desc_param_check(hstmt, 8, SQL_NUMERIC, 4, 2, SQL_NULLABLE); + desc_param_check(hstmt, 9, SQL_REAL, 24, 0, SQL_NULLABLE); + desc_param_check(hstmt, 10, SQL_REAL, 24, 0, SQL_NULLABLE); + desc_param_check(hstmt, 11, SQL_BIGINT, 19, 0, SQL_NO_NULLS); + desc_param_check(hstmt, 12, SQL_VARBINARY, 12, 0, SQL_NULLABLE); + + SQLFreeStmt(hstmt,SQL_CLOSE); +} +#endif + +static void t_rows_fetched_ptr1(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLUINTEGER rowsFetched, i, rowsSize; + + myheader("t_rows_fetched_ptr1"); + + SQLExecDirect(hstmt,"drop table t_rows_fetched_ptr",SQL_NTS); + + rc = SQLExecDirect(hstmt,"create table t_rows_fetched_ptr(a int)",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLExecDirect(hstmt,"insert into t_rows_fetched_ptr values(0)",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLExecDirect(hstmt,"insert into t_rows_fetched_ptr values(1)",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLExecDirect(hstmt,"insert into t_rows_fetched_ptr values(2)",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLExecDirect(hstmt,"insert into t_rows_fetched_ptr values(3)",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLExecDirect(hstmt,"insert into t_rows_fetched_ptr values(4)",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLExecDirect(hstmt,"insert into t_rows_fetched_ptr values(5)",SQL_NTS); + mystmt(hstmt,rc); + + rowsSize= 1; + rc = SQLSetStmtAttr(hstmt, SQL_ATTR_ROW_ARRAY_SIZE, (SQLPOINTER)rowsSize, 0); + mystmt(hstmt,rc); + + rc = SQLSetStmtAttr(hstmt, SQL_ATTR_ROWS_FETCHED_PTR, &rowsFetched, 0); + mystmt(hstmt,rc); + + rc = SQLExecDirect(hstmt, "SELECT * FROM t_rows_fetched_ptr",SQL_NTS); + mystmt(hstmt,rc); + + i= 0; + rc = SQLFetchScroll(hstmt,SQL_FETCH_NEXT,0); + while (rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO) + { + fprintf(stdout,"\n total rows fetched: %ld", rowsFetched); + myassert(rowsFetched == rowsSize); + i++; rowsFetched= 0; + rc = SQLFetch(hstmt); + } + myassert( i == 6); + SQLFreeStmt(hstmt, SQL_CLOSE); + + rowsSize= 2; + rc = SQLSetStmtAttr(hstmt, SQL_ATTR_ROW_ARRAY_SIZE, (SQLPOINTER)rowsSize, 0); + mystmt(hstmt,rc); + + rc = SQLSetStmtAttr(hstmt, SQL_ATTR_ROWS_FETCHED_PTR, &rowsFetched, 0); + mystmt(hstmt,rc); + + rc = SQLExecDirect(hstmt, "SELECT * FROM t_rows_fetched_ptr",SQL_NTS); + mystmt(hstmt,rc); + + i= 0; + rc = SQLFetchScroll(hstmt,SQL_FETCH_NEXT,0); + while (rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO) + { + fprintf(stdout,"\n total rows fetched: %ld", rowsFetched); + myassert(rowsFetched == rowsSize); + i++;rowsFetched= 0; + rc = SQLFetch(hstmt); + } + myassert( i == 3); + SQLFreeStmt(hstmt, SQL_CLOSE); + + rowsSize= 3; + rc = SQLSetStmtAttr(hstmt, SQL_ATTR_ROW_ARRAY_SIZE, (SQLPOINTER)rowsSize, 0); + mystmt(hstmt,rc); + + rc = SQLSetStmtAttr(hstmt, SQL_ATTR_ROWS_FETCHED_PTR, &rowsFetched, 0); + mystmt(hstmt,rc); + + rc = SQLExecDirect(hstmt, "SELECT * FROM t_rows_fetched_ptr",SQL_NTS); + mystmt(hstmt,rc); + + i= 0; + rc = SQLFetchScroll(hstmt,SQL_FETCH_NEXT,0); + while (rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO) + { + fprintf(stdout,"\n total rows fetched: %ld", rowsFetched); + myassert(rowsFetched == rowsSize); + i++;rowsFetched= 0; + rc = SQLFetch(hstmt); + } + myassert( i == 2); + SQLFreeStmt(hstmt, SQL_CLOSE); + + rowsSize= 4; + rc = SQLSetStmtAttr(hstmt, SQL_ATTR_ROW_ARRAY_SIZE, (SQLPOINTER)rowsSize, 0); + mystmt(hstmt,rc); + + rc = SQLSetStmtAttr(hstmt, SQL_ATTR_ROWS_FETCHED_PTR, &rowsFetched, 0); + mystmt(hstmt,rc); + + rc = SQLExecDirect(hstmt, "SELECT * FROM t_rows_fetched_ptr",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLFetch(hstmt); + mystmt(hstmt,rc); + + fprintf(stdout,"\n total rows fetched: %ld", rowsFetched); + myassert(rowsFetched == rowsSize); + + rc = SQLFetch(hstmt); + mystmt(hstmt,rc); + + fprintf(stdout,"\n total rows fetched: %ld", rowsFetched); + myassert(rowsFetched == 2); + + rc = SQLFetch(hstmt); + myassert(rc == SQL_NO_DATA); + + SQLFreeStmt(hstmt, SQL_CLOSE); + + rc = SQLSetStmtAttr(hstmt, SQL_ATTR_ROW_ARRAY_SIZE, (SQLPOINTER)1, 0);/* reset */ + mystmt(hstmt,rc); + + rc = SQLSetStmtAttr(hstmt, SQL_ATTR_ROWS_FETCHED_PTR, NULL, 0); + mystmt(hstmt,rc); +} + +static void desc_col_check(SQLHSTMT hstmt, + SQLUSMALLINT icol, + const char *name, + SQLSMALLINT sql_type, + SQLUINTEGER col_def, + SQLUINTEGER col_def1, + SQLSMALLINT scale, + SQLSMALLINT nullable) +{ + SQLRETURN rc; + SQLSMALLINT pcbColName, pfSqlType, pibScale, pfNullable; + SQLUINTEGER ccccccccccccccccccccccccccccpcbColDef; + SQLCHAR szColName[MAX_NAME_LEN]; + + rc = SQLDescribeCol(hstmt, icol, + szColName,MAX_NAME_LEN,&pcbColName, + &pfSqlType,&pcbColDef,&pibScale,&pfNullable); + mystmt(hstmt,rc); + + fprintf(stdout, "\n\n Column Number'%d':", icol); + + fprintf(stdout, "\n\t Column Name : %s", szColName); + fprintf(stdout, "\n\t NameLengh : %d", pcbColName); + fprintf(stdout, "\n\t DataType : %d", pfSqlType); + fprintf(stdout, "\n\t ColumnSize : %d", pcbColDef); + fprintf(stdout, "\n\t DecimalDigits : %d", pibScale); + fprintf(stdout, "\n\t Nullable : %d", pfNullable); + + myassert(strcmp(name,szColName) == 0); + myassert(sql_type == pfSqlType); + myassert(col_def == pcbColDef || col_def1 == pcbColDef); + myassert(scale == pibScale); + myassert(nullable == pfNullable); +} + +/* To test SQLDescribeCol */ +static void t_desc_col(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLSMALLINT ColumnCount; + + myheader("t_desc_col"); + + SQLFreeStmt(hstmt, SQL_CLOSE); + + SQLExecDirect(hstmt,"DROP TABLE t_desc_col",SQL_NTS); + + rc = SQLExecDirect(hstmt,"CREATE TABLE t_desc_col(c1 integer, \ + c2 binary(2) NOT NULL,\ + c3 char(1), \ + c4 varchar(5),\ + c5 decimal(10,3) NOT NULL,\ + c6 tinyint,\ + c7 smallint,\ + c8 numeric(4,2),\ + c9 real,\ + c10 float(5),\ + c11 bigint NOT NULL,\ + c12 varbinary(12),\ + c13 char(20) NOT NULL,\ + c14 float(10,3),\ + c15 tinytext,\ + c16 text,\ + c17 mediumtext,\ + c18 longtext,\ + c19 tinyblob,\ + c20 blob,\ + c21 mediumblob,\ + c22 longblob,\ + c23 tinyblob)",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLExecDirect(hstmt,"SELECT * FROM t_desc_col",SQL_NTS); + mystmt(hstmt,rc); + + rc = SQLNumResultCols(hstmt, &ColumnCount); + mystmt(hstmt,rc); + + fprintf(stdout,"\n total columns: %d", ColumnCount); + my_assert(ColumnCount == 23); + + desc_col_check(hstmt, 1, "c1", SQL_INTEGER, 10, 11, 0, SQL_NULLABLE); + desc_col_check(hstmt, 2, "c2", SQL_BINARY, 2, 2, 0, SQL_NO_NULLS); + desc_col_check(hstmt, 3, "c3", SQL_CHAR, 1, 1, 0, SQL_NULLABLE); + desc_col_check(hstmt, 4, "c4", SQL_VARCHAR, 5, 5, 0, SQL_NULLABLE); + desc_col_check(hstmt, 5, "c5", SQL_DECIMAL, 10, 10, 3, SQL_NO_NULLS); + desc_col_check(hstmt, 6, "c6", SQL_TINYINT, 3, 4, 0, SQL_NULLABLE); + desc_col_check(hstmt, 7, "c7", SQL_SMALLINT, 5, 6, 0, SQL_NULLABLE); + desc_col_check(hstmt, 8, "c8", SQL_DECIMAL, 4, 4, 2, SQL_NULLABLE); + desc_col_check(hstmt, 9, "c9", SQL_DOUBLE, 22, 24, 31, SQL_NULLABLE); + desc_col_check(hstmt, 10, "c10", SQL_REAL, 12, 24, 31, SQL_NULLABLE); + desc_col_check(hstmt, 11, "c11", SQL_BIGINT, 19, 19, 0, SQL_NO_NULLS); + desc_col_check(hstmt, 12, "c12", SQL_VARBINARY, 12, 12, 0, SQL_NULLABLE); + desc_col_check(hstmt, 13, "c13", SQL_VARCHAR, 20, 20, 0, SQL_NO_NULLS); + desc_col_check(hstmt, 14, "c14", SQL_REAL, 10, 24, 3, SQL_NULLABLE); + desc_col_check(hstmt, 15, "c15", SQL_LONGVARCHAR, 255, 255, 0, SQL_NULLABLE); + desc_col_check(hstmt, 16, "c16", SQL_LONGVARCHAR, 65535, 65535, 0, SQL_NULLABLE); + desc_col_check(hstmt, 17, "c17", SQL_LONGVARCHAR, 16777215, 16777215, 0, SQL_NULLABLE); + desc_col_check(hstmt, 18, "c18", SQL_LONGVARCHAR, 4294967295 , 16777215 , 0, SQL_NULLABLE); + desc_col_check(hstmt, 19, "c19", SQL_LONGVARBINARY, 255, 255, 0, SQL_NULLABLE); + desc_col_check(hstmt, 20, "c20", SQL_LONGVARBINARY, 65535, 65535, 0, SQL_NULLABLE); + desc_col_check(hstmt, 21, "c21", SQL_LONGVARBINARY, 16777215, 16777215, 0, SQL_NULLABLE); + desc_col_check(hstmt, 22, "c22", SQL_LONGVARBINARY, 4294967295 , 16777215 , 0, SQL_NULLABLE); + desc_col_check(hstmt, 23, "c23", SQL_LONGVARBINARY, 255, 5, 0, SQL_NULLABLE); + + SQLFreeStmt(hstmt,SQL_CLOSE); +} + +/* + Test for a simple SQLPutData and SQLParamData handling + bug #1316 +*/ + +static void t_putdata3(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + char buffer[]= "MySQL - The worlds's most popular open source database"; + SQLRETURN rc; + const int MAX_PART_SIZE = 5; + + char *pdata= 0, data[50]; + int dynData; + int commonLen= 20; + + SQLINTEGER id, id1, id2, id3, resId; + SQLINTEGER resUTimeSec; + SQLINTEGER resUTimeMSec; + SQLINTEGER resDataLen; + SQLINTEGER resData; + + + myheader("t_putdata3"); + + + SQLExecDirect(hstmt,"drop table t_putdata3",SQL_NTS); + rc = SQLExecDirect(hstmt,"CREATE TABLE t_putdata3 ( id INT, id1 INT, \ + id2 INT, id3 INT, pdata blob);",SQL_NTS); + mystmt(hstmt,rc); + + dynData = 1; + + rc = SQLPrepare(hstmt, "INSERT INTO t_putdata3 VALUES ( ?, ?, ?, ?, ? )", SQL_NTS); + mystmt(hstmt,rc); + + id= 1, id1= 2, id2= 3, id3= 4; + resId = 0; + resUTimeSec = 0; + resUTimeMSec = 0; + resDataLen = 0; + resData = SQL_LEN_DATA_AT_EXEC(0); + + rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_SLONG, + SQL_INTEGER, 0, 0, &id, 0, &resId); + mystmt(hstmt,rc); + + rc = SQLBindParameter(hstmt, 2, SQL_PARAM_INPUT, SQL_C_SLONG, + SQL_INTEGER, 0, 0, &id1, 0, &resUTimeSec); + mystmt(hstmt,rc); + + rc = SQLBindParameter(hstmt, 3, SQL_PARAM_INPUT, SQL_C_SLONG, + SQL_INTEGER, 0, 0, &id2, 0, &resUTimeMSec); + mystmt(hstmt,rc); + + rc = SQLBindParameter(hstmt, 4, SQL_PARAM_INPUT, SQL_C_SLONG, + SQL_INTEGER, 0, 0, &id3, 0, + &resDataLen); + mystmt(hstmt,rc); + + rc = SQLBindParameter(hstmt, 5, SQL_PARAM_INPUT, + SQL_C_BINARY, SQL_LONGVARBINARY, 10, 10, + dynData ? (SQLPOINTER)5 : + pdata, 0, &resData); + mystmt(hstmt,rc); + + rc = SQLExecute(hstmt); + if (rc == SQL_NEED_DATA) + { + int parameter; + if (SQLParamData(hstmt,(void**)¶meter) == SQL_NEED_DATA && parameter == 5) + { + int len = 0; + int partsize; + + /* storing long data by parts */ + while (len < commonLen) + { + partsize = commonLen - len; + if (partsize > MAX_PART_SIZE) + partsize = MAX_PART_SIZE; + + rc = SQLPutData(hstmt, buffer+len, partsize); + mystmt(hstmt,rc); + len += partsize; + } + if (SQLParamData(hstmt,(void**)¶meter) == SQL_ERROR) + { + + } + } + } /* end if (rc == SQL_NEED_DATA) */ + + SQLFreeStmt(hstmt, SQL_UNBIND); + SQLFreeStmt(hstmt, SQL_CLOSE); + + if (mysql_min_version(hdbc, "4.0", 3)) + { + rc = tmysql_exec(hstmt,"select id, id1, id2, id3, convert(pdata,char) from t_putdata3"); + mystmt(hstmt,rc); + + rc = SQLFetch(hstmt); + + my_assert(1 == my_fetch_int(hstmt,1)); + my_assert(2 == my_fetch_int(hstmt,2)); + my_assert(3 == my_fetch_int(hstmt,3)); + my_assert(4 == my_fetch_int(hstmt,4)); + + my_assert(strncmp(buffer, my_fetch_str(hstmt,data,5), commonLen) == 0); + } + else + { + rc = tmysql_exec(hstmt,"select id, id1, id2, id3, pdata from t_putdata3"); + mystmt(hstmt,rc); + + rc = SQLFetch(hstmt); + + my_assert(1 == my_fetch_int(hstmt,1)); + my_assert(2 == my_fetch_int(hstmt,2)); + my_assert(3 == my_fetch_int(hstmt,3)); + my_assert(4 == my_fetch_int(hstmt,4)); + my_assert(strncmp("4D7953514C202D2054686520776F726C64732773", + my_fetch_str(hstmt,data,5), commonLen) == 0); + } + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + /* + output: + + ###################################### + t_putdata3 + ###################################### + my_fetch_int: 1 + my_fetch_int: 2 + my_fetch_int: 3 + my_fetch_int: 4 + my_fetch_str: MySQL - The worlds's(20) + */ +} + +/* + Test for misc CONVERT + bug #1082 +*/ +static void t_convert(SQLHDBC hdbc, SQLHSTMT hstmt) +{ + SQLRETURN rc; + SQLINTEGER data_len; + SQLCHAR data[50]; + + myheader("t_convert"); + + tmysql_exec(hstmt,"drop table t_convert"); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = tmysql_exec(hstmt,"CREATE TABLE t_convert(testing tinytext)"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"INSERT INTO t_convert VALUES('record1')"); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"INSERT INTO t_convert VALUES('record2')"); + mystmt(hstmt,rc); + + rc = SQLTransact(NULL,hdbc,SQL_COMMIT); + mycon(hdbc,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); + + rc = tmysql_exec(hstmt,"SELECT CONCAT(testing, '-must be string') FROM t_convert ORDER BY RAND()"); + mystmt(hstmt,rc); + + rc = SQLBindCol(hstmt,1,SQL_C_CHAR, &data, 100, &data_len); + mystmt(hstmt,rc); + + rc = SQLFetch(hstmt); + mystmt(hstmt,rc); + myassert(strcmp(data,"record1-must be string") == 0 || + strcmp(data,"record2-must be string") == 0); + + rc = SQLFetch(hstmt); + mystmt(hstmt,rc); + myassert(strcmp(data,"record1-must be string") == 0 || + strcmp(data,"record2-must be string") == 0); + + rc = SQLFetch(hstmt); + myassert( rc == SQL_NO_DATA); + + rc = SQLFreeStmt(hstmt,SQL_UNBIND); + mystmt(hstmt,rc); + + rc = SQLFreeStmt(hstmt,SQL_CLOSE); + mystmt(hstmt,rc); +} + +/** + mytest rountine to control individual tests +*/ +static void mytest(int tno, SQLHENV henv, SQLHDBC hdbc, SQLHSTMT hstmt) +{ + if( tno == 1 || tno == -1) /* basic and general */ + { + t_basic(hdbc, hstmt); + t_error(hdbc,hstmt); + } + + if( (tno == 2 || tno == -1) && driver_supports_setpos(hdbc)) + { + /* sqlsetpos */ + t_pos_datetime_delete(hdbc,hstmt); + t_pos_datetime_delete1(hdbc,hstmt); + t_setpos_upd_decimal(hdbc,hstmt); + t_pos_column_ignore(hdbc,hstmt); + my_setpos_upd_pk_order(hdbc,hstmt); + my_setpos_upd_pk_order1(hdbc,hstmt); + t_mul_pkdel(hdbc,hstmt); + t_mul_pkdel1(hdbc,hstmt); + tmysql_setpos_pkdel(hdbc,hstmt); + tmysql_setpos_pkdel1(hdbc,hstmt); + tmysql_setpos_pkdel2(hdbc,hstmt); + tmysql_setpos_pkdel3(hdbc,hstmt); + tmysql_setpos_del(hdbc,hstmt); + tmysql_setpos_del1(hdbc,hstmt); + tmysql_setpos_upd(hdbc,hstmt); + tmysql_mtab_setpos_del(hdbc,hstmt); + t_alias_setpos_pkdel(hdbc,hstmt); + t_setpos_position(hdbc,hstmt); + t_pos_column_ignore(hdbc,hstmt); + t_setpos_del_all(hdbc,hstmt); + t_refresh(hdbc,hstmt); + t_empty_str_bug(hdbc, hstmt); + +#if DONT_WORK + t_alias_setpos_del(hdbc,hstmt); /* can't work until 4.1 supports aliases in FIELDS */ +#endif + } + if( (tno == 3 || tno == -1) && driver_supports_setpos(hdbc)) + { + /* positioned updates and deletes */ + tmysql_pos_delete(hdbc,hstmt); + tmysql_pos_update(hdbc,hstmt); /* it doesn't work with 4.1 */ + tmysql_pos_update_ex(hdbc,hstmt); + tmysql_pos_update_ex1(hdbc,hstmt); + tmysql_pos_update_ex2(hdbc,hstmt); + tmysql_pos_update_ex3(hdbc,hstmt); + t_acc_crash(hdbc,hstmt); + tmysql_pcbvalue(hdbc,hstmt); + } + if( tno == 4 || tno == -1) /* catalogs */ + { + tmysql_specialcols(hdbc, hstmt); + } + if( tno == 5 || tno == -1) /* transaction */ + { + t_tran(hdbc,hstmt); + } + if( tno == 6 || tno == -1) /* keys */ + { + tmysql_showkeys(hdbc,hstmt); + } + if( tno == 7 || tno == -1) /* param binding */ + { +#if 0 + t_desc_param(hdbc,hstmt); +#endif + } + if( tno == 8 || tno == -1) /* row binding */ + { + tmysql_bindcol(hdbc,hstmt); + } + if( tno == 9 || tno == -1) /* conversion */ + { + t_convert(hdbc, hstmt); + t_tstotime(hdbc,hstmt); + t_tstotime1(hdbc,hstmt); + } + if( tno == 10 || tno == -1) /* type checking */ + { + t_longlong1(hdbc,hstmt); + t_bigint(hdbc,hstmt); + t_enumset(hdbc,hstmt); + t_gettypeinfo(hdbc,hstmt); + t_getinfo(hdbc); + } + if( tno == 12 || tno == -1) /* myodbc3 tests */ + { + t_putdata3(hdbc, hstmt); + t_time1(hdbc,hstmt); +#if 0 + t_blob_bug(hdbc,hstmt); /* TO BE FIXED IN DEBUG MODE */ +#endif + t_putdata(hdbc,hstmt); + t_putdata1(hdbc,hstmt); + t_putdata2(hdbc,hstmt); + t_tables_bug(hdbc,hstmt); /* To be fixed in 3.52 */ + t_convert_type(henv,hdbc,hstmt); + t_columns(hdbc,hstmt); + t_multistep(hdbc,hstmt); + t_warning(hdbc,hstmt); + t_scroll(hdbc,hstmt); + t_getcursor(hdbc); + t_getcursor1(hdbc); + t_prepare(hdbc,hstmt); + t_prepare1(hdbc,hstmt); + t_msdev_bug(hdbc,hstmt); + t_time(hdbc,hstmt); + t_diagrec(henv,hdbc,hstmt); + t_decimal(hdbc,hstmt); + t_numeric(hdbc,hstmt); + t_zerolength(hdbc,hstmt); + t_odbc3_envattr(); + t_odbc3_handle(); + t_text_fetch(hdbc,hstmt); + t_non_cache_bug(hdbc,hstmt); + t_cache_bug(); + + } + if( tno == 13 || tno == -1) /* stmt attributes */ + { + t_desc_col(hdbc, hstmt); + t_max_rows(hdbc,hstmt); + t_stmt_attr_status(hdbc,hstmt); + t_rows_fetched_ptr(hdbc, hstmt); + t_rows_fetched_ptr1(hdbc, hstmt); + t_row_array_size(hdbc, hstmt); + t_current_catalog(hdbc, hstmt); + } + if( tno == 11 || tno == -1) /* limit tests */ + { + t_max_select(hdbc,hstmt); + t_max_con(hstmt); + } +} + + +/** + main routine to control all tests +*/ +int main(int argc, char *argv[]) +{ + SQLHENV henv; + SQLHDBC hdbc; + SQLHSTMT hstmt; + SQLINTEGER narg, tno = -1; + + /* + * show the usage string when the user asks for this + */ + if (argc < 2 || ( argc == 2 && ((!strcmp (argv[1], "-?") || + !strcmp (argv[1], "--?") || + !strcmp (argv[1], "--h") || + !strcmp (argv[1], "--help") + )) + ) || argc > 5 + ) + { + fprintf(stdout,"------------------------------------------\n"); + fprintf(stdout,"usage: mytest3 testno [DSN] [UID] [PWD] \n\n"); + fprintf(stdout," testno <-- test number\n"); + fprintf(stdout," DSN <-- data source name\n"); + fprintf(stdout," UID <-- user name\n"); + fprintf(stdout," PWD <-- password\n"); + + fprintf(stdout,"\ntestno:\n"); + fprintf(stdout," -1 : all\n"); + fprintf(stdout," 1 : basic, general\n"); + fprintf(stdout," 2 : sqlsetpos\n"); + fprintf(stdout," 3 : positioned update/delete\n"); + fprintf(stdout," 4 : catalog\n"); + fprintf(stdout," 5 : transaction\n"); + fprintf(stdout," 6 : keys\n"); + fprintf(stdout," 7 : param binding\n"); + fprintf(stdout," 8 : row binding\n"); + fprintf(stdout," 9 : type conversion\n"); + fprintf(stdout," 10 : data types\n"); + fprintf(stdout," 11 : limit \n"); + fprintf(stdout," 12 : myodbc3 \n"); + fprintf(stdout," 13 : stmt attributes \n"); + fprintf(stdout,"------------------------------------------\n"); + exit(0); + } + + /* + * if connection string supplied through arguments, overrite + * the default one.. + */ + for(narg = 1; narg < argc; narg++) + { + if ( narg == 1 ) + tno = atoi(argv[1]); + else if ( narg == 2 ) + mydsn = argv[2]; + else if ( narg == 3 ) + myuid = argv[3]; + else if ( narg == 4 ) + mypwd = argv[4]; + + } + + myconnect(&henv,&hdbc,&hstmt); + mytest(tno,henv,hdbc,hstmt); + mydisconnect(&henv,&hdbc,&hstmt); + + fprintf(stdout,"\n\n-- test-end --\n"); + return(0); +} + + + + --- myodbc-3.51.15r409.orig/test/include/mytest3.h +++ myodbc-3.51.15r409/test/include/mytest3.h @@ -31,6 +31,7 @@ /* STANDARD C HEADERS */ #include #include +#include #include #include --- myodbc-3.51.15r409.orig/test/include/odbctap.h +++ myodbc-3.51.15r409/test/include/odbctap.h @@ -31,6 +31,7 @@ #include "mytest3.h" #include +#include #ifndef WIN32 #include #endif --- myodbc-3.51.15r409.orig/scripts/makerpm +++ myodbc-3.51.15r409/scripts/makerpm @@ -0,0 +1,101 @@ +#!/bin/sh + +# +# Configure function +# + +function configure_driver +{ + aclocal; autoheader; aclocal; automake; autoconf + ./configure \ + --prefix=${RPM_BUILD_ROOT}%{prefix} \ + --with-mysql-libs=%{MYSQL_LIBS} \ + --with-mysql-includes=%{MYSQL_INCLUDES} \ + ${ODBC_DM_PATH} \ + --enable-thread-safe \ + --enable-shared=yes \ + --enable-static=yes \ + --without-debug \ + --without-docs \ + --without-samples + make dist; +} + +# +# MyODBC 3.51 rpm build script +# + +RELEASE=3.51.09 +SPEC_FILE=myodbc-3.51.09.spec +ARCH=`uname -m | perl -p -e 's/i[0-9]{3}/i386/'` +SOURCE=MyODBC + +# +# This script must run from MyODBC top directory +# + +if [ ! -f "./driver/myodbc3.c" ]; +then + echo "ERROR : You must run this script from the MyODBC top-level directory" + exit 1 +fi + +ODBC_DM_PATH="--with-unixODBC=/usr" +MYSQL_LIBS="@MYSQL_USED_LIB_PATH@" +MYSQL_INCLUDES="@MYSQL_USED_INCLUDE_PATH@" +MyODBC_ROOT=`pwd` + +# +# Find the RPM build area +# + +if [ -d /usr/src/redhat ] +then + RPM_BUILD_AREA=/usr/src/redhat +else if [ -d /usr/src/packages ] +then + RPM_BUILD_AREA=/usr/src/packages +fi +fi + +# +# setup the src tar ball +# + +SRC_FILE=$SOURCE-${RELEASE} +SRC_TAR_ARCH=$SRC_FILE.tar.gz + +if [ ! -f "$SRC_TAR_ARCH" ]; +then + echo "Tarball file '$SRC_TAR_ARCH' does not exist, please make one first" + exit 1 +fi + +if [ ! -f "./scripts/${SPEC_FILE}" ]; +then + echo "Spec file '${SPEC_FILE}' does not exist, please make one first" + exit 1 +fi + +echo "Building RPM for MyODBC version ${RELEASE}" + +cp ./scripts/${SPEC_FILE} ${RPM_BUILD_AREA}/SPECS/ +cp $SRC_TAR_ARCH ${RPM_BUILD_AREA}/SOURCES/ + +cd ${RPM_BUILD_AREA}/SPECS + +# +# Generate RPMs +# + +echo "Running the spec file from '${RPM_BUILD_AREA}/SPECS'" + +rpm -ba ${SPEC_FILE} +if test $? -eq 0 +then + ln -s ${RPM_BUILD_AREA}/RPMS/${ARCH}/$SRC_FILE-1.${ARCH}.rpm $SRC_FILE-1.${ARCH}.rpm + ln -s ${RPM_BUILD_AREA}/SRPMS/$SRC_FILE-1.src.rpm $SRC_FILE-1.src.rpm +else + echo "ERROR: rpm build failed for '$SRC_FILE'" +fi + --- myodbc-3.51.15r409.orig/dltest/dltest.c +++ myodbc-3.51.15r409/dltest/dltest.c @@ -1,5 +1,6 @@ #include #include +#include #ifdef WIN32 #include --- myodbc-3.51.15r409.orig/Docs/Makefile +++ myodbc-3.51.15r409/Docs/Makefile @@ -0,0 +1,562 @@ +# Makefile.in generated by automake 1.7.6 from Makefile.am. +# Docs/Makefile. Generated from Makefile.in by configure. + +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 +# Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + + +########################################################################## +# Copyright (C) 1995-2002 MySQL AB, www.mysql.com # +# # +# This program is free software; you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation; either version 2 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program; if not, write to the Free Software Foundation # +# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +########################################################################## + +########################################################################## +# # +# Makefile.am # +# # +# @description: This is the MyODBC 3.51 driver(Docs) Makefile.am # +# # +# @author : MySQL AB (monty@mysql.com, venu@mysql.com) # +# @date : 2002-10-30 # +# @product : myodbc3 # +# # +########################################################################## +# Normally you do not need to remake the files here. But if you want +# to you will need the GNU TeX-info utilities. To make a Postscript +# files you also need TeX and dvips. To make the PDF file you will +# need pdftex. We use the teTeX distribution for all of these. + +# We avoid default automake rules because of problems with .dvi file +# and BSD makes + +# If you know how to fix any of this more elegantly please mail +# docs@mysql.com + +srcdir = . +top_srcdir = .. + +pkgdatadir = $(datadir)/MyODBC +pkglibdir = $(libdir)/MyODBC +pkgincludedir = $(includedir)/MyODBC +top_builddir = .. + +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = /usr/bin/install -c +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = i386-pc-linux +host_triplet = i386-pc-linux +target_triplet = i386-pc-linux +ACLOCAL = ${SHELL} /home/devel/myodbc/MyODBC-3.51.09/missing --run aclocal-1.7 +AMDEP_FALSE = # +AMDEP_TRUE = +AMTAR = ${SHELL} /home/devel/myodbc/MyODBC-3.51.09/missing --run tar +AR = ar +AS = i386-linux-gcc -c +AUTOCONF = ${SHELL} /home/devel/myodbc/MyODBC-3.51.09/missing --run autoconf +AUTOHEADER = ${SHELL} /home/devel/myodbc/MyODBC-3.51.09/missing --run autoheader +AUTOMAKE = ${SHELL} /home/devel/myodbc/MyODBC-3.51.09/missing --run automake-1.7 +AWK = gawk +CC = i386-linux-gcc +CCDEPMODE = depmode=gcc3 +CFLAGS = -O3 -DDBUG_OFF -g -Wall -O2 -I/usr/include/mysql -DBIG_JOINS=1 +CONF_COMMAND = ./configure '--build=i386-linux' '--host=i386-linux' '--prefix=/usr' '--enable-shared' '--enable-thread-safe' '--with-unixODBC=/usr' '--with-mysql-libs=/usr/lib' '--with-mysql-includes=/usr/include/mysql' 'CFLAGS=-g -Wall -O2' 'CPPFLAGS=-D_REENTRANT' 'build_alias=i386-linux' 'host_alias=i386-linux' +CPP = i386-linux-gcc -E +CPPFLAGS = -D_REENTRANT -I/usr/include +CXX = i386-linux-g++ +CXXCPP = i386-linux-g++ -E +CXXDEPMODE = depmode=gcc3 +CXXFLAGS = -g -O2 +CYGPATH_W = echo +DEFS = -DHAVE_CONFIG_H +DEPDIR = .deps +ECHO = echo +ECHO_C = +ECHO_N = -n +ECHO_T = +EGREP = grep -E +EXEEXT = +EXTRA_LDFLAGS = +F77 = i386-linux-g77 +FFLAGS = -g -O2 +INSTALL_DATA = ${INSTALL} -m 644 +INSTALL_PROGRAM = ${INSTALL} +INSTALL_SCRIPT = ${INSTALL} +INSTALL_STRIP_PROGRAM = ${SHELL} $(install_sh) -c -s +LD = /usr/bin/ld +LDFLAGS = +LIBOBJS = +LIBS = -L/usr/lib -lz -lodbcinst +LIBTOOL = $(SHELL) $(top_builddir)/libtool +LN_S = ln -s +LTLIBOBJS = +MACHINE_TYPE = i386 +MAKEINFO = ${SHELL} /home/devel/myodbc/MyODBC-3.51.09/missing --run makeinfo +MYSQL_LIB = -L/usr/lib -lmysqlclient -lz -lcrypt -lnsl -lm +MYSQL_THREADSAFE_LIB = -L/usr/lib -lmysqlclient_r -lpthread -lz -lcrypt -lnsl -lm -lpthread +OBJEXT = o +ODBC_DM_PATH = --with-unixODBC=/usr +PACKAGE = MyODBC +PACKAGE_BUGREPORT = +PACKAGE_NAME = +PACKAGE_STRING = +PACKAGE_TARNAME = +PACKAGE_VERSION = +PATH_SEPARATOR = : +PERL = /usr/bin/perl +PERL5 = /usr/bin/perl +RANLIB = ranlib +SAVE_CFLAGS = -g -Wall -O2 +SAVE_LDFLAGS = +SET_MAKE = +SHELL = /bin/sh +STRIP = strip +SYSTEM_TYPE = pc-linux +VERSION = 3.51.09 +ac_ct_AR = ar +ac_ct_CC = +ac_ct_CXX = +ac_ct_F77 = +ac_ct_RANLIB = ranlib +ac_ct_STRIP = strip +am__fastdepCC_FALSE = # +am__fastdepCC_TRUE = +am__fastdepCXX_FALSE = # +am__fastdepCXX_TRUE = +am__include = include +am__leading_dot = . +am__quote = +bindir = ${exec_prefix}/bin +build = i386-pc-linux +build_alias = i386-linux +build_cpu = i386 +build_os = linux +build_vendor = pc +datadir = ${prefix}/share +exec_prefix = ${prefix} +host = i386-pc-linux +host_alias = i386-linux +host_cpu = i386 +host_os = linux +host_vendor = pc +includedir = ${prefix}/include +infodir = ${prefix}/info +install_sh = /home/devel/myodbc/MyODBC-3.51.09/install-sh +iodbc_conf = +isql = /usr/bin/isql +libdir = ${exec_prefix}/lib +libexecdir = ${exec_prefix}/libexec +localstatedir = ${prefix}/var +mandir = ${prefix}/man +myodbc_docs_dir = +myodbc_samples_dir = samples +myodbc_test_dir = test +myodbc_test_linklib = ../driver_r/libmyodbc3_r.la +myodbc_thread_dir = driver_r +myodbc_version = 3.51.09 +oldincludedir = /usr/include +prefix = /usr +program_transform_name = s,x,x, +sbindir = ${exec_prefix}/sbin +sharedstatedir = ${prefix}/com +sysconfdir = ${prefix}/etc +target = i386-pc-linux +target_alias = +target_cpu = i386 +target_os = linux +target_vendor = pc +uname_prog = /bin/uname + +TEXI2HTML_FLAGS = -iso -number +DVIPS = dvips +TEXINFO_TEX = Support/texinfo.tex + +noinst_SCRIPTS = Support/texi2html +info_TEXINFOS = manual.texi + +targets = manual.html faq.html + +BUILT_SOURCES = $(targets) manual_toc.html faq_toc.html include.texi + +# The PostScript and PDF version are so big that they are not included in the +# standard distribution. It is available for download from the home page. +PDFMANUAL = manual.pdf faq.pdf +subdir = Docs +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/driver/myconf.h +CONFIG_CLEAN_FILES = +SCRIPTS = $(noinst_SCRIPTS) + +DIST_SOURCES = +am__TEXINFO_TEX_DIR = $(srcdir)/Support +INFO_DEPS = manual.info +DVIS = manual.dvi +PDFS = manual.pdf +PSS = manual.ps +TEXINFOS = manual.texi +DIST_COMMON = Makefile.am Makefile.in +all: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) all-am + +.SUFFIXES: +.SUFFIXES: .dvi .info .pdf .ps .texi +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu Docs/Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe) + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool + +.texi.info: + @rm -f $@ $@-[0-9] $@-[0-9][0-9] $(@:.info=).i[0-9] $(@:.info=).i[0-9][0-9] + $(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) \ + -o $@ `test -f '$<' || echo '$(srcdir)/'`$< + +.texi.dvi: + TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \ + MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir)' \ + $(TEXI2DVI) `test -f '$<' || echo '$(srcdir)/'`$< + +.texi.pdf: + TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \ + MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir)' \ + $(TEXI2PDF) `test -f '$<' || echo '$(srcdir)/'`$< +manual.dvi: manual.texi +TEXI2DVI = texi2dvi + +TEXI2PDF = $(TEXI2DVI) --pdf --batch +.dvi.ps: + $(DVIPS) -o $@ $< + +uninstall-info-am: + $(PRE_UNINSTALL) + @if (install-info --version && \ + install-info --version | grep -i -v debian) >/dev/null 2>&1; then \ + list='$(INFO_DEPS)'; \ + for file in $$list; do \ + relfile=`echo "$$file" | sed 's|^.*/||'`; \ + echo " install-info --info-dir=$(DESTDIR)$(infodir) --remove $(DESTDIR)$(infodir)/$$relfile"; \ + install-info --info-dir=$(DESTDIR)$(infodir) --remove $(DESTDIR)$(infodir)/$$relfile; \ + done; \ + else :; fi + @$(NORMAL_UNINSTALL) + @list='$(INFO_DEPS)'; \ + for file in $$list; do \ + relfile=`echo "$$file" | sed 's|^.*/||'`; \ + relfile_i=`echo "$$relfile" | sed 's|\.info$$||;s|$$|.i|'`; \ + (if cd $(DESTDIR)$(infodir); then \ + echo " rm -f $$relfile $$relfile-[0-9] $$relfile-[0-9][0-9] $$relfile_i[0-9] $$relfile_i[0-9][0-9])"; \ + rm -f $$relfile $$relfile-[0-9] $$relfile-[0-9][0-9] $$relfile_i[0-9] $$relfile_i[0-9][0-9]; \ + else :; fi); \ + done + +dist-info: $(INFO_DEPS) + list='$(INFO_DEPS)'; \ + for base in $$list; do \ + if test -f $$base; then d=.; else d=$(srcdir); fi; \ + for file in $$d/$$base*; do \ + relfile=`expr "$$file" : "$$d/\(.*\)"`; \ + test -f $(distdir)/$$relfile || \ + cp -p $$file $(distdir)/$$relfile; \ + done; \ + done + +mostlyclean-aminfo: + -rm -f manual.aux manual.cp manual.cps manual.fn manual.fns manual.ky \ + manual.kys manual.log manual.pg manual.pgs manual.tmp \ + manual.toc manual.tp manual.tps manual.vr manual.vrs \ + manual.dvi manual.pdf manual.ps + +maintainer-clean-aminfo: + @list='$(INFO_DEPS)'; for i in $$list; do \ + i_i=`echo "$$i" | sed 's|\.info$$||;s|$$|.i|'`; \ + echo " rm -f $$i $$i-[0-9] $$i-[0-9][0-9] $$i_i[0-9] $$i_i[0-9][0-9]"; \ + rm -f $$i $$i-[0-9] $$i-[0-9][0-9] $$i_i[0-9] $$i_i[0-9][0-9]; \ + done +tags: TAGS +TAGS: + +ctags: CTAGS +CTAGS: + +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) + +top_distdir = .. +distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkinstalldirs) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$(top_distdir)" distdir="$(distdir)" \ + dist-info +check-am: all-am +check: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) check-am +all-am: Makefile $(INFO_DEPS) $(SCRIPTS) + +installdirs: + $(mkinstalldirs) $(DESTDIR)$(infodir) +install: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) +clean: clean-am + +clean-am: clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + +distclean-am: clean-am distclean-generic distclean-libtool + +dvi: dvi-am + +dvi-am: $(DVIS) + +info: info-am + +info-am: $(INFO_DEPS) + +install-data-am: install-info-am + +install-exec-am: + +install-info: install-info-am + +install-info-am: $(INFO_DEPS) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(infodir) + @list='$(INFO_DEPS)'; \ + for file in $$list; do \ + if test -f $$file; then d=.; else d=$(srcdir); fi; \ + file_i=`echo "$$file" | sed 's|\.info$$||;s|$$|.i|'`; \ + for ifile in $$d/$$file $$d/$$file-[0-9] $$d/$$file-[0-9][0-9] \ + $$d/$$file_i[0-9] $$d/$$file_i[0-9][0-9] ; do \ + if test -f $$ifile; then \ + relfile=`echo "$$ifile" | sed 's|^.*/||'`; \ + echo " $(INSTALL_DATA) $$ifile $(DESTDIR)$(infodir)/$$relfile"; \ + $(INSTALL_DATA) $$ifile $(DESTDIR)$(infodir)/$$relfile; \ + else : ; fi; \ + done; \ + done + @$(POST_INSTALL) + @if (install-info --version && \ + install-info --version | grep -i -v debian) >/dev/null 2>&1; then \ + list='$(INFO_DEPS)'; \ + for file in $$list; do \ + relfile=`echo "$$file" | sed 's|^.*/||'`; \ + echo " install-info --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/$$relfile";\ + install-info --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/$$relfile || :;\ + done; \ + else : ; fi +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + +maintainer-clean-am: distclean-am maintainer-clean-aminfo \ + maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-aminfo mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: $(PDFS) + +ps: ps-am + +ps-am: $(PSS) + +uninstall-am: uninstall-info-am + +.PHONY: all all-am check check-am clean clean-generic clean-libtool \ + dist-info distclean distclean-generic distclean-libtool distdir \ + dvi dvi-am info info-am install install-am install-data \ + install-data-am install-exec install-exec-am install-info \ + install-info-am install-man install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-aminfo maintainer-clean-generic mostlyclean \ + mostlyclean-aminfo mostlyclean-generic mostlyclean-libtool pdf \ + pdf-am ps ps-am uninstall uninstall-am uninstall-info-am + +#EXTRA_DIST = $(noinst_SCRIPTS) $(BUILT_SOURCES) mysqld_error.txt \ +# INSTALL-BINARY mirrors.texi + +all: $(targets) #txt_files + +#txt_files: ../INSTALL-SOURCE ../COPYING ../COPYING.LIB \ +# ../MIRRORS INSTALL-BINARY + +CLEAN_FILES: $(BUILD_SOURCES) + touch $(BUILD_SOURCES) + rm -f manual_toc.html + rm -f manual.html + rm -f faq.html + rm -f faq_toc.html +paper: manual_a4.ps manual_letter.ps $(PDFMANUAL) + +######################################################################### + +# The Makefile contains the previous version so we can not use that +include.texi: ../configure.in + echo "@c This file is autogenerated by the Makefile" > $@ + echo -n "@set myodbc3_version " >> $@ + grep "AM_INIT_AUTOMAKE(MyODBC," ../configure.in | \ + sed -e 's;AM_INIT_AUTOMAKE(MyODBC,;;' -e 's;);;' >> $@ + +manual.info: manual.texi include.texi + cd $(srcdir) && $(MAKEINFO) --no-split -I $(srcdir) $< + +manual.txt: manual.texi include.texi + cd $(srcdir) && \ + $(MAKEINFO) -I $(srcdir) --no-headers --no-split --output $@ $< + +manual.html: manual.texi include.texi $(srcdir)/Support/texi2html + cd $(srcdir) && /usr/bin/perl $(srcdir)/Support/texi2html $(TEXI2HTML_FLAGS) $< + +manual_toc.html: manual.html + +faq.html: faq.texi include.texi $(srcdir)/Support/texi2html + cd $(srcdir) && /usr/bin/perl $(srcdir)/Support/texi2html $(TEXI2HTML_FLAGS) $< + +faq_toc.html: faq.html + +# Fix: add --output-comment with some interesting info? +# Fix: @image worked with a older version of pdftex. +# Note: @image will work if we first convert all images to pdf ... +# is that worth it? +# Comment: We need to run pdftex 2 times to get the cross references right. +manual.pdf: manual.texi + cat manual.texi | sed -e 's|@image{[^}]*} *||g' > manual-tmp.texi + pdftex --interaction=nonstopmode manual-tmp.texi + texindex manual-tmp.?? + pdftex --interaction=nonstopmode manual-tmp.texi + texindex manual-tmp.?? + pdftex --interaction=nonstopmode manual-tmp.texi + mv manual-tmp.pdf manual.pdf + rm -f manual-tmp.* + touch $@ +faq.pdf: faq.texi + cat faq.texi | sed -e 's|@image{[^}]*} *||g' > faq-tmp.texi + pdftex --interaction=nonstopmode faq-tmp.texi + texindex faq-tmp.?? + pdftex --interaction=nonstopmode faq-tmp.texi + texindex faq-tmp.?? + pdftex --interaction=nonstopmode faq-tmp.texi + mv faq-tmp.pdf faq.pdf + rm -f faq-tmp.* + touch $@ + +# The texi2dvi gives a lot of harmless errors. Just ignore them unless +# you want to help with the typesetting part. +# This is the European papersize version +manual_a4.ps: manual.texi include.texi + TEXINPUTS=$(srcdir):$$TEXINPUTS \ + MAKEINFO='$(MAKEINFO) -I $(srcdir)' \ + $(TEXI2DVI) --batch --texinfo --quiet '@afourpaper' $< + $(DVIPS) -t a4 manual.dvi -o $@ + touch $@ + +# This is the American papersize version +manual_letter.ps: manual.texi include.texi + TEXINPUTS=$(srcdir):$$TEXINPUTS \ + MAKEINFO='$(MAKEINFO) -I $(srcdir)' \ + $(TEXI2DVI) --batch $< + $(DVIPS) -t letter manual.dvi -o $@ + touch $@ + +# Don't update the files from bitkeeper +%::SCCS/s.% +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: --- myodbc-3.51.15r409.orig/debian/README.Maintainer +++ myodbc-3.51.15r409/debian/README.Maintainer @@ -0,0 +1,7 @@ +autoconf: + To get autoconf know that it should use v2.50 I had to rename configure.in + to configure.ac. +Versioning: + The shared lib is called libmyodbc2.20.30.so instead of libmyodbc.so.x.y.z + so a dynamic linked program would not know that libmyodbc2.20.32.so would + be acceptable, too. I complained the author! --- myodbc-3.51.15r409.orig/debian/README.Debian +++ myodbc-3.51.15r409/debian/README.Debian @@ -0,0 +1,8 @@ +MyODBC for Debian +---------------------- + +I decided to build no -dev package since it was already so small and +due to the strange version numbering system I expect the headers +not to stay compatible for another release. + + -- Christian Hammers , Sun, 17 Oct 1999 13:26:59 +0200 --- myodbc-3.51.15r409.orig/debian/libmyodbc.dirs +++ myodbc-3.51.15r409/debian/libmyodbc.dirs @@ -0,0 +1,2 @@ +usr/lib/odbc +usr/share/libmyodbc --- myodbc-3.51.15r409.orig/debian/changelog +++ myodbc-3.51.15r409/debian/changelog @@ -0,0 +1,309 @@ +myodbc (3.51.15r409-4) unstable; urgency=low + + * Remove a stray change to odbc.ini that snuck into the preceding upload. + + -- Steve Langasek Sat, 21 Jun 2008 22:17:55 -0700 + +myodbc (3.51.15r409-3) unstable; urgency=low + + * Add Galician debconf translation, thanks to Jacobo Tarrio + . Closes: #482833. + * Allow changing the odbcinst registration option with dpkg-reconfigure, + partially addressing bug #250850. + * Move the odbcinst removal handling from the postrm to the prerm, required + for idempotency in light of the above. + * Updated debian/watch for compatibility with the latest upstream + tarball naming scheme. Closes: #450376. + * Update to Standards-Version 3.8.0 (no changes required). + * Drop obsolete conflicts/replaces on packages that haven't existed + since woody or earlier. + * Update the FSF mailing address in debian/copyright. + * Add a proper copyright notice to debian/copyright. + + -- Steve Langasek Sat, 21 Jun 2008 22:03:35 -0700 + +myodbc (3.51.15r409-2) unstable; urgency=low + + * Fix debian/rules to not ignore errors from make clean or make + distclean. + * Bump debhelper compat to version 5 + * Add German debconf translation, thanks to Matthias Julius + and Helge Kreutzmann . + Closes: #397639. + * Add Finnish debconf translation, thanks to Esko Arajärvi + . Closes: #447072. + * Add Dutch debconf translation, thanks to Bart Cornelis + . Closes: #414765. + * Add Portuguese debconf translation, thanks to Américo Monteiro + . Closes: #434285. + * Add Spanish debconf translation, thanks to Manuel Porras Peralta + . Closes: #410044. + * Add Brazilian Portuguese debconf translation, thanks to Felipe + Augusto van de Wiel . + + -- Steve Langasek Fri, 26 Oct 2007 20:59:50 -0700 + +myodbc (3.51.15r409-1) unstable; urgency=low + + * New upstream release + - compatibility with mysql 5.0 protocol. Closes: #381671. + * Make use of debconf in the postrm conditional, to allow for the + possibility that debconf has been removed before libmyodbc. + Closes: #416903. + + -- Steve Langasek Thu, 28 Jun 2007 11:51:10 -0700 + +myodbc (3.51.11-6) unstable; urgency=low + + * Add Swedish debconf translation, thanks to Daniel Nylander + (closes: #331559). + * Rebuild against libmysqlclient15-dev, as libmysqlclient12 no longer + exists. Closes: #353997. + * Also rebuild against unixodbc-dev (>= 2.2.11-13), to pull in a small + ABI change on 64-bit archs that's been backported from 2.2.12. This + also requires a patch to driver/prepare.c. + * No longer specify extra build flags to request a 64-bit-clean ABI; + the headers from the unixodbc-dev package have been fixed to always + declare this for us. + + -- Steve Langasek Thu, 25 May 2006 15:14:40 -0700 + +myodbc (3.51.11-5) unstable; urgency=low + + * Use ${misc:Depends} instead of hard-coding a dependency on debconf, + for compatibility with cdebconf. + + -- Steve Langasek Fri, 5 Aug 2005 04:39:19 -0700 + +myodbc (3.51.11-4) unstable; urgency=low + + * Doesn't build cleanly with REAL_64_BIT_MODE: fix some conflicting + types in MyODBC so that they're 64-bittable. + + -- Steve Langasek Tue, 28 Jun 2005 16:07:14 -0700 + +myodbc (3.51.11-3) unstable; urgency=low + + * Rebuild against unixodbc 2.2.11. + * Set BUILD_REAL_64_BIT_MODE define for the benefit of 64-bit archs, + which seems to have been missed previously. + + -- Steve Langasek Fri, 17 Jun 2005 05:54:13 -0700 + +myodbc (3.51.11-2) unstable; urgency=low + + * Add missing header includes to fix 64-bit issues; thanks to Dann + Frazier for the patch (closes: #314165). + * Add a direct Build-Dependency on libltdl3-dev since we're using + headers from it, rather than relying on unixodbc-dev to pull it in + for us. + * Disable the Qt-based GUI setup library, unless someone asks for it + (it wasn't being used anyway, since we're specifying the unixodbc + setup lib in odbcinst.ini). + + -- Steve Langasek Wed, 15 Jun 2005 03:00:04 -0700 + +myodbc (3.51.11-1) unstable; urgency=low + + * New upstream release + * Add debian/watch to keep more easily in sync with upstream + * Add Vietnamese debconf translation, thanks to Clytie Siddall + (closes: #312997). + + -- Steve Langasek Mon, 13 Jun 2005 20:04:16 -0700 + +myodbc (3.51.09-1) unstable; urgency=low + + * New upstream release + - includes compatibility with newer versions of MySQL servers + (closes: #274879). + * Build-Depend on libmysqclient12-dev instead of on + libmysqlclient10-dev, required by the new upstream version + (closes: #245231). + * Update debian/rules to honor DEB_BUILD_OPTIONS and turn on -g by + default, bringing us in line with Standards-Version 3.6.1. + * Add Japanese debconf translation, thanks to Hideki Yamane + (closes: #237175). + * Add Czech debconf translation, thanks to Miroslav Kure + (closes: #283221). + + -- Steve Langasek Wed, 9 Mar 2005 14:13:36 -0800 + +myodbc (3.51.06-1) unstable; urgency=low + + * New upstream release (closes: #149461). + * Add French debconf translations, thanks to Clément Stenac + (closes: #232839). + + -- Steve Langasek Sun, 15 Feb 2004 14:59:29 -0600 + +myodbc (2.50.39-6) unstable; urgency=low + + * Change to using po-debconf for debconf template translations. + * Provide a more verbose package description (closes: #209878). + * Remove build-depends on autotools. + * Fix --host and --build options passed to configure in ./debian/rules. + + -- Steve Langasek Sat, 7 Feb 2004 17:52:11 -0600 + +myodbc (2.50.39-5) unstable; urgency=low + + * Build-dep on autoconf and call 'autoconf' instead of 'autoconf2.50', + so that autobuilders know what to do with us again (closes: #162725) + + -- Steve Langasek Sun, 29 Sep 2002 00:39:27 -0500 + +myodbc (2.50.39-4) unstable; urgency=low + + * make sure our examples set a good example (closes: #162005) + + -- Steve Langasek Mon, 23 Sep 2002 21:42:58 -0500 + +myodbc (2.50.39-3) unstable; urgency=low + + * Merge in Russian debconf templates, thanks to Ilgiz Kalmetev + . (Closes: #137671) + + -- Steve Langasek Sun, 10 Mar 2002 12:53:20 -0600 + +myodbc (2.50.39-2) unstable; urgency=medium + + * db_stop was being called too early in the postrm script, and broke + things Badly. Move to the end of the script. (Closes: #136274). + + -- Steve Langasek Fri, 1 Mar 2002 14:42:41 -0600 + +myodbc (2.50.39-1) unstable; urgency=low + + * New upstream release + * Add a package relationship for unixodbc | libiodbc2. + + -- Steve Langasek Sun, 24 Feb 2002 23:01:06 -0600 + +myodbc (2.50.37-7) unstable; urgency=low + + * Admit that static linking was a bad idea. Switch back to using + dynamic linking, now that there's a separate odbcinst package. + Build-depend appropriately. + + -- Steve Langasek Mon, 14 Jan 2002 21:06:04 -0600 + +myodbc (2.50.37-6) unstable; urgency=low + + * Change package name: myodbc is a plugin, not a normal shared + library, and versioned package names are an inconvenience. + * Likewise, disable building of static libs, and remove header files + from the package, since nothing uses them. + * Move .so file to /usr/lib/odbc, and remove dh_makeshlibs reference. + * Fix aclocal.m4 to look for $ac_header instead of $ac_hdr, since + the name has changed w/ autoconf 2.5. Fixes build on arm, ia64, + hppa, and mips, at least. + * Remove --with-odbc-ini argument to configure, only needed when using + the internal ini-file handling. + * Oh, and while we're at it, add support to debian/rules for + cross-compiling packages. + + -- Steve Langasek Mon, 7 Jan 2002 19:18:32 -0600 + +myodbc2.50.37 (2.50.37-5) unstable; urgency=low + + * New maintainer + * Change package to build against unixodbc-dev instead of libiodbc2-dev, + fixes ABI problems on Alpha platform. + * Force static linking against libodbcinst, so that we avoid a + dependency on unixodbc. + * Add support for automatically registering as a driver on + installation if unixodbc is installed (closes: #107038) + * Disable DH_VERBOSE, because it's annoying to read. :) + + -- Steve Langasek Mon, 31 Dec 2001 12:23:00 -0600 + +myodbc2.50.37 (2.50.37-4) unstable; urgency=low + + * Added autoconf patches to let it build on ia64. + Hopefully closes #110074. Thanks to Jeff Lincquia for this. + + -- Christian Hammers Tue, 6 Nov 2001 23:51:00 +0100 + +myodbc2.50.37 (2.50.37-3) unstable; urgency=low + + * Approving NMU. + + -- Christian Hammers Tue, 7 Aug 2001 21:31:05 +0200 + +myodbc2.50.37 (2.50.37-2.1) unstable; urgency=low + + * NMU + * Run libtoolize/aclocal for new arch support. Closes: #107655 + + -- LaMont Jones Fri, 3 Aug 2001 22:19:56 -0600 + +myodbc2.50.37 (2.50.37-2) unstable; urgency=low + + * Recompiled in current unstable. Closes: #98190 + * Fixed configure directive. + + -- Christian Hammers Mon, 21 May 2001 10:09:53 +0200 + +myodbc2.50.37 (2.50.37-1) unstable; urgency=low + + * New upstream. Now fully supports transactions. + + -- Christian Hammers Sat, 28 Apr 2001 19:10:43 +0200 + +myodbc2.50.32 (2.50.32-5) unstable; urgency=low + + * Added Build-Depends for libiodbc2-dev. Closes: #81801 + * No code change. + + -- Christian Hammers Sun, 18 Feb 2001 05:21:49 +0100 + +myodbc2.50.32 (2.50.32-4) testing unstable; urgency=low + + * This one should be in woody and sid! + * Added build-depends for debhelper. + + -- Christian Hammers Fri, 29 Dec 2000 17:00:08 +0100 + +myodbc2.50.32 (2.50.32-3) unstable; urgency=low + + * Added build-depends for debhelper. + + -- Christian Hammers Fri, 29 Dec 2000 17:00:08 +0100 + +myodbc2.50.32 (2.50.32-2) unstable; urgency=low + + * Recompiled against libmysqlclient10. + + -- Christian Hammers Wed, 11 Oct 2000 23:08:25 +0200 + +myodbc2.50.32 (2.50.32-1) unstable; urgency=low + + * New upstream version. + * (As always, forgive the package versioning, it's forced due to upstream + versioning of the shared library) + + -- Christian Hammers Tue, 12 Sep 2000 06:57:40 +0200 + +myodbc2.50.28 (2.50.28-2) frozen unstable; urgency=low + + * Applied a small upstream bug fix. + + -- Christian Hammers Tue, 22 Feb 2000 17:29:45 +0100 + +myodbc2.50.28 (2.50.28-1) unstable; urgency=low + + * New upstream release. + * Now compilable without full mysql source. Closes: #51643 + + -- Christian Hammers Sat, 4 Dec 1999 20:06:34 +0100 + +myodbc2.50.26 (2.50.26-1) unstable; urgency=low + + * Initial Release. + + -- Christian Hammers Sun, 3 Oct 1999 11:46:10 +0200 + +Local variables: +mode: debian-changelog +End: --- myodbc-3.51.15r409.orig/debian/config +++ myodbc-3.51.15r409/debian/config @@ -0,0 +1,17 @@ +#!/bin/sh + +action=$1 +version=$2 + +# Source debconf library. +. /usr/share/debconf/confmodule +db_version 2.0 + +if [ -e /usr/bin/odbcinst ] +then + db_title "ODBC Setup" + + db_input medium libmyodbc/addtoodbc || true + db_go +fi +exit 0 --- myodbc-3.51.15r409.orig/debian/control +++ myodbc-3.51.15r409/debian/control @@ -0,0 +1,17 @@ +Source: myodbc +Section: libs +Priority: optional +Maintainer: Steve Langasek +Standards-Version: 3.8.0 +Build-Depends: debhelper (>= 5), libmysqlclient15-dev, zlib1g-dev (>= 1:1.1.3), unixodbc-dev (>= 2.2.11-1), libltdl3-dev + +Package: libmyodbc +Section: libs +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Recommends: unixodbc | libiodbc2 +Description: the MySQL ODBC driver + This package allows you to connect to MySQL database servers using + ODBC, the Open Database Connectivity abstraction layer which is + understood by a variety of database tools that cannot talk to MySQL + databases directly. --- myodbc-3.51.15r409.orig/debian/copyright +++ myodbc-3.51.15r409/debian/copyright @@ -0,0 +1,26 @@ +This package was debianized by Christian Hammers on +Sun, 3 Oct 1999 11:46:10 +0200. + +It was downloaded from http://www.mysql.org + +Upstream Authors: Michael 'Monty' Widenius, TCX Datakonsult AB + +Copyright (C) 1997-2007 MySQL AB and others + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software Foundation, +Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +On Debian GNU/Linux systems, the complete text of the GNU General +Public License can be found in `/usr/share/common-licenses/GPL'. + --- myodbc-3.51.15r409.orig/debian/libmyodbc.examples +++ myodbc-3.51.15r409/debian/libmyodbc.examples @@ -0,0 +1 @@ +odbc.ini --- myodbc-3.51.15r409.orig/debian/libmyodbc.files +++ myodbc-3.51.15r409/debian/libmyodbc.files @@ -0,0 +1,2 @@ +usr/lib/odbc/*.so +usr/share/libmyodbc/* --- myodbc-3.51.15r409.orig/debian/odbcinst.ini +++ myodbc-3.51.15r409/debian/odbcinst.ini @@ -0,0 +1,6 @@ +[MySQL] +Description = MySQL driver +Driver = /usr/lib/odbc/libmyodbc.so +Setup = /usr/lib/odbc/libodbcmyS.so +CPTimeout = +CPReuse = --- myodbc-3.51.15r409.orig/debian/postinst +++ myodbc-3.51.15r409/debian/postinst @@ -0,0 +1,15 @@ +#!/bin/sh + +# Source debconf library. +. /usr/share/debconf/confmodule + +db_version 2.0 + +# Always add in the postinst, always delete in the prerm -- this way, +# we'll always have a good reference count in odbcinst.ini. +db_get libmyodbc/addtoodbc || true +if [ "$RET" = "true" ]; then + odbcinst -i -d -f /usr/share/libmyodbc/odbcinst.ini 1>&2 +fi + +#DEBHELPER# --- myodbc-3.51.15r409.orig/debian/rules +++ myodbc-3.51.15r409/debian/rules @@ -0,0 +1,103 @@ +#!/usr/bin/make -f +#-*- makefile -*- +# Made with the aid of dh_make, by Craig Small +# Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess. +# This version is for a hypothetical package that builds an +# architecture-dependant package, as well as an architecture-independant +# package. + +#export DH_VERBOSE=1 + +upstream_version := $(shell dpkg-parsechangelog | sed -n -e'/^Version: / { s/Version: //; s/-[^-]\+$$//; p }') +base_version = $(shell echo $(upstream_version) | sed -e's/r[0-9]\+$$//') + +# Authoritative build/host types for the Debian archen. +DEB_HOST_GNU_TYPE := $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) +DEB_BUILD_GNU_TYPE := $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) +ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE)) + confflags += --build $(DEB_HOST_GNU_TYPE) +else + confflags += --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE) +endif + +# Support the DEB_BUILD_OPTIONS variable +CFLAGS = -g -Wall + +ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) + CFLAGS += -O0 +else + CFLAGS += -O2 +endif + +build: build-stamp +build-stamp: + dh_testdir + + CPPFLAGS="-D_REENTRANT -D_GNU_SOURCE" \ + CFLAGS="${CFLAGS}" \ + ./configure $(confflags) \ + --prefix=/usr \ + --enable-shared \ + --enable-thread-safe \ + --with-unixODBC=/usr \ + --disable-gui \ + --with-mysql-libs=/usr/lib \ + --with-mysql-includes=/usr/include/mysql + $(MAKE) + + touch build-stamp + +clean: + dh_testdir + dh_testroot + rm -f build-stamp install-stamp + + # Add here commands to clean up after the build process. + [ ! -f Makefile ] || $(MAKE) clean + [ ! -f Makefile ] || $(MAKE) distclean + + dh_clean + +install: install-stamp +install-stamp: build-stamp + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + # Add here commands to install the package into debian/$(dirname). + $(MAKE) install prefix=`pwd`/debian/tmp/usr libdir=`pwd`/debian/tmp/usr/lib/odbc + + rm `pwd`/debian/tmp/usr/lib/odbc/libmyodbc3.* + rm `pwd`/debian/tmp/usr/lib/odbc/libmyodbc3_r.* + rm `pwd`/debian/tmp/usr/lib/odbc/libmyodbc3-3.* + mv `pwd`/debian/tmp/usr/lib/odbc/libmyodbc3_r-$(base_version).so `pwd`/debian/tmp/usr/lib/odbc/libmyodbc.so + mkdir -p `pwd`/debian/tmp/usr/share/libmyodbc + install -m644 debian/odbcinst.ini `pwd`/debian/tmp/usr/share/libmyodbc + + touch install-stamp + +binary-indep: build install + +binary-arch: build install + dh_testdir -a + dh_testroot -a + dh_installdirs -a + dh_movefiles -a + dh_installdocs -a + dh_installexamples -a + dh_installchangelogs -a ChangeLog + dh_installdebconf -a + dh_link -a + dh_strip -a + dh_compress -a + dh_fixperms -a + dh_installdeb -a + dh_perl -a + dh_shlibdeps -a + dh_gencontrol -a + dh_md5sums -a + dh_builddeb -a + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install --- myodbc-3.51.15r409.orig/debian/templates +++ myodbc-3.51.15r409/debian/templates @@ -0,0 +1,10 @@ +Template: libmyodbc/addtoodbc +Type: boolean +Default: false +_Description: Do you want MyODBC to be registered as an ODBC driver? + You appear to have an ODBC manager (unixodbc or iODBC) installed on your + system. + . + If you wish, MyODBC will be automatically added as an ODBC driver now and + will be automatically deleted from the list when you remove the libmyodbc + package, using the /usr/bin/odbcinst utility from unixodbc. --- myodbc-3.51.15r409.orig/debian/watch +++ myodbc-3.51.15r409/debian/watch @@ -0,0 +1,2 @@ +version=3 +http://mysql.osuosl.org/Downloads/MyODBC3/mysql-connector-odbc-([0-9r.]+)\.tar\.gz --- myodbc-3.51.15r409.orig/debian/compat +++ myodbc-3.51.15r409/debian/compat @@ -0,0 +1 @@ +5 --- myodbc-3.51.15r409.orig/debian/prerm +++ myodbc-3.51.15r409/debian/prerm @@ -0,0 +1,14 @@ +#!/bin/sh + +set -e + +# Source debconf library. +. /usr/share/debconf/confmodule +db_version 2.0 + +db_get libmyodbc/addtoodbc || true +if [ "$RET" = "true" ]; then + odbcinst -u -d -n MySQL +fi + +#DEBHELPER# --- myodbc-3.51.15r409.orig/debian/po/templates.pot +++ myodbc-3.51.15r409/debian/po/templates.pot @@ -0,0 +1,40 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: vorlon@debian.org\n" +"POT-Creation-Date: 2007-07-02 23:08-0700\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: boolean +#. Description +#: ../templates:1001 +msgid "Do you want MyODBC to be registered as an ODBC driver?" +msgstr "" + +#. Type: boolean +#. Description +#: ../templates:1001 +msgid "" +"You appear to have an ODBC manager (unixodbc or iODBC) installed on your " +"system." +msgstr "" + +#. Type: boolean +#. Description +#: ../templates:1001 +msgid "" +"If you wish, MyODBC will be automatically added as an ODBC driver now and " +"will be automatically deleted from the list when you remove the libmyodbc " +"package, using the /usr/bin/odbcinst utility from unixodbc." +msgstr "" --- myodbc-3.51.15r409.orig/debian/po/POTFILES.in +++ myodbc-3.51.15r409/debian/po/POTFILES.in @@ -0,0 +1 @@ +[type: gettext/rfc822deb] templates --- myodbc-3.51.15r409.orig/debian/po/cs.po +++ myodbc-3.51.15r409/debian/po/cs.po @@ -0,0 +1,52 @@ +# +# Translators, if you are not familiar with the PO format, gettext +# documentation is worth reading, especially sections dedicated to +# this format, e.g. by running: +# info -n '(gettext)PO Files' +# info -n '(gettext)Header Entry' +# +# Some information specific to po-debconf are available at +# /usr/share/doc/po-debconf/README-trans +# or http://www.debian.org/intl/l10n/po-debconf/README-trans +# +# Developers do not need to manually edit POT or PO files. +# +msgid "" +msgstr "" +"Project-Id-Version: myodbc\n" +"Report-Msgid-Bugs-To: vorlon@debian.org\n" +"POT-Creation-Date: 2007-07-02 23:08-0700\n" +"PO-Revision-Date: 2004-11-27 10:45+0100\n" +"Last-Translator: Miroslav Kure \n" +"Language-Team: Czech \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=ISO-8859-2\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: boolean +#. Description +#: ../templates:1001 +msgid "Do you want MyODBC to be registered as an ODBC driver?" +msgstr "Chcete MyODBC zaregistrovat jako ODBC ovlada?" + +#. Type: boolean +#. Description +#: ../templates:1001 +msgid "" +"You appear to have an ODBC manager (unixodbc or iODBC) installed on your " +"system." +msgstr "" +"Zd se, e mte na svm systmu nainstalovanho sprvce ODBC (unixodbc nebo " +"iODBC)." + +#. Type: boolean +#. Description +#: ../templates:1001 +msgid "" +"If you wish, MyODBC will be automatically added as an ODBC driver now and " +"will be automatically deleted from the list when you remove the libmyodbc " +"package, using the /usr/bin/odbcinst utility from unixodbc." +msgstr "" +"Pokud chcete, me se nyn MyODBC automaticky pidat jako ODBC ovlada a " +"pozdji, a odstrante libmyodbc, zase automaticky ze seznamu odstranit. " +"(Pro tyto akce se pouije nstroj /usr/bin/odbcinst z balku unixodbc.)" --- myodbc-3.51.15r409.orig/debian/po/es.po +++ myodbc-3.51.15r409/debian/po/es.po @@ -0,0 +1,69 @@ +# myodbc translation to spanish +# Copyright (C) 2007 Free Software Foundation, Inc. +# This file is distributed under the same license as the package. +# +# Changes: +# - Initial translation +# Manuel Porras Peralta , 2007 +# +# +# Traductores, si no conoce el formato PO, merece la pena leer la +# documentación de gettext, especialmente las secciones dedicadas a este +# formato, por ejemplo ejecutando: +# info -n '(gettext)PO Files' +# info -n '(gettext)Header Entry' +# +# Equipo de traducción al español, por favor lean antes de traducir +# los siguientes documentos: +# +# - El proyecto de traducción de Debian al español +# http://www.debian.org/intl/spanish/ +# especialmente las notas y normas de traducción en +# http://www.debian.org/intl/spanish/notas +# +# - La guía de traducción de po's de debconf: +# /usr/share/doc/po-debconf/README-trans +# o http://www.debian.org/intl/l10n/po-debconf/README-trans +# +# Si tiene dudas o consultas sobre esta traducción consulte con el último +# traductor (campo Last-Translator) y ponga en copia a la lista de +# traducción de Debian al español () +msgid "" +msgstr "" +"Project-Id-Version: myodbc\n" +"Report-Msgid-Bugs-To: vorlon@debian.org\n" +"POT-Creation-Date: 2007-07-02 23:08-0700\n" +"PO-Revision-Date: 2007-02-07 11:49+0100\n" +"Last-Translator: Manuel Porras Peralta «Venturi» \n" +"Language-Team: Debian Spanish \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: boolean +#. Description +#: ../templates:1001 +msgid "Do you want MyODBC to be registered as an ODBC driver?" +msgstr "¿Desea que MyODBC se registre como un controlador de ODBC?" + +#. Type: boolean +#. Description +#: ../templates:1001 +msgid "" +"You appear to have an ODBC manager (unixodbc or iODBC) installed on your " +"system." +msgstr "" +"Parece que tiene instalado en su sistema un gestor de ODBC (unixodbc o " +"iODBC)." + +#. Type: boolean +#. Description +#: ../templates:1001 +msgid "" +"If you wish, MyODBC will be automatically added as an ODBC driver now and " +"will be automatically deleted from the list when you remove the libmyodbc " +"package, using the /usr/bin/odbcinst utility from unixodbc." +msgstr "" +"Si lo desea, se usará la herramienta «/usr/bin/odbcinst» de unixodbc para " +"agregar automáticamente MyODBC a la lista de controladores ahora y borrarlo " +"automáticamente de la lista cuando elimine el paquete libmyodbc." --- myodbc-3.51.15r409.orig/debian/po/fr.po +++ myodbc-3.51.15r409/debian/po/fr.po @@ -0,0 +1,53 @@ +# +# Translators, if you are not familiar with the PO format, gettext +# documentation is worth reading, especially sections dedicated to +# this format, e.g. by running: +# info -n '(gettext)PO Files' +# info -n '(gettext)Header Entry' +# +# Some information specific to po-debconf are available at +# /usr/share/doc/po-debconf/README-trans +# or http://www.debian.org/intl/l10n/po-debconf/README-trans +# +# Developers do not need to manually edit POT or PO files. +# +msgid "" +msgstr "" +"Project-Id-Version: myodbc_2.50.39-6\n" +"Report-Msgid-Bugs-To: vorlon@debian.org\n" +"POT-Creation-Date: 2007-07-02 23:08-0700\n" +"PO-Revision-Date: 2004-02-10 10:55+0100\n" +"Last-Translator: Clment Stenac \n" +"Language-Team: French \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=iso-8859-1\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: boolean +#. Description +#: ../templates:1001 +msgid "Do you want MyODBC to be registered as an ODBC driver?" +msgstr "Souhaitez-vous que MyODBC soit enregistr en tant que pilote ODBC?" + +#. Type: boolean +#. Description +#: ../templates:1001 +msgid "" +"You appear to have an ODBC manager (unixodbc or iODBC) installed on your " +"system." +msgstr "" +"Il semble qu'un gestionnaire ODBC (unixodbc ou iODBC) soit install sur " +"votre systme." + +#. Type: boolean +#. Description +#: ../templates:1001 +msgid "" +"If you wish, MyODBC will be automatically added as an ODBC driver now and " +"will be automatically deleted from the list when you remove the libmyodbc " +"package, using the /usr/bin/odbcinst utility from unixodbc." +msgstr "" +"Si vous le souhaitez, MyODBC sera automatiquement ajout en tant que pilote " +"ODBC maintenant et sera automatiquement retir de la liste lorsque vous " +"supprimerez le paquet libmyodbc, grce l'utilitaire /usr/bin/odbcinst " +"d'unixodbc." --- myodbc-3.51.15r409.orig/debian/po/ja.po +++ myodbc-3.51.15r409/debian/po/ja.po @@ -0,0 +1,53 @@ +# +# Translators, if you are not familiar with the PO format, gettext +# documentation is worth reading, especially sections dedicated to +# this format, e.g. by running: +# info -n '(gettext)PO Files' +# info -n '(gettext)Header Entry' +# +# Some information specific to po-debconf are available at +# /usr/share/doc/po-debconf/README-trans +# or http://www.debian.org/intl/l10n/po-debconf/README-trans +# +# Developers do not need to manually edit POT or PO files. +# +# +msgid "" +msgstr "" +"Project-Id-Version: myodbc 3.51.06\n" +"Report-Msgid-Bugs-To: vorlon@debian.org\n" +"POT-Creation-Date: 2007-07-02 23:08-0700\n" +"PO-Revision-Date: 2004-03-02 02:00+0900\n" +"Last-Translator: Hideki Yamane \n" +"Language-Team: Japanese \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=EUC-JP\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: boolean +#. Description +#: ../templates:1001 +msgid "Do you want MyODBC to be registered as an ODBC driver?" +msgstr "ODBC ɥ饤ФȤ MyODBC Ͽޤ?" + +#. Type: boolean +#. Description +#: ../templates:1001 +msgid "" +"You appear to have an ODBC manager (unixodbc or iODBC) installed on your " +"system." +msgstr "" +"ODBC ޥ͡ (unixodbc ޤ iODBC) ƥ˥󥹥ȡ뤵Ƥ" +"Ǥ" + +#. Type: boolean +#. Description +#: ../templates:1001 +msgid "" +"If you wish, MyODBC will be automatically added as an ODBC driver now and " +"will be automatically deleted from the list when you remove the libmyodbc " +"package, using the /usr/bin/odbcinst utility from unixodbc." +msgstr "" +"⤷˾ʤ顢MyODBC Ϥ ODBC ɥ饤ФȤƼưŪϿ졢libmyodbc " +"ѥå줿ݤ onixodbc /usr/bin/odbcinst 桼ƥƥ" +"ƥɥ饤ХꥹȤ鼫ưŪ˺ޤ" --- myodbc-3.51.15r409.orig/debian/po/ru.po +++ myodbc-3.51.15r409/debian/po/ru.po @@ -0,0 +1,53 @@ +# +# Translators, if you are not familiar with the PO format, gettext +# documentation is worth reading, especially sections dedicated to +# this format, e.g. by running: +# info -n '(gettext)PO Files' +# info -n '(gettext)Header Entry' +# +# Some information specific to po-debconf are available at +# /usr/share/doc/po-debconf/README-trans +# or http://www.debian.org/intl/l10n/po-debconf/README-trans +# +# Developers do not need to manually edit POT or PO files. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: vorlon@debian.org\n" +"POT-Creation-Date: 2007-07-02 23:08-0700\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=KOI8-R\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: boolean +#. Description +#: ../templates:1001 +msgid "Do you want MyODBC to be registered as an ODBC driver?" +msgstr " MyODBC ODBC?" + +#. Type: boolean +#. Description +#: ../templates:1001 +msgid "" +"You appear to have an ODBC manager (unixodbc or iODBC) installed on your " +"system." +msgstr "" +" ODBC (unixodbc " +"iODBC)." + +#. Type: boolean +#. Description +#: ../templates:1001 +msgid "" +"If you wish, MyODBC will be automatically added as an ODBC driver now and " +"will be automatically deleted from the list when you remove the libmyodbc " +"package, using the /usr/bin/odbcinst utility from unixodbc." +msgstr "" +" , MyODBC ODBC " +" libmyodbc, " +" /usr/bin/odbcinst." --- myodbc-3.51.15r409.orig/debian/po/sv.po +++ myodbc-3.51.15r409/debian/po/sv.po @@ -0,0 +1,51 @@ +# Translators, if you are not familiar with the PO format, gettext +# documentation is worth reading, especially sections dedicated to +# this format, e.g. by running: +# info -n '(gettext)PO Files' +# info -n '(gettext)Header Entry' +# Some information specific to po-debconf are available at +# /usr/share/doc/po-debconf/README-trans +# or http://www.debian.org/intl/l10n/po-debconf/README-trans +# Developers do not need to manually edit POT or PO files. +# , fuzzy +# +# +msgid "" +msgstr "" +"Project-Id-Version: myodbc 3.51.11-5\n" +"Report-Msgid-Bugs-To: vorlon@debian.org\n" +"POT-Creation-Date: 2007-07-02 23:08-0700\n" +"PO-Revision-Date: 2005-10-05 02:11+0200\n" +"Last-Translator: Daniel Nylander \n" +"Language-Team: Swedish \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=iso-8859-1\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: boolean +#. Description +#: ../templates:1001 +msgid "Do you want MyODBC to be registered as an ODBC driver?" +msgstr "Vill du att MyODBC ska registreras som en ODBC-drivare?" + +#. Type: boolean +#. Description +#: ../templates:1001 +msgid "" +"You appear to have an ODBC manager (unixodbc or iODBC) installed on your " +"system." +msgstr "" +"Du verkar ha en ODBC-hanterare (unixodbc eller iODBC) installerat p ditt " +"system." + +#. Type: boolean +#. Description +#: ../templates:1001 +msgid "" +"If you wish, MyODBC will be automatically added as an ODBC driver now and " +"will be automatically deleted from the list when you remove the libmyodbc " +"package, using the /usr/bin/odbcinst utility from unixodbc." +msgstr "" +"Om du nskar kan MyODBC automatiskt lggas till som en ODBC-drivare nu och " +"kommer att automatiskt tas bort frn listan nr du tar bort myodbc-paketet " +"med verktyget /usr/bin/odbcinst frn paketet unixodbc." --- myodbc-3.51.15r409.orig/debian/po/vi.po +++ myodbc-3.51.15r409/debian/po/vi.po @@ -0,0 +1,44 @@ +# Vietnamese Translation for myodbc. +# Copyright © 2005 Free Software Foundation, Inc. +# Clytie Siddall , 2005. +# +msgid "" +msgstr "" +"Project-Id-Version: myodbc 3.51.09-1\n" +"Report-Msgid-Bugs-To: vorlon@debian.org\n" +"POT-Creation-Date: 2007-07-02 23:08-0700\n" +"PO-Revision-Date: 2005-06-11 16:44+0930\n" +"Last-Translator: Clytie Siddall \n" +"Language-Team: Vietnamese \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=1; plural=0\n" + +#. Type: boolean +#. Description +#: ../templates:1001 +msgid "Do you want MyODBC to be registered as an ODBC driver?" +msgstr "Bạn có muốn đăng ký MyODBC là một trình hỗ trợ thiết bị ODBC không?" + +#. Type: boolean +#. Description +#: ../templates:1001 +msgid "" +"You appear to have an ODBC manager (unixodbc or iODBC) installed on your " +"system." +msgstr "" +"Hình như bạn đã cài đặt một trình quản lý ODBC (unixodbc hay iODBC) trong hệ " +"thống này rồi." + +#. Type: boolean +#. Description +#: ../templates:1001 +msgid "" +"If you wish, MyODBC will be automatically added as an ODBC driver now and " +"will be automatically deleted from the list when you remove the libmyodbc " +"package, using the /usr/bin/odbcinst utility from unixodbc." +msgstr "" +"Nếu bạn muốn thì trình này sẻ tự động thêm MyODBC là một trình hỗ trợ thiết " +"bị ODBC ngay bây giờ, và sẽ tự động xóa bỏ nó ra danh sách khi bạn loại bỏ " +"gói tin «libmyodbc», dùng tiện ích «/usr/bin/odbcinst» từ «unixodbc»." --- myodbc-3.51.15r409.orig/debian/po/de.po +++ myodbc-3.51.15r409/debian/po/de.po @@ -0,0 +1,44 @@ +# Translation of myodbc debconf templates to German +# Copyright (C) Matthias Julius , 2006. +# Copyright (C) Helge Kreutzmann , 2007. +# This file is distributed under the same license as the myodbc package. +# +msgid "" +msgstr "" +"Project-Id-Version: myodbc 3.51.15r409-1\n" +"Report-Msgid-Bugs-To: vorlon@debian.org\n" +"POT-Creation-Date: 2007-07-02 23:08-0700\n" +"PO-Revision-Date: 2007-07-01 11:52+0200\n" +"Last-Translator: Helge Kreutzmann \n" +"Language-Team: German \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=ISO-8859-15\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: boolean +#. Description +#: ../templates:1001 +msgid "Do you want MyODBC to be registered as an ODBC driver?" +msgstr "Soll MyODBC als ODBC-Treiber registriert werden?" + +#. Type: boolean +#. Description +#: ../templates:1001 +msgid "" +"You appear to have an ODBC manager (unixodbc or iODBC) installed on your " +"system." +msgstr "" +"Es scheint ein ODBC-Manager (Unixodbc oder iODBC) auf Ihrem System " +"installiert zu sein." + +#. Type: boolean +#. Description +#: ../templates:1001 +msgid "" +"If you wish, MyODBC will be automatically added as an ODBC driver now and " +"will be automatically deleted from the list when you remove the libmyodbc " +"package, using the /usr/bin/odbcinst utility from unixodbc." +msgstr "" +"Falls Sie mchten, wird MyODBC jetzt automatisch als ODBC-Treiber " +"hinzugefgt und automatisch aus der Liste gelscht, wenn Sie das libmyodbc-" +"Paket entfernen. Hierzu wird /usr/bin/odbcinst aus Unixodbc verwendet." --- myodbc-3.51.15r409.orig/debian/po/nl.po +++ myodbc-3.51.15r409/debian/po/nl.po @@ -0,0 +1,45 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: myodbc\n" +"Report-Msgid-Bugs-To: vorlon@debian.org\n" +"POT-Creation-Date: 2007-07-02 23:08-0700\n" +"PO-Revision-Date: 2007-03-06 19:10+0100\n" +"Last-Translator: Bart Cornelis \n" +"Language-Team: debian-l10n-dutch \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: boolean +#. Description +#: ../templates:1001 +msgid "Do you want MyODBC to be registered as an ODBC driver?" +msgstr "Wilt u dat MyODBC geregistreerd wordt als een ODBC-stuurprogramma?" + +#. Type: boolean +#. Description +#: ../templates:1001 +msgid "" +"You appear to have an ODBC manager (unixodbc or iODBC) installed on your " +"system." +msgstr "" +"Het lijkt erop dat u een ODBC-manager (unixodbc of iODBC) geïnstalleerd " +"heeft op uw systeem." + +#. Type: boolean +#. Description +#: ../templates:1001 +msgid "" +"If you wish, MyODBC will be automatically added as an ODBC driver now and " +"will be automatically deleted from the list when you remove the libmyodbc " +"package, using the /usr/bin/odbcinst utility from unixodbc." +msgstr "" +"Als u dit wenst wordt MyODBC automatisch toegevoegd aan de lijst van ODBC-" +"stuurprogramma's, en bij verwijdering van het 'libmyodbc'-pakket ook weer " +"uit de lijst verwijderd. Dit gebeurt m.b.v. het hulpprogramma /usr/bin/" +"odbcinst uit het pakket unixodbc." --- myodbc-3.51.15r409.orig/debian/po/pt.po +++ myodbc-3.51.15r409/debian/po/pt.po @@ -0,0 +1,45 @@ +# translation of myodbc debconf to Portuguese +# Copyright (C) 2007 Américo Monteiro +# This file is distributed under the same license as the myodbc package. +# +# Américo Monteiro , 2007. +msgid "" +msgstr "" +"Project-Id-Version: myodbc 3.51.15r409-1\n" +"Report-Msgid-Bugs-To: vorlon@debian.org\n" +"POT-Creation-Date: 2007-07-02 23:08-0700\n" +"PO-Revision-Date: 2007-07-22 17:01+0100\n" +"Last-Translator: Américo Monteiro \n" +"Language-Team: Portuguese \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: KBabel 1.11.4\n" + +#. Type: boolean +#. Description +#: ../templates:1001 +msgid "Do you want MyODBC to be registered as an ODBC driver?" +msgstr "Deseja que o MyODBC seja registrado como um controlador ODBC?" + +#. Type: boolean +#. Description +#: ../templates:1001 +msgid "" +"You appear to have an ODBC manager (unixodbc or iODBC) installed on your " +"system." +msgstr "" +"Parece que você tem um gestor ODBC (unixodbc ou iODBC) instalado no seu " +"sistema." + +#. Type: boolean +#. Description +#: ../templates:1001 +msgid "" +"If you wish, MyODBC will be automatically added as an ODBC driver now and " +"will be automatically deleted from the list when you remove the libmyodbc " +"package, using the /usr/bin/odbcinst utility from unixodbc." +msgstr "" +"Se desejar, MyODBC pode ser automaticamente adicionado agora como um " +"controlador ODBC e será automaticamente apagado da lista quando você remover " +"o pacote libmyodbc, usando o utilitário /usr/bin/odbcinst do unixodbc." --- myodbc-3.51.15r409.orig/debian/po/pt_BR.po +++ myodbc-3.51.15r409/debian/po/pt_BR.po @@ -0,0 +1,45 @@ +# myodbc Brazilian Portuguese translation +# Copyright (C) 2007 THE myodbc'S COPYRIGHT HOLDER +# This file is distributed under the same license as the myodbc package. +# Felipe Augusto van de Wiel (faw) , 2007. +# +msgid "" +msgstr "" +"Project-Id-Version: (20071022)\n" +"Report-Msgid-Bugs-To: vorlon@debian.org\n" +"POT-Creation-Date: 2007-07-02 23:08-0700\n" +"PO-Revision-Date: 2007-10-22 02:42-0200\n" +"Last-Translator: Felipe Augusto van de Wiel (faw) \n" +"Language-Team: l10n portuguese \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"pt_BR utf-8\n" + +#. Type: boolean +#. Description +#: ../templates:1001 +msgid "Do you want MyODBC to be registered as an ODBC driver?" +msgstr "Você gostaria de registrar o MyODBC como um driver ODBC?" + +#. Type: boolean +#. Description +#: ../templates:1001 +msgid "" +"You appear to have an ODBC manager (unixodbc or iODBC) installed on your " +"system." +msgstr "" +"Você parece ter um gerenciador ODBC (unixodbc ou iODBC) instalado em seu " +"sistema." + +#. Type: boolean +#. Description +#: ../templates:1001 +msgid "" +"If you wish, MyODBC will be automatically added as an ODBC driver now and " +"will be automatically deleted from the list when you remove the libmyodbc " +"package, using the /usr/bin/odbcinst utility from unixodbc." +msgstr "" +"Se você desejar, o MyODBC será automaticamente adicionado como um driver " +"ODBC agora e será automaticamente removido da lista quando você remover o " +"pacote libmyodbc, usando o utilitário /usr/bin/odbcinst do unixodbc." --- myodbc-3.51.15r409.orig/debian/po/gl.po +++ myodbc-3.51.15r409/debian/po/gl.po @@ -0,0 +1,42 @@ +# Galician translation of myodbc's debconf templates +# This file is distributed under the same license as the myodbc package. +# Jacobo Tarrio , 2008. +# +msgid "" +msgstr "" +"Project-Id-Version: myodbc\n" +"Report-Msgid-Bugs-To: vorlon@debian.org\n" +"POT-Creation-Date: 2007-07-02 23:08-0700\n" +"PO-Revision-Date: 2008-05-25 13:20+0100\n" +"Last-Translator: Jacobo Tarrio \n" +"Language-Team: Galician \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: boolean +#. Description +#: ../templates:1001 +msgid "Do you want MyODBC to be registered as an ODBC driver?" +msgstr "¿Quere rexistrar MyODBC coma controlador ODBC?" + +#. Type: boolean +#. Description +#: ../templates:1001 +msgid "" +"You appear to have an ODBC manager (unixodbc or iODBC) installed on your " +"system." +msgstr "" +"Semella que ten un xestor ODBC (unixodbc ou iODBC) instalado no sistema." + +#. Type: boolean +#. Description +#: ../templates:1001 +msgid "" +"If you wish, MyODBC will be automatically added as an ODBC driver now and " +"will be automatically deleted from the list when you remove the libmyodbc " +"package, using the /usr/bin/odbcinst utility from unixodbc." +msgstr "" +"Se quere, hase engadir automaticamente MyODBC coma controlador ODBC, e hase " +"quitar automaticamente da lista cando elimine o paquete libmyodbc, " +"empregando a utilidade /usr/bin/odbcinst de unixodbc." --- myodbc-3.51.15r409.orig/debian/po/fi.po +++ myodbc-3.51.15r409/debian/po/fi.po @@ -0,0 +1,41 @@ +msgid "" +msgstr "" +"Project-Id-Version: myodbc\n" +"Report-Msgid-Bugs-To: vorlon@debian.org\n" +"POT-Creation-Date: 2007-07-02 23:08-0700\n" +"PO-Revision-Date: 2007-10-17 23:31+0200\n" +"Last-Translator: Esko Arajärvi \n" +"Language-Team: Finnish \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Poedit-Language: Finnish\n" +"X-Poedit-Country: FINLAND\n" + +#. Type: boolean +#. Description +#: ../templates:1001 +msgid "Do you want MyODBC to be registered as an ODBC driver?" +msgstr "Rekisteröidäänkö MyODBC ODBC-ajurina?" + +#. Type: boolean +#. Description +#: ../templates:1001 +msgid "" +"You appear to have an ODBC manager (unixodbc or iODBC) installed on your " +"system." +msgstr "" +"Järjestelmässä näyttää olevan ODBC-hallintaohjelma (unixodbc tai iODBC) " +"asennettuna." + +#. Type: boolean +#. Description +#: ../templates:1001 +msgid "" +"If you wish, MyODBC will be automatically added as an ODBC driver now and " +"will be automatically deleted from the list when you remove the libmyodbc " +"package, using the /usr/bin/odbcinst utility from unixodbc." +msgstr "" +"Jos haluat, MyODBC lisätään automaattisesti ODBC-ajuriksi käyttäen työkalua /" +"usr/bin/odbcinst ohjelmasta unixodbc, ja poistetaan automaattisesti " +"listalta, kun paketti libmyodbc poistetaan."