Modified:
myodbc3/cursor.c
myodbc3/execute.c
myodbc3u/MYODBCUtil.h
samples/Makefile.am
samples/my_basics.c
samples/my_cursor.c
samples/my_param.c
samples/my_result.c
samples/my_tran.c
samples/my_utility.h
samples/run-samples
Log:
Jims patch...
* changing extend_buffer() to call net_realloc() instead of monkeying
with net->buff on its own
* s/SQLINTEGER/SQLLEN/ to a variable in insert_field(), because they
aren't interchangeable on 64-bit systems.
the changes to the samples where i changed SQLINTEGER to long may have a
better solution -- the problem is that the SQLINTEGER is being used as a
bound parameter and called a SQL_C_LONG, but SQLINTEGER is just an int.
Modified: myodbc3/cursor.c
===================================================================
--- myodbc3/cursor.c 2006-08-25 15:26:46 UTC (rev 64)
+++ myodbc3/cursor.c 2006-08-26 02:30:39 UTC (rev 65)
@@ -448,7 +448,7 @@
MYSQL_ROW row_data= result->data_cursor->data + nSrcCol;
NET *net=&stmt->dbc->mysql.net;
SQLCHAR *to= net->buff;
- SQLINTEGER length;
+ SQLLEN length;
/* Copy row buffer data to statement */
param.used= 1;
@@ -1460,7 +1460,7 @@
the result set
*/
-SQLRETURN SQL_API SQLSetPos(SQLHSTMT hstmt, SQLUSMALLINT irow,
+SQLRETURN SQL_API SQLSetPos(SQLHSTMT hstmt, SQLSETPOSIROW irow,
SQLUSMALLINT fOption, SQLUSMALLINT fLock)
{
return my_SQLSetPos(hstmt,irow,fOption,fLock);
Modified: myodbc3/execute.c
===================================================================
--- myodbc3/execute.c 2006-08-25 15:26:46 UTC (rev 64)
+++ myodbc3/execute.c 2006-08-26 02:30:39 UTC (rev 65)
@@ -135,33 +135,24 @@
@purpose : help function to enlarge buffer if necessary
*/
-char *extend_buffer(NET *net,char *to,ulong length)
+char *extend_buffer(NET *net, char *to, ulong length)
{
- ulong nead= 0;
+ ulong need= 0;
MYODBCDbgEnter("extend_buffer");
MYODBCDbgPrint("enter",("current_length: %ld length: %ld buffer_length: %ld",
- (ulong) (to - (char*) net->buff),
+ (ulong) (to - (char *)net->buff),
(ulong) length,
(ulong) net->max_packet));
- if ( !to ||
- (nead= (ulong) (to - (char*) net->buff)+length) > net->max_packet-10 )
+ if (!to ||
+ (need= (ulong)(to - (char *)net->buff) + length) > net->max_packet - 10)
{
- ulong pkt_length= (nead+8192) & ~(8192-1);
- uchar *buff;
-
- if ( pkt_length > max_allowed_packet )
+ if (net_realloc(net, need))
{
- MYODBCDbgPrint("error",("Needed %ld but max_allowed_packet is %ld",
- pkt_length,max_allowed_packet));
- MYODBCDbgReturn2(0); /* Too large packet */
- }
- if ( !(buff= (uchar*) my_realloc((char*) net->buff,pkt_length,
- MYF(MY_WME))) )
MYODBCDbgReturn2(0);
- to= (char*) buff+nead-length;
- net->buff= net->write_pos= buff;
- net->buff_end= buff+(net->max_packet= pkt_length);
+ }
+
+ to= (char *)net->buff + need - length;
}
MYODBCDbgReturn2(to);
}
Modified: myodbc3u/MYODBCUtil.h
===================================================================
--- myodbc3u/MYODBCUtil.h 2006-08-25 15:26:46 UTC (rev 64)
+++ myodbc3u/MYODBCUtil.h 2006-08-26 02:30:39 UTC (rev 65)
@@ -26,7 +26,7 @@
#include <stdlib.h>
#include <string.h>
-#include "../MYODBC_MYSQL.h"
+/* #include "../MYODBC_MYSQL.h" */
#include "../MYODBC_CONF.h"
#include "../MYODBC_ODBC.h"
Modified: samples/Makefile.am
===================================================================
--- samples/Makefile.am 2006-08-25 15:26:46 UTC (rev 64)
+++ samples/Makefile.am 2006-08-26 02:30:39 UTC (rev 65)
@@ -34,7 +34,4 @@
# test samples
test: all
- $(MAKE); \
./run-samples
-
-
Modified: samples/my_basics.c
===================================================================
--- samples/my_basics.c 2006-08-25 15:26:46 UTC (rev 64)
+++ samples/my_basics.c 2006-08-26 02:30:39 UTC (rev 65)
@@ -139,10 +139,6 @@
rc = SQLEndTran(SQL_HANDLE_DBC, hdbc, SQL_COMMIT);
mycon(hdbc,rc);
- /* free the statement cursor */
- rc = SQLFreeStmt(hstmt, SQL_CLOSE);
- mystmt(hstmt,rc);
-
printf(" success!!\n");
}
@@ -159,13 +155,6 @@
SQLINTEGER narg;
/*
- * show the usage string when the user asks for this
- */
- printf("***********************************************\n");
- printf("usage: my_basics [DSN] [UID] [PWD] \n");
- printf("***********************************************\n");
-
- /*
* if connection string supplied through arguments, overrite
* the default one..
*/
@@ -192,7 +181,7 @@
/*
* disconnect from the server, by freeing all resources
*/
- mydisconnect(&henv,&hdbc,&hstmt);
+ mydisconnect(henv,hdbc,hstmt);
return(0);
}
Modified: samples/my_cursor.c
===================================================================
--- samples/my_cursor.c 2006-08-25 15:26:46 UTC (rev 64)
+++ samples/my_cursor.c 2006-08-26 02:30:39 UTC (rev 65)
@@ -95,7 +95,7 @@
void my_init_table(SQLHDBC hdbc, SQLHSTMT hstmt)
{
SQLRETURN rc;
- SQLINTEGER id;
+ long id;
char name[50];
printf("\nmy_init_table:\n");
@@ -339,16 +339,9 @@
SQLHENV henv;
SQLHDBC hdbc;
SQLHSTMT hstmt;
- SQLINTEGER narg;
+ int narg, rc;
/*
- * show the usage string when the user asks for this
- */
- printf("***********************************************\n");
- printf("usage: my_cursor [DSN] [UID] [PWD] \n");
- printf("***********************************************\n");
-
- /*
* if connection string supplied through arguments, overrite
* the default one..
*/
@@ -382,10 +375,15 @@
*/
my_setpos_cursor(hdbc, hstmt);
+
+ /* Clean up after ourselves. */
+ rc= SQLExecDirect(hstmt,(SQLCHAR*) "DROP TABLE my_demo_cursor", SQL_NTS);
+ mystmt(hstmt,rc);
+
/*
* disconnect from the server, by freeing all resources
*/
- mydisconnect(&henv,&hdbc,&hstmt);
+ mydisconnect(henv,hdbc,hstmt);
return(0);
}
Modified: samples/my_param.c
===================================================================
--- samples/my_param.c 2006-08-25 15:26:46 UTC (rev 64)
+++ samples/my_param.c 2006-08-26 02:30:39 UTC (rev 65)
@@ -64,6 +64,7 @@
/* commit the transaction*/
rc = SQLEndTran(SQL_HANDLE_DBC, hdbc, SQL_COMMIT);
mycon(hdbc,rc);
+
}
/********************************************************
@@ -129,7 +130,7 @@
void my_param_insert(SQLHDBC hdbc, SQLHSTMT hstmt)
{
SQLRETURN rc;
- SQLINTEGER id;
+ long id;
char name[50];
printf("\nmy_param_insert:\n");
@@ -242,7 +243,7 @@
void my_param_delete(SQLHDBC hdbc, SQLHSTMT hstmt)
{
SQLRETURN rc;
- SQLINTEGER id, nRowCount;
+ long id, nRowCount;
printf("\nmy_param_delete:\n");
@@ -307,19 +308,13 @@
SQLHDBC hdbc;
SQLHSTMT hstmt;
SQLINTEGER narg;
+ int rc;
/*
- * show the usage string when the user asks for this
- */
- printf("***********************************************\n");
- printf("usage: my_param [DSN] [UID] [PWD] \n");
- printf("***********************************************\n");
-
- /*
* if connection string supplied through arguments, overrite
* the default one..
*/
- for(narg = 1; narg < argc; narg++)
+ for (narg= 1; narg < argc; narg++)
{
if ( narg == 1 )
mydsn = argv[1];
@@ -354,10 +349,15 @@
*/
my_param_delete(hdbc, hstmt);
+ /* Clean up after oursleves. */
+ rc = SQLExecDirect(hstmt,(SQLCHAR*) "DROP TABLE if exists my_demo_param",
+ SQL_NTS);
+ mystmt(hstmt,rc);
+
/*
* disconnect from the server, by freeing all resources
*/
- mydisconnect(&henv,&hdbc,&hstmt);
+ mydisconnect(henv,hdbc,hstmt);
return(0);
}
Modified: samples/my_result.c
===================================================================
--- samples/my_result.c 2006-08-25 15:26:46 UTC (rev 64)
+++ samples/my_result.c 2006-08-26 02:30:39 UTC (rev 65)
@@ -186,7 +186,7 @@
/*
* disconnect from the server, by freeing all resources
*/
- mydisconnect(&henv,&hdbc,&hstmt);
+ mydisconnect(henv,hdbc,hstmt);
return(0);
}
Modified: samples/my_tran.c
===================================================================
--- samples/my_tran.c 2006-08-25 15:26:46 UTC (rev 64)
+++ samples/my_tran.c 2006-08-26 02:30:39 UTC (rev 65)
@@ -155,7 +155,7 @@
/*
* disconnect from the server, by freeing all resources
*/
- mydisconnect(&henv,&hdbc,&hstmt);
+ mydisconnect(henv,hdbc,hstmt);
return(0);
}
Modified: samples/my_utility.h
===================================================================
--- samples/my_utility.h 2006-08-25 15:26:46 UTC (rev 64)
+++ samples/my_utility.h 2006-08-26 02:30:39 UTC (rev 65)
@@ -167,30 +167,30 @@
mycon(*hdbc,rc);
rc = SQLAllocHandle(SQL_HANDLE_STMT,*hdbc,hstmt);
- mycon(*hdbc,rc);
+ mystmt(*hstmt,rc);
printf(" success!!\n");
}
/********************************************************
* MyODBC 3.51 closes the connection *
*********************************************************/
-void mydisconnect(SQLHENV *henv,SQLHDBC *hdbc, SQLHSTMT *hstmt)
+void mydisconnect(SQLHENV henv,SQLHDBC hdbc, SQLHSTMT hstmt)
{
SQLRETURN rc;
printf("\nmydisconnect:\n");
- rc = SQLFreeStmt(*hstmt, SQL_DROP);
- mystmt(*hstmt,rc);
+ rc = SQLFreeStmt(hstmt, SQL_DROP);
+ mystmt(hstmt,rc);
- rc = SQLDisconnect(*hdbc);
- mycon(*hdbc,rc);
+ rc = SQLDisconnect(hdbc);
+ mycon(hdbc,rc);
- rc = SQLFreeConnect(*hdbc);
- mycon(*hdbc,rc);
+ rc = SQLFreeConnect(hdbc);
+ mycon(hdbc,rc);
- rc = SQLFreeEnv(*henv);
- myenv(*henv,rc);
+ rc = SQLFreeEnv(henv);
+ myenv(henv,rc);
printf(" success!!\n");
}
Modified: samples/run-samples
===================================================================
--- samples/run-samples 2006-08-25 15:26:46 UTC (rev 64)
+++ samples/run-samples 2006-08-26 02:30:39 UTC (rev 65)
@@ -1,4 +1,5 @@
#! /bin/sh
+set -e
# Run individual MyODBC test samples
| Thread |
|---|
| • Connector/ODBC 3.51 commit: r65 - myodbc3 myodbc3u samples | pharvey | 26 Aug |