- Add unoficial patch for MySQL 3.23 and 4.0 users

PR:		ports/91684
Submitted by:	Bjorn Konig <bkoenig@cs.tu-berlin.de> (maintainer)
This commit is contained in:
Pav Lucistnik 2006-01-14 19:47:12 +00:00
parent 52e61d2411
commit d6986129a3
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=153496
5 changed files with 350 additions and 62 deletions

View File

@ -16,7 +16,6 @@ COMMENT= TCL module for accessing MySQL databases based on msqltcl
LIB_DEPENDS= ${TCL_NODOT}:${PORTSDIR}/lang/${TCL_NODOT}
USE_MYSQL= yes
BROKEN_WITH_MYSQL= 323 40
TCL_VERSION?= tcl8.4
TCL_NODOT= ${TCL_VERSION:S/.//}
SQL_DIR= ${PREFIX}/lib/${TCL_VERSION}/mysqltcl
@ -31,15 +30,22 @@ USE_REINPLACE= yes
REINPLACE_ARGS= -i ''
pre-patch:
${REINPLACE_CMD} -e 's, * ,,' ${WRKSRC}/generic/*.[ch]
@${REINPLACE_CMD} -e 's, * ,,' ${WRKSRC}/generic/*.[ch]
do-install:
${MKDIR} ${SQL_DIR}
${INSTALL_DATA} ${WRKSRC}/${LIB_NAME} ${SQL_DIR}
${ECHO} "package ifneeded mysqltcl ${PORTVERSION} {load ${SQL_DIR}/${LIB_NAME}}" \
@${MKDIR} ${SQL_DIR}
@${INSTALL_DATA} ${WRKSRC}/${LIB_NAME} ${SQL_DIR}
@${ECHO} "package ifneeded mysqltcl ${PORTVERSION} {load ${SQL_DIR}/${LIB_NAME}}" \
> ${SQL_DIR}/pkgIndex.tcl
${INSTALL_MAN} ${WRKSRC}/doc/${MANN} ${PREFIX}/man/mann
@${INSTALL_MAN} ${WRKSRC}/doc/${MANN} ${PREFIX}/man/mann
post-install:
@${TEST} ! -f ${PKGMESSAGE} || ${CAT} ${PKGMESSAGE}
.include <bsd.port.mk>
.if ${MYSQL_VER} == 323 || ${MYSQL_VER} == 40
PKGMESSAGE= ${PKGDIR}/pkg-message-legacy
.endif
LIB_NAME!= ${MAKE_ENV} ${MAKE} -f ${FILESDIR}/Makefile.bsd -V SHLIB_NAME

View File

@ -0,0 +1,305 @@
--- generic/mysqltcl.c.orig Wed Jan 11 21:08:48 2006
+++ generic/mysqltcl.c Wed Jan 11 21:17:10 2006
@@ -95,6 +95,8 @@
/* C variable corresponding to mysqlstatus(nullvalue) */
#define MYSQL_NULLV_INIT ""
+#define FUNCTION_NOT_AVAILABLE "function not available"
+
/* Check Level for mysql_prologue */
enum CONNLEVEL {CL_PLAIN,CL_CONN,CL_DB,CL_RES};
@@ -183,7 +185,6 @@
static int MysqlNullSet(Tcl_Interp *interp, Tcl_Obj *objPtr)
{
Tcl_ObjType *oldTypePtr = objPtr->typePtr;
- Tcl_HashEntry *entryPtr;
if ((oldTypePtr != NULL) && (oldTypePtr->freeIntRepProc != NULL)) {
oldTypePtr->freeIntRepProc(objPtr);
@@ -803,6 +804,7 @@
if (booleanflag)
flags |= CLIENT_ODBC;
break;
+#if (MYSQL_VERSION_ID >= 40107)
case MYSQL_MULTISTATEMENT_OPT:
if (Tcl_GetBooleanFromObj(interp,objv[++i],&booleanflag) != TCL_OK )
return TCL_ERROR;
@@ -817,6 +819,7 @@
if (booleanflag)
flags |= CLIENT_MULTI_RESULTS;
break;
+#endif
case MYSQL_LOCALFILES_OPT:
if (Tcl_GetBooleanFromObj(interp,objv[++i],&booleanflag) != TCL_OK )
@@ -876,9 +879,11 @@
#if (MYSQL_VERSION_ID>=32350)
mysql_options(handle->connection,MYSQL_READ_DEFAULT_GROUP,groupname);
#endif
+#if (MYSQL_VERSION_ID >= 40107)
if (isSSL) {
mysql_ssl_set(handle->connection,sslkey,sslcert, sslca, sslcapath, sslcipher);
}
+#endif
if (!mysql_real_connect(handle->connection, hostname, user,
password, db, port, socket, flags)) {
@@ -1388,8 +1393,8 @@
static int Mysqltcl_Receive(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
MysqltclState *statePtr = (MysqltclState *)clientData;
- int code ;
- int count ;
+ int code = TCL_ERROR;
+ int count = 0;
MysqlTclHandle *handle;
int idx ;
@@ -1397,7 +1402,6 @@
Tcl_Obj** listObjv ;
MYSQL_ROW row ;
int *val = NULL;
- int breakLoop = 0;
unsigned long *lengths;
@@ -1455,15 +1459,9 @@
switch(code=Tcl_EvalObjEx(interp, objv[4],0)) {
case TCL_CONTINUE:
case TCL_OK:
- break ;
- case TCL_BREAK:
- breakLoop=1;
- break;
- default:
- breakLoop=1;
- break;
+ continue;
}
- if (breakLoop==1) break;
+ break;
}
}
if (val!=NULL) {
@@ -1592,6 +1590,7 @@
Tcl_SetObjResult(interp, Tcl_NewStringObj(val,-1));
}
break;
+#if (MYSQL_VERSION_ID >= 40107)
case MYSQL_INF_SERVERVERSION:
Tcl_SetObjResult(interp, Tcl_NewStringObj(mysql_get_server_info(handle->connection),-1));
break;
@@ -1604,6 +1603,7 @@
case MYSQL_INFO_STATE:
Tcl_SetObjResult(interp, Tcl_NewStringObj(mysql_stat(handle->connection),-1));
break;
+#endif
default: /* should never happen */
return mysql_prim_confl(interp,objc,objv,"weirdness in Mysqltcl_Info") ;
}
@@ -1625,6 +1625,7 @@
int idx ;
Tcl_Obj *resList;
char **option;
+#if (MYSQL_VERSION_ID >= 40107)
static CONST char* MysqlInfoOpt[] =
{
"connectparameters", "clientversion","clientversionid", NULL
@@ -1632,6 +1633,15 @@
enum baseoption {
MYSQL_BINFO_CONNECT, MYSQL_BINFO_CLIENTVERSION,MYSQL_BINFO_CLIENTVERSIONID
};
+#else
+ static CONST char* MysqlInfoOpt[] =
+ {
+ "connectparameters", "clientversion", NULL
+ };
+ enum baseoption {
+ MYSQL_BINFO_CONNECT, MYSQL_BINFO_CLIENTVERSION
+ };
+#endif
if (objc <2) {
Tcl_WrongNumArgs(interp, 1, objv, "connectparameters | clientversion");
@@ -1657,9 +1667,11 @@
case MYSQL_BINFO_CLIENTVERSION:
Tcl_SetObjResult(interp, Tcl_NewStringObj(mysql_get_client_info(),-1));
break;
+#if (MYSQL_VERSION_ID >= 40107)
case MYSQL_BINFO_CLIENTVERSIONID:
Tcl_SetObjResult(interp, Tcl_NewIntObj(mysql_get_client_version()));
break;
+#endif
}
return TCL_OK ;
}
@@ -1974,6 +1986,10 @@
static int Mysqltcl_AutoCommit(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
+#if (MYSQL_VERSION_ID < 40107)
+ Tcl_AddErrorInfo(interp, FUNCTION_NOT_AVAILABLE);
+ return TCL_ERROR;
+#else
MysqlTclHandle *handle;
int isAutocommit = 0;
@@ -1986,6 +2002,7 @@
mysql_server_confl(interp,objc,objv,handle->connection);
}
return TCL_OK;
+#endif
}
/*
*----------------------------------------------------------------------
@@ -1997,6 +2014,10 @@
static int Mysqltcl_Commit(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
+#if (MYSQL_VERSION_ID < 40107)
+ Tcl_AddErrorInfo(interp, FUNCTION_NOT_AVAILABLE);
+ return TCL_ERROR;
+#else
MysqlTclHandle *handle;
if ((handle = mysql_prologue(interp, objc, objv, 2, 2, CL_CONN,
@@ -2006,6 +2027,7 @@
mysql_server_confl(interp,objc,objv,handle->connection);
}
return TCL_OK;
+#endif
}
/*
*----------------------------------------------------------------------
@@ -2017,6 +2039,10 @@
static int Mysqltcl_Rollback(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
+#if (MYSQL_VERSION_ID < 40107)
+ Tcl_AddErrorInfo(interp, FUNCTION_NOT_AVAILABLE);
+ return TCL_ERROR;
+#else
MysqlTclHandle *handle;
if ((handle = mysql_prologue(interp, objc, objv, 2, 2, CL_CONN,
@@ -2026,6 +2052,7 @@
mysql_server_confl(interp,objc,objv,handle->connection);
}
return TCL_OK;
+#endif
}
/*
*----------------------------------------------------------------------
@@ -2037,6 +2064,10 @@
static int Mysqltcl_MoreResult(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
+#if (MYSQL_VERSION_ID < 40107)
+ Tcl_AddErrorInfo(interp, FUNCTION_NOT_AVAILABLE);
+ return TCL_ERROR;
+#else
MysqlTclHandle *handle;
int boolResult = 0;
@@ -2046,6 +2077,7 @@
boolResult = mysql_more_results(handle->connection);
Tcl_SetObjResult(interp,Tcl_NewBooleanObj(boolResult));
return TCL_OK;
+#endif
}
/*
@@ -2059,6 +2091,10 @@
static int Mysqltcl_NextResult(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
+#if (MYSQL_VERSION_ID < 40107)
+ Tcl_AddErrorInfo(interp, FUNCTION_NOT_AVAILABLE);
+ return TCL_ERROR;
+#else
MysqlTclHandle *handle;
int result = 0;
@@ -2085,6 +2121,7 @@
Tcl_SetObjResult(interp, Tcl_NewIntObj(handle->res_count));
}
return TCL_OK;
+#endif
}
/*
*----------------------------------------------------------------------
@@ -2096,6 +2133,10 @@
static int Mysqltcl_WarningCount(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
+#if (MYSQL_VERSION_ID < 40107)
+ Tcl_AddErrorInfo(interp, FUNCTION_NOT_AVAILABLE);
+ return TCL_ERROR;
+#else
MysqlTclHandle *handle;
int count = 0;
@@ -2105,6 +2146,7 @@
count = mysql_warning_count(handle->connection);
Tcl_SetObjResult(interp,Tcl_NewIntObj(count));
return TCL_OK;
+#endif
}
/*
*----------------------------------------------------------------------
@@ -2149,7 +2191,6 @@
static int Mysqltcl_NewNull(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Tcl_Obj *objPtr;
if (objc != 1) {
Tcl_WrongNumArgs(interp, 1, objv, "");
return TCL_ERROR;
@@ -2164,13 +2205,19 @@
* usage: mysql::setserveroption (-
*
*/
+#if (MYSQL_VERSION_ID >= 40107)
static CONST char* MysqlServerOpt[] =
{
"-multi_statment_on", "-multi_statment_off",NULL
};
+#endif
static int Mysqltcl_SetServerOption(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
+#if (MYSQL_VERSION_ID < 40107)
+ Tcl_AddErrorInfo(interp, FUNCTION_NOT_AVAILABLE);
+ return TCL_ERROR;
+#else
MysqlTclHandle *handle;
int idx;
enum enum_mysql_set_option mysqlServerOption;
@@ -2201,6 +2248,7 @@
mysql_server_confl(interp,objc,objv,handle->connection);
}
return TCL_OK;
+#endif
}
/*
*----------------------------------------------------------------------
@@ -2211,6 +2259,10 @@
*/
static int Mysqltcl_ShutDown(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
+#if (MYSQL_VERSION_ID < 40107)
+ Tcl_AddErrorInfo(interp, FUNCTION_NOT_AVAILABLE);
+ return TCL_ERROR;
+#else
MysqlTclHandle *handle;
if ((handle = mysql_prologue(interp, objc, objv, 2, 2, CL_CONN,
@@ -2220,6 +2272,7 @@
mysql_server_confl(interp,objc,objv,handle->connection);
}
return TCL_OK;
+#endif
}
/*
*----------------------------------------------------------------------

View File

@ -1,45 +0,0 @@
--- generic/mysqltcl.c Mon Dec 27 07:34:33 2004
+++ generic/mysqltcl.c Sun Jul 31 19:43:08 2005
@@ -184,5 +184,4 @@
{
Tcl_ObjType *oldTypePtr = objPtr->typePtr;
- Tcl_HashEntry *entryPtr;
if ((oldTypePtr != NULL) && (oldTypePtr->freeIntRepProc != NULL)) {
@@ -1389,6 +1388,6 @@
{
MysqltclState *statePtr = (MysqltclState *)clientData;
- int code ;
- int count ;
+ int code = TCL_ERROR;
+ int count = 0;
MysqlTclHandle *handle;
@@ -1398,5 +1397,4 @@
MYSQL_ROW row ;
int *val = NULL;
- int breakLoop = 0;
unsigned long *lengths;
@@ -1456,13 +1454,7 @@
case TCL_CONTINUE:
case TCL_OK:
- break ;
- case TCL_BREAK:
- breakLoop=1;
- break;
+ continue;
- default:
- breakLoop=1;
- break;
}
- if (breakLoop==1) break;
+ break;
}
}
@@ -2150,5 +2143,4 @@
static int Mysqltcl_NewNull(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Tcl_Obj *objPtr;
if (objc != 1) {
Tcl_WrongNumArgs(interp, 1, objv, "");

View File

@ -1,17 +1,14 @@
From the package man-page:
MySQLTcl is a collection of Tcl commands and a Tcl global
array that provide access to one or more mysql database
servers.
MySQLTcl is a collection of Tcl commands and a Tcl global array that
provide access to MySQL database servers.
MySQLTcl is nothing more than a patched version of a
patched version of Hakan Soderstrom's patch of Tom
Poindexter's Sybtcl. Most of the documentention has been
left as it was when I started to work with this interface
(a patch of msqltcl-1.50). However, I have tried to
replace appropriate occurrences of msql by MySQL.
MySQLTcl is nothing more than a patched version of a patched version of
Hakan Soderstrom's patch of Tom Poindexter's Sybtcl.
This port makes use of some of the Tcl-8.x niceties, but more on that
front can be done.
Mysqltcl is binary Tcl library (extension) written in C language that
use direkt official MySQL C-API. Almost all Tcl commands correspond to
MySQL C-API functions. For detail documentation see official MySQL C-
API manual.
WWW: http://www.xdobry.de/mysqltcl/

View File

@ -0,0 +1,25 @@
######################################################################
Attention!
This version of mysqltcl contains an unofficial patch that
allows you to use this Tcl module with MySQL 3.23 and 4.0.
Due to restrictions of the underlying MySQL version the
use of the following functions will always cause an error:
- autocommit
- commit
- rollback
- moreresult
- nextresult
- warningcount
- setserverversion
- shutdown
This is not supported by the author of mysqltcl. Please
send comments and questions solely to me.
- Björn König
bkoenig@cs.tu-berlin.de
######################################################################