Date: Mon, 28 Jul 2014 15:51:59 +0000 (UTC) From: Adam Weinberger <adamw@FreeBSD.org> To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r363190 - in head/databases: dbf2mysql/files jdb/files rdb/files sybtcl/files tcl-Mysql/files Message-ID: <201407281551.s6SFpxbb035777@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: adamw Date: Mon Jul 28 15:51:59 2014 New Revision: 363190 URL: http://svnweb.freebsd.org/changeset/ports/363190 QAT: https://qat.redports.org/buildarchive/r363190/ Log: Rename databases/ patch-xy patches to reflect the files they modify. Added: head/databases/dbf2mysql/files/patch-Makefile - copied unchanged from r363137, head/databases/dbf2mysql/files/patch-aa head/databases/dbf2mysql/files/patch-dbf2mysql.c - copied unchanged from r363137, head/databases/dbf2mysql/files/patch-ab head/databases/jdb/files/patch-no-FileCache - copied unchanged from r363137, head/databases/jdb/files/patch-ab head/databases/rdb/files/patch-rdb - copied unchanged from r363137, head/databases/rdb/files/patch-aa head/databases/sybtcl/files/patch-generic_sybtcl.c - copied unchanged from r363137, head/databases/sybtcl/files/patch-aa head/databases/tcl-Mysql/files/patch-docs_api.html - copied unchanged from r363137, head/databases/tcl-Mysql/files/patch-ab head/databases/tcl-Mysql/files/patch-sql.cc - copied unchanged from r363137, head/databases/tcl-Mysql/files/patch-aa Deleted: head/databases/dbf2mysql/files/patch-aa head/databases/dbf2mysql/files/patch-ab head/databases/jdb/files/patch-ab head/databases/rdb/files/patch-aa head/databases/sybtcl/files/patch-aa head/databases/tcl-Mysql/files/patch-aa head/databases/tcl-Mysql/files/patch-ab Copied: head/databases/dbf2mysql/files/patch-Makefile (from r363137, head/databases/dbf2mysql/files/patch-aa) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/databases/dbf2mysql/files/patch-Makefile Mon Jul 28 15:51:59 2014 (r363190, copy of r363137, head/databases/dbf2mysql/files/patch-aa) @@ -0,0 +1,35 @@ +--- Makefile.orig Fri Jul 7 20:19:19 2000 ++++ Makefile Wed Feb 7 13:07:42 2001 +@@ -2,27 +2,27 @@ + # Maarten Boekhold (boekhold@cindy.et.tudelft.nl) 1995 + + # Set this to your C-compiler +-CC=gcc ++CC?=gcc + + # set this to your install-program (what does Solaris have + # in /usr/sbin/install? SYSV install?) + INSTALL=/usr/bin/install + + #AR=/usr/bin/ar +-AR=ar ++AR?=ar + + # Set this to whatever your compiler accepts. Nothing special is needed + #CFLAGS=-g -Wall -pedantic -include /usr/include/mpatrol.h + #CFLAGS=-g -Wall +-CFLAGS=-O2 -Wall ++CFLAGS?=-O2 -Wall + + # Set this to make smaller binaries + #STRIP= + STRIP=-s + + # Set this to your MySQL installation-path +-MYSQLINC=-I/usr/include/mysql +-MYSQLLIB=-L/usr/lib/mysql ++MYSQLINC=-I${PREFIX}/include/mysql ++MYSQLLIB=-L${PREFIX}/lib/mysql + + # Set this to where you want the binary (no man-page yet, don't know + # how to write them) Copied: head/databases/dbf2mysql/files/patch-dbf2mysql.c (from r363137, head/databases/dbf2mysql/files/patch-ab) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/databases/dbf2mysql/files/patch-dbf2mysql.c Mon Jul 28 15:51:59 2014 (r363190, copy of r363137, head/databases/dbf2mysql/files/patch-ab) @@ -0,0 +1,199 @@ +--- dbf2mysql.c.orig Fri Jul 7 04:55:02 2000 ++++ dbf2mysql.c Mon Mar 15 16:46:17 2004 +@@ -9,6 +9,12 @@ + Fixxed Quick mode insert for blank Numeric fields + Modified to use -x flag to add _rec and _timestamp fields to start of record. + ( only those lines immediately affect by if(express) (and getopt) ) ++ ++ Bart Friederichs (bart@friesoft.nl) feb 2003 ++ Added MYSQL_OPT_LOCAL_INFILE to options for compatibility with ++ MySQL >3.23.49 and >4.0.2, new option -L enables it ++ Replaced mysql_connect with mysql_real_connect, SQLsock isn't used anymore ++ + */ + #include <stdio.h> + #include <fcntl.h> +@@ -17,10 +23,15 @@ + #include <string.h> + #include <ctype.h> + #include <mysql.h> ++#include <paths.h> + #include "dbf.h" + ++#if !defined(_PATH_TMP) ++#define _PATH_TMP "/tmp/" ++#endif ++ + int verbose=0, upper=0, lower=0, create=0, fieldlow=0, var_chars=1; +-int express=0; ++int express=0, enable_local=0; + int null_fields=0, trim=0, quick=0; + char primary[11]; + char *host = NULL; +@@ -79,7 +90,7 @@ + printf("dbf2mysql %s\n", VERSION); + printf("usage: dbf2mysql [-h hostname] [-d dbase] [-t table] [-p primary key]\n"); + printf(" [-o field[,field]] [-s oldname=newname[,oldname=newname]]\n"); +- printf(" [-i field[,field]] [-c] [-f] [-F] [-n] [-r] [-u|-l] \n"); ++ printf(" [-i field[,field]] [-c] [-f] [-F] [-n] [-r] [-u|-l] [-L]\n"); + printf(" [-v[v]] [-x] [-q] [-P password] [-U user] dbf-file\n"); + } + +@@ -319,7 +330,7 @@ + /* Patched by GLC to fix quick mode Numeric fields */ + void do_inserts(MYSQL *SQLsock, char *table, dbhead *dbh) + { +- int result, i, j, nc = 0, h; ++ int result, i, j, nc = 0, h, fd; + field *fields; + char *query, *vpos, *pos; + char str[257], *cvt = NULL, *s; +@@ -395,9 +406,17 @@ + strcat(query, "NULL,NULL,"); + else /* if specified -q create file for 'LOAD DATA' */ + { +- datafile = tempnam ("/tmp", "d2my"); +- tempfile = fopen (datafile, "wt"); +- if (tempfile == NULL || datafile == NULL) ++ if (asprintf(&datafile, "%s/d2myXXXXXXXX", ++ getenv("TMPDIR") ? getenv("TMPDIR") : _PATH_TMP) == -1) { ++ fprintf (stderr, "asprintf() failed"); ++ return; ++ } ++ if ((fd = mkstemp(datafile)) == -1) { ++ fprintf (stderr, "mkstemp() failed"); ++ return; ++ } ++ tempfile = fdopen (fd, "w"); ++ if (tempfile == NULL) + { + fprintf (stderr, "Cannot open file '%s' for writing\n", datafile); + return; +@@ -575,7 +594,7 @@ + } + if (mysql_query(SQLsock, query) == -1) { + fprintf(stderr, +- "Error sending LOAD DATA INFILE from file '%s'\n", datafile); ++ "Error sending LOAD DATA LOCAL INFILE from file '%s'\n", datafile); + fprintf(stderr, + "Detailed report: %s\n", + mysql_error(SQLsock)); +@@ -591,7 +610,7 @@ + int main(int argc, char **argv) + { + int i; +- MYSQL *SQLsock,mysql; ++ MYSQL mysql; + extern int optind; + extern char *optarg; + char *query; +@@ -599,7 +618,7 @@ + + primary[0] = '\0'; + +- while ((i = getopt(argc, argv, "xqfFrne:lucvi:h:p:d:t:s:o:U:P:")) != EOF) { ++ while ((i = getopt(argc, argv, "xqLfFrne:lucvi:h:p:d:t:s:o:U:P:")) != EOF) { + switch (i) { + case 'P': + pass = (char *)strdup(optarg); +@@ -666,6 +685,9 @@ + case 'o': + flist = (char *)strdup(optarg); + break; ++ case 'L': ++ enable_local = 1; ++ break; + case ':': + usage(); + printf("missing argument!\n"); +@@ -704,6 +726,7 @@ + table); + printf("Number of records: %ld\n", dbh->db_records); + } ++ + if (verbose > 1) { + printf("Name\t\t Length\tDisplay\t Type\n"); + printf("-------------------------------------\n"); +@@ -720,7 +743,20 @@ + printf("Making connection to MySQL-server\n"); + } + +- if (!(SQLsock = mysql_connect(&mysql,host,user,pass))) { ++ mysql_init(&mysql); ++ ++ if (enable_local == 1) { ++ if (verbose) { ++ printf("Setting MySQL option MYSQL_OPT_LOCAL_INFILE\n"); ++ } ++ ++ if (mysql_options(&mysql, MYSQL_OPT_LOCAL_INFILE, 0)) { ++ printf("Setting options failed."); ++ exit(1); ++ } ++ } ++ ++ if (!mysql_real_connect(&mysql,host,user,pass, dbase, 0, NULL,0)) { + fprintf(stderr, "Couldn't get a connection with the "); + fprintf(stderr, "designated host!\n"); + fprintf(stderr, "Detailed report: %s\n", mysql_error(&mysql)); +@@ -728,23 +764,12 @@ + exit(1); + } + +- if (verbose > 2) { +- printf("Selecting database '%s'\n", dbase); +- } +- +- if ((mysql_select_db(SQLsock, dbase)) == -1) { +- fprintf(stderr, "Couldn't select database %s.\n", dbase); +- fprintf(stderr, "Detailed report: %s\n", mysql_error(SQLsock)); +- mysql_close(SQLsock); +- dbf_close(&dbh); +- exit(1); +- } + /* Substitute field names */ + do_onlyfields(flist, dbh); + do_substitute(subarg, dbh); + + if (!create) { +- if (!check_table(SQLsock, table)) { ++ if (!check_table(&mysql, table)) { + printf("Table does not exist!\n"); + exit(1); + } +@@ -755,30 +780,30 @@ + + if (!(query = (char *)malloc(12 + strlen(table)))) { + printf("Memory-allocation error in main (drop)!\n"); +- mysql_close(SQLsock); ++ mysql_close(&mysql); + dbf_close(&dbh); + exit(1); + } + + sprintf(query, "DROP TABLE %s", table); +- mysql_query(SQLsock, query); ++ mysql_query(&mysql, query); + free(query); + + /* Build a CREATE-clause + */ +- do_create(SQLsock, table, dbh); ++ do_create(&mysql, table, dbh); + } + + /* Build an INSERT-clause + */ + if (create < 2) +- do_inserts(SQLsock, table, dbh); ++ do_inserts(&mysql, table, dbh); + + if (verbose > 2) { + printf("Closing up....\n"); + } + +- mysql_close(SQLsock); ++ mysql_close(&mysql); + dbf_close(&dbh); + exit(0); + } Copied: head/databases/jdb/files/patch-no-FileCache (from r363137, head/databases/jdb/files/patch-ab) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/databases/jdb/files/patch-no-FileCache Mon Jul 28 15:51:59 2014 (r363190, copy of r363137, head/databases/jdb/files/patch-ab) @@ -0,0 +1,91 @@ +--- dbcolmultiscale.O Wed Feb 12 15:15:35 2003 ++++ dbcolmultiscale Wed Feb 12 15:15:50 2003 +@@ -127,7 +127,6 @@ + push(@INC, $dblibdir); + } + use DbGetopt; +-use FileCache; + require "$dblibdir/dblib.pl"; + + @orig_argv = @ARGV; +--- dbmultistats.O Wed Feb 12 15:08:07 2003 ++++ dbmultistats Wed Feb 12 15:09:28 2003 +@@ -57,7 +57,6 @@ + push(@INC, $dblibdir); + } + use DbGetopt; +-use FileCache; + require "$dblibdir/dblib.pl"; + + @orig_argv = @ARGV; +@@ -112,13 +111,13 @@ + # open a new file + $path = $tag_files{$tag} = &db_tmpfile(TMP); + close(TMP); +- cacheout $path; +- print $path "$col_headertag data\n"; ++ open PATH, ">>$path"; ++ print PATH "$col_headertag data\n"; + $tag_counts{$tag} = 1; + }; + $path = $tag_files{$tag}; +- cacheout $path; +- print $path "$val\n"; ++ open PATH, ">>$path"; ++ print PATH "$val\n"; + }; + + @dbstats_args = ("$dbbindir/dbstats"); +@@ -131,8 +130,7 @@ + foreach $tag (sort keys %tag_files) { + # close it + $path = $tag_files{$tag}; +- cacheout $path; +- close($path); ++ close(PATH); + + open(FROMMEAN, join(" ", @dbstats_args) . " <$tag_files{$tag} |") || die "$prog: cannot run dbstats.\n"; + @meanout = <FROMMEAN>; +--- dbrowsplituniq.O Wed Feb 12 15:10:08 2003 ++++ dbrowsplituniq Wed Feb 12 15:14:43 2003 +@@ -77,7 +77,6 @@ + require "$dblibdir/dblib.pl"; + use DbGetopt; + use English; +-use FileCache; + + @orig_argv = @ARGV; + my($prog) = &progname; +@@ -130,8 +129,8 @@ + my($path) = $prefix . $index . ".jdb"; + $index++; + $keys_to_paths{$key} = $path; +- cacheout $path; +- write_header_fh_tag($path, $col_headertag); ++ open $fh, ">>$path"; ++ write_header_fh_tag($fh, $col_headertag); + return $path; + } + +@@ -141,15 +140,15 @@ + &split_cols; + ] . $code . q[ + my($path) = &key_to_path($key); +- cacheout $path; +- write_these_cols_fh($path, @f); ++ open $fh, ">>$path"; ++ write_these_cols_fh($fh, @f); + }; + # cleanup + foreach (values %keys_to_paths) { +- cacheout $_; +- delayed_write_comments($_); +- print $_ "# | $prog ", join(" ", @orig_argv), "\n"; +- close $_; ++ open $fh, ">>$_"; ++ delayed_write_comments($fh); ++ print $fh "# | $prog ", join(" ", @orig_argv), "\n"; ++ close $fh; + }; + ]; + print $loop if ($debug); Copied: head/databases/rdb/files/patch-rdb (from r363137, head/databases/rdb/files/patch-aa) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/databases/rdb/files/patch-rdb Mon Jul 28 15:51:59 2014 (r363190, copy of r363137, head/databases/rdb/files/patch-aa) @@ -0,0 +1,14 @@ +*** rdb~ Wed Jul 16 10:23:13 1997 +--- rdb Wed Feb 9 20:01:38 2000 +*************** +*** 155,158 **** + Jones XY 77 47 + EOF + $helpinfo .= "\n$RCS_ID\n" ; +! system "echo \"$helpinfo\" | less" ; +--- 155,159 ---- + Jones XY 77 47 + EOF + $helpinfo .= "\n$RCS_ID\n" ; +! $pager = $ENV{'PAGER'} ? $ENV{'PAGER'} : "more"; +! system "echo \"$helpinfo\" | $pager" ; Copied: head/databases/sybtcl/files/patch-generic_sybtcl.c (from r363137, head/databases/sybtcl/files/patch-aa) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/databases/sybtcl/files/patch-generic_sybtcl.c Mon Jul 28 15:51:59 2014 (r363190, copy of r363137, head/databases/sybtcl/files/patch-aa) @@ -0,0 +1,342 @@ +--- generic/sybtcl.c 2000-08-30 20:24:18.000000000 -0400 ++++ generic/sybtcl.c 2007-10-12 16:54:36.000000000 -0400 +@@ -178,5 +178,6 @@ + #endif + +-#include "tcl.h" ++#include <strings.h> ++#include <tcl.h> + + +@@ -279,4 +280,12 @@ + #endif + ++#ifndef CS_INTERNAL ++#define CS_INTERNAL /* Not defined by FreeTDS */ ++#endif ++ ++#ifndef TDS_DEF_CHARSET ++#define TDS_DEF_CHARSET "iso_1" /* Not defined by Sybase */ ++#endif ++ + typedef struct SybTclProcs { /* struct for handle entries */ + int in_use; /* if this entry is opened */ +@@ -393,5 +402,5 @@ + #else + +-extern void * malloc(); ++#include <stdlib.h> + + #endif +@@ -428,22 +437,22 @@ + /* prototypes for all tcl command functions */ + +-EXTERN Sybtcl_Init _ANSI_ARGS_((Tcl_Interp *interp)); +-EXTERN Sybtcl_SafeInit _ANSI_ARGS_((Tcl_Interp *interp)); ++EXTERN int Sybtcl_Init _ANSI_ARGS_((Tcl_Interp *interp)); ++EXTERN int Sybtcl_SafeInit _ANSI_ARGS_((Tcl_Interp *interp)); + +-extern Tcl_ObjCmdProc Sybtcl_Connect; +-extern Tcl_ObjCmdProc Sybtcl_ErrHandler; +-extern Tcl_ObjCmdProc Sybtcl_MsgHandler; +-extern Tcl_ObjCmdProc Sybtcl_Money; +-extern Tcl_ObjCmdProc Sybtcl_Use; +-extern Tcl_ObjCmdProc Sybtcl_Sql; +-extern Tcl_ObjCmdProc Sybtcl_Poll; +-extern Tcl_ObjCmdProc Sybtcl_Next; +-extern Tcl_ObjCmdProc Sybtcl_Cols; +-extern Tcl_ObjCmdProc Sybtcl_Cancel; +-extern Tcl_ObjCmdProc Sybtcl_Close; +-extern Tcl_ObjCmdProc Sybtcl_Retval; +-extern Tcl_ObjCmdProc Sybtcl_Wrtext; +-extern Tcl_ObjCmdProc Sybtcl_Rdtext; +-extern Tcl_ObjCmdProc Sybtcl_Event; ++static Tcl_ObjCmdProc Sybtcl_Connect; ++static Tcl_ObjCmdProc Sybtcl_ErrHandler; ++static Tcl_ObjCmdProc Sybtcl_MsgHandler; ++static Tcl_ObjCmdProc Sybtcl_Money; ++static Tcl_ObjCmdProc Sybtcl_Use; ++static Tcl_ObjCmdProc Sybtcl_Sql; ++static Tcl_ObjCmdProc Sybtcl_Poll; ++static Tcl_ObjCmdProc Sybtcl_Next; ++static Tcl_ObjCmdProc Sybtcl_Cols; ++static Tcl_ObjCmdProc Sybtcl_Cancel; ++static Tcl_ObjCmdProc Sybtcl_Close; ++static Tcl_ObjCmdProc Sybtcl_Retval; ++static Tcl_ObjCmdProc Sybtcl_Wrtext; ++static Tcl_ObjCmdProc Sybtcl_Rdtext; ++static Tcl_ObjCmdProc Sybtcl_Event; + + +@@ -461,8 +470,10 @@ + Tcl_Interp *interp)); + ++#ifdef POLLED_EVENTS + static int dbEventProc _ANSI_ARGS_((Tcl_Event *evPtr, int flags)); + static void dbSetupProc _ANSI_ARGS_((ClientData cd_hand, int flags)); + static void dbCheckProc _ANSI_ARGS_((ClientData cd_hand, int flags)); +-void Sybtcl_Kill _ANSI_ARGS_((ClientData clientData)); ++#endif ++static void Sybtcl_Kill _ANSI_ARGS_((ClientData clientData)); + static int CS_INTERNAL syb_tcl_err_handler _ANSI_ARGS_(( + DBPROCESS *db_proc, +@@ -496,4 +507,5 @@ + + ++#ifdef POLLED_EVENTS /* { */ + /* + *---------------------------------------------------------------------- +@@ -566,5 +578,5 @@ + } + } +- ++#endif /* POLLED_EVENTS } */ + + +@@ -609,5 +621,4 @@ + { + dbState *statePtr = (dbState *) instanceData; +- int hand = statePtr->hand; + + #ifdef POLLED_EVENTS +@@ -641,5 +652,5 @@ + dbState *statePtr = (dbState *) instanceData; + +- *handlePtr = (ClientData)statePtr->fd; ++ *handlePtr = (ClientData)(intptr_t)statePtr->fd; + return TCL_OK; + } +@@ -661,5 +672,5 @@ + } + +-Tcl_Channel ++static Tcl_Channel + dbMakeChannel (sock, hand, channelName) + int sock; +@@ -1167,9 +1178,9 @@ + */ + ++CALLBACK_SCOPE Tcl_ChannelProc callback_handler; + static void + remove_handler (hand) + int hand; + { +- CALLBACK_SCOPE Tcl_ChannelProc callback_handler; + if (SybProcs[hand].callBackScript != NULL) { + Tcl_DecrRefCount(SybProcs[hand].callBackScript); +@@ -1177,8 +1188,8 @@ + if (SybProcs[hand].sybChan != NULL) { + Tcl_DeleteChannelHandler(SybProcs[hand].sybChan, +- callback_handler, (ClientData) hand); ++ callback_handler, (ClientData)(intptr_t)hand); + } + #ifdef POLLED_EVENTS +- Tcl_DeleteEventSource( dbSetupProc, dbCheckProc, (ClientData) hand); ++ Tcl_DeleteEventSource( dbSetupProc, dbCheckProc, (ClientData)(intptr_t)hand); + #endif + } +@@ -1451,4 +1462,16 @@ + &dateinfo,(DBDATETIME *) col_ptr); + j=0; ++#if defined(MSDBLIB) && !defined(dateyear) ++# define dateyear year ++# define datemonth month ++# define datedmonth day ++# define datedyear dayofyear ++# define datedweek weekday ++# define datehour hour ++# define dateminute minute ++# define datesecond second ++# define datemsecond millisecond ++# define datetzone tzone ++#endif + while((unsigned int) j < strlen(date_str)) { + if (!strncmp(&(date_str[j]),"YYYY",4)) { +@@ -1669,6 +1692,8 @@ + + +-#ifdef DBVERSION_100 ++#ifdef SYBBOUNDARY + case SYBBOUNDARY: ++#endif ++#ifdef SYBSENSITIVITY + case SYBSENSITIVITY: + #endif +@@ -1694,5 +1719,5 @@ + */ + +-void ++static void + Sybtcl_Kill (clientData) + ClientData clientData; +@@ -1776,5 +1801,5 @@ + */ + +-void ++static void + Sybtcl_DeleteInterp (clientData, interp) + ClientData clientData; +@@ -2429,5 +2454,5 @@ + */ + +-int ++static int + Sybtcl_ErrHandler (clientData, interp, objc, objv) + ClientData clientData; +@@ -2466,5 +2491,5 @@ + */ + +-int ++static int + Sybtcl_MsgHandler (clientData, interp, objc, objv) + ClientData clientData; +@@ -2505,5 +2530,5 @@ + */ + +-int ++static int + Sybtcl_Connect (clientData, interp, objc, objv) + ClientData clientData; +@@ -2556,5 +2581,7 @@ + + DBSETLUSER(login,Tcl_GetStringFromObj(objv[1],NULL)); +- DBSETLPWD(login, Tcl_GetStringFromObj(objv[2],NULL)); ++ server_str = Tcl_GetStringFromObj(objv[2],&len); ++ if (len > 0) ++ DBSETLPWD(login, server_str); + + /* check for server optional parameter */ +@@ -2594,8 +2621,8 @@ + DBSETLCHARSET(login, charset_str); + } else { +- DBSETLCHARSET(login, NULL); ++ DBSETLCHARSET(login, TDS_DEF_CHARSET); + } + } else { +- DBSETLCHARSET(login, NULL); ++ DBSETLCHARSET(login, TDS_DEF_CHARSET); + } + +@@ -2607,5 +2634,6 @@ + if (SybProcs[hand].dbproc == NULL) { + Sybtcl_AppendObjResult (interp, CMD_STR, +- ": sybconnect failed in dbopen", (char *) NULL); ++ ": sybconnect to ", server_str ? server_str : "(DEFAULT)", ++ " failed in dbopen", (char *) NULL); + return TCL_ERROR; + } +@@ -2673,4 +2701,5 @@ + */ + ++static int + Sybtcl_Money (clientData, interp, objc, objv) + ClientData clientData; +@@ -2788,4 +2817,5 @@ + */ + ++static int + Sybtcl_Use (clientData, interp, objc, objv) + ClientData clientData; +@@ -2850,4 +2880,5 @@ + */ + ++static int + Sybtcl_Sql (clientData, interp, objc, objv) + ClientData clientData; +@@ -2909,5 +2940,5 @@ + if (SybProcs[hand].last_text != SybOptions[i].maxtext) { + SybProcs[hand].last_text = SybOptions[i].maxtext; +- sprintf(conv_buf,"%d",SybOptions[i].maxtext); ++ sprintf(conv_buf,"%ld",SybOptions[i].maxtext); + dbsetopt(SybProcs[hand].dbproc, DBTEXTSIZE, conv_buf, -1); + dbsqlexec(SybProcs[hand].dbproc); /* execute dbsetopt() */ +@@ -3022,4 +3053,5 @@ + */ + ++static int + Sybtcl_Poll (clientData, interp, objc, objv) + ClientData clientData; +@@ -3551,4 +3583,5 @@ + */ + ++static int + Sybtcl_Next (clientData, interp, objc, objv) + ClientData clientData; +@@ -3819,4 +3852,5 @@ + */ + ++static int + Sybtcl_Cols (clientData, interp, objc, objv) + ClientData clientData; +@@ -3972,4 +4006,5 @@ + */ + ++static int + Sybtcl_Cancel (clientData, interp, objc, objv) + ClientData clientData; +@@ -4020,4 +4055,5 @@ + */ + ++static int + Sybtcl_Retval (clientData, interp, objc, objv) + ClientData clientData; +@@ -4091,4 +4127,5 @@ + */ + ++static int + Sybtcl_Close (clientData, interp, objc, objv) + ClientData clientData; +@@ -4167,4 +4204,5 @@ + */ + ++static int + Sybtcl_Wrtext (clientData, interp, objc, objv) + ClientData clientData; +@@ -4190,5 +4228,5 @@ + int obj_parm; + int isvar = 0; +- Tcl_Channel fd; ++ Tcl_Channel fd = NULL; + #ifndef MAC_TCL + struct stat stat_buf; +@@ -4305,5 +4343,6 @@ + txtptr = dbtxptr(SybProcs[hand].dbproc,col); + if (txtptr == NULL) { +- Tcl_Close (NULL,fd); ++ if (fd != NULL) ++ Tcl_Close (NULL,fd); + Sybtcl_AppendObjResult (interp, CMD_STR, + ": dbtxptr failed ", (char *) NULL); +@@ -4448,5 +4487,5 @@ + */ + +- ++static int + Sybtcl_Rdtext (clientData, interp, objc, objv) + ClientData clientData; +@@ -4638,5 +4677,5 @@ + int mask; + { +- int hand = (int) cd_hand; ++ int hand = (int)(intptr_t)cd_hand; + Tcl_Interp *interp = SybProcs[hand].interp; + DBPROCESS *readyproc; +@@ -4754,5 +4793,5 @@ + */ + +- ++static int + Sybtcl_Event (clientData, interp, objc, objv) + ClientData clientData; +@@ -4791,9 +4830,9 @@ + /* create handler */ + Tcl_CreateChannelHandler(SybProcs[hand].sybChan, TCL_READABLE, +- callback_handler, (ClientData) hand); ++ callback_handler, (ClientData)(intptr_t)hand); + + #ifdef POLLED_EVENTS + Tcl_CreateEventSource(dbSetupProc, dbCheckProc, +- (ClientData) hand); ++ (ClientData)(intptr_t)hand); + #endif + Copied: head/databases/tcl-Mysql/files/patch-docs_api.html (from r363137, head/databases/tcl-Mysql/files/patch-ab) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/databases/tcl-Mysql/files/patch-docs_api.html Mon Jul 28 15:51:59 2014 (r363190, copy of r363137, head/databases/tcl-Mysql/files/patch-ab) @@ -0,0 +1,52 @@ +--- docs/api.html Wed Jul 22 21:54:38 1998 ++++ docs/api.html Wed Jul 19 17:19:34 2000 +@@ -1,2 +1,5 @@ ++<HTML> ++<HEAD> + <title>Generic Tcl Database Interface API</title> ++</HEAD> + <BODY BGCOLOR="#ffffff" LINK="#0000ff" ALINK="#ff0000" TEXT="#000000"> +@@ -55,3 +58,3 @@ + statement). Use with <code><font color="#000099">fetchrow</font></code> and <code><font color="#000099">endquery</font></code>. <br> +- <code><font color="#000099">sql query $conn "select * from sample where x > 3"</font></code> ++ <code><font color="#000099">set query [sql query $conn "select * from sample where x > 3"]</font></code> + +@@ -62,3 +65,3 @@ + is returned.<br> +- <code><font color="#000099">while {[set row [sql fetchrow $conn]] != ""} { puts $row }</font></code> ++ <code><font color="#000099">while {[set row [sql fetchrow $conn $query]] != ""} { puts $row }</font></code> + +@@ -66,4 +69,4 @@ + <p> +-<hr width=50%> +-<a name=sample><h3>Sample Usage:</h3></a> ++<hr width="50%"> ++<h3><a name=sample>Sample Usage:</a></h3> + Also see +@@ -86,3 +89,3 @@ + # Put some dummy data in: +-for {set i 0} {$i < 10} {incr i} { ++for {set i 0} {$i < 10} {incr i} { + sql exec $conn "insert into junk values ($i, $i.01, 'xx $i xx')" +@@ -91,5 +94,5 @@ + # Do a select and display the results +-sql query $conn "select * from junk where i > 3" ++set query [sql query $conn "select * from junk where i > 3"] + +-while {[set row [sql fetchrow $conn]] != ""} { ++while {[set row [sql fetchrow $conn $query]] != ""} { + puts "row = $row" +@@ -97,3 +100,3 @@ + +-sql endquery $conn ++sql endquery $conn $query + +@@ -113 +116,3 @@ + </pre> ++</BODY> ++</HTML> + +>Release-Note: +>Audit-Trail: +>Unformatted: + Copied: head/databases/tcl-Mysql/files/patch-sql.cc (from r363137, head/databases/tcl-Mysql/files/patch-aa) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/databases/tcl-Mysql/files/patch-sql.cc Mon Jul 28 15:51:59 2014 (r363190, copy of r363137, head/databases/tcl-Mysql/files/patch-aa) @@ -0,0 +1,284 @@ +This patch substantially revamps the sql.cc to make use of and better +comply with Tcl-8.x object-paradigm. The correct programs will still +execute the same way, but in some erroneous cases the error messages may +be slightly different. The patch gets rid of a lot of sprintf and will +make your scripts faster, especially when fetching multiple rows of the +same queries. + +In modern MySQL mysql_error() returns a const-pointer, so getErrorMsg() +had to be changed. However, since we are using TCL_STATIC anyway, we can +just cast its result back down to plain char* + +--- sql.cc Fri Aug 13 15:28:56 1999 ++++ sql.cc Wed Nov 10 17:40:19 2004 +@@ -12,24 +12,11 @@ + +-const char* HANDLE_PREFIX = "sql"; +-const char* RESULT_PREFIX = "res"; +- +-// ------------------------------------------------------------- +-// Convert a tcl style connection to an interger +-// returns -1 on format error, +-int stripPrefix(char *txt, const char* prefix) { +- +- unsigned int prefixLen = strlen(prefix); +- +- if (strlen(txt) <= prefixLen || +- strncmp(txt, prefix, prefixLen)!=0) { +- return -1; +- } +- return (atoi(txt+prefixLen)); +-} ++#ifndef CONST84 ++# define CONST84 ++#endif + + // ------------------------------------------------------------- +-int selectdbCmd(Tcl_Interp *interp, Sql_interface *conn, char *dbname) { ++int selectdbCmd(Tcl_Interp *interp, Sql_interface *conn, Tcl_Obj *const dbname) { + +- if (conn->selectdb(dbname)) { +- Tcl_SetResult(interp, dbname, TCL_VOLATILE); ++ if (conn->selectdb(Tcl_GetString(dbname))) { ++ Tcl_SetObjResult(interp, dbname); + return TCL_OK; +@@ -38,3 +25,3 @@ + // An error occured. +- Tcl_SetResult(interp, conn->getErrorMsg(), TCL_VOLATILE); ++ Tcl_SetResult(interp, (char *)conn->getErrorMsg(), TCL_STATIC); + return TCL_ERROR; +@@ -47,3 +34,3 @@ + // An error occured. +- Tcl_SetResult(interp, conn->getErrorMsg(), TCL_VOLATILE); ++ Tcl_SetResult(interp, (char *)conn->getErrorMsg(), TCL_STATIC); + return TCL_ERROR; +@@ -60,9 +47,9 @@ + int queryCmd(Tcl_Interp *interp, Sql_interface *conn, char *cmd) { +- int handle = -1; ++ int handle; + if ((handle = conn->query(cmd)) < 0) { + // An error occured. +- Tcl_SetResult(interp, conn->getErrorMsg(), TCL_VOLATILE); ++ Tcl_SetResult(interp, (char *)conn->getErrorMsg(), TCL_STATIC); + return TCL_ERROR; + } +- sprintf(interp->result, "%s%d", RESULT_PREFIX, handle); ++ Tcl_SetObjResult(interp, Tcl_NewIntObj(handle)); + return TCL_OK; +@@ -71,7 +58,3 @@ + // ------------------------------------------------------------- +-int endqueryCmd(Tcl_Interp *interp, Sql_interface *conn, char *handle) { +- int resHandle = 0; +- if (handle) { +- resHandle = stripPrefix(handle, RESULT_PREFIX); +- } ++int endqueryCmd(Tcl_Interp *interp, Sql_interface *conn, int resHandle) { + conn->endquery(resHandle); +@@ -81,14 +64,4 @@ + // ------------------------------------------------------------- +-int numrowsCmd(Tcl_Interp *interp, Sql_interface *conn, char *handle) { +- int resHandle = 0; +- if (handle) { +- resHandle = stripPrefix(handle, RESULT_PREFIX); +- } +- int nrows = conn->numRows(resHandle); +- +- // Return the result of the command: +- char retval[20]; +- sprintf(retval, "%d", nrows); +- +- Tcl_SetResult(interp, retval, TCL_VOLATILE); ++int numrowsCmd(Tcl_Interp *interp, Sql_interface *conn, int resHandle) { ++ Tcl_SetObjResult(interp, Tcl_NewIntObj(conn->numRows(resHandle))); + return TCL_OK; +@@ -97,13 +70,3 @@ + // ------------------------------------------------------------- +-int fetchrowCmd(Tcl_Interp *interp, Sql_interface *conn, char *handle) { +- +- int resHandle = 0; +- if (handle) { +- resHandle = stripPrefix(handle, RESULT_PREFIX); +- } +- if (resHandle < 0) { +- Tcl_SetResult(interp, "Invalid result handle.", TCL_VOLATILE); +- return TCL_ERROR; +- } +- ++int fetchrowCmd(Tcl_Interp *interp, Sql_interface *conn, int resHandle) { + Sql_row *row; +@@ -124,6 +87,7 @@ + // +-int SqlCmd(ClientData clientData, Tcl_Interp *interp, int argc, char **argv) ++int SqlCmd(ClientData clientData, Tcl_Interp *interp, ++ int objc, Tcl_Obj * const objv[]) + { +- if (argc == 1) { +- Tcl_SetResult(interp, "Usage: sql command ?handle?", TCL_STATIC); ++ if (objc == 1) { ++ Tcl_WrongNumArgs(interp, 1, objv, "command ?handle?"); + return TCL_ERROR; +@@ -133,58 +97,58 @@ + Manager_sql *mgr = (Manager_sql *)clientData; +- int res = TCL_OK; ++ int res; + +- int c = -1; ++ int connid; + +- // ----------------------------------- +- if (strcmp(argv[1], "connect")==0) { +- c = mgr->connect(argc-2, argv+2); +- if (c < 0) { +- char *basemsg = "Unable to Connect: "; +- char *errmsg = mgr->getErrorMsg(); +- char *msg = Tcl_Alloc(strlen(errmsg)+strlen(basemsg)); +- strcpy(msg, basemsg); +- strcat(msg, errmsg); +- Tcl_SetResult(interp, msg, TCL_DYNAMIC); ++ static CONST84 char * subCmds[] = { ++ "exec", "query", "endquery", "fetchrow", ++ "numrows", "disconnect", "selectdb", "connect", ++ (char *)NULL ++ }; ++ enum e_subcommands { ++ Execute, Query, EndQuery, FetchRow, ++ NumRows, Disconnect, SelectDB, Connect ++ } subcommand; ++ if (Tcl_GetIndexFromObj(interp, objv[1], subCmds, "subcommand", 0, ++ (int *) &subcommand) != TCL_OK) return TCL_ERROR; ++ if (subcommand == Connect) { ++ char *argv[objc-2]; ++ for (res = 0; res < objc-2; res++) { ++ argv[res] = Tcl_GetString(objv[res+2]); ++ } ++ connid = mgr->connect(objc-2, argv); ++ if (connid < 0) { ++ Tcl_SetResult(interp, (char *)mgr->getErrorMsg(), TCL_STATIC); + return TCL_ERROR; + } +- char errormsg[16]; +- sprintf(errormsg, "%s%d", HANDLE_PREFIX, c); +- Tcl_SetResult(interp,errormsg,TCL_VOLATILE); +- /* sprintf(interp->result, "%s%d", HANDLE_PREFIX, c); */ ++ Tcl_SetObjResult(interp, Tcl_NewIntObj(connid)); + return TCL_OK; ++ } + +- } else { +- +- // Every other command needs a handle. Get it. +- int connid = -1; +- if (argc <= 2) { +- Tcl_SetResult(interp, "Usage:\nsql command handle", TCL_STATIC); +- return TCL_ERROR; +- } else if ((connid = stripPrefix(argv[2], HANDLE_PREFIX)) < 0) { +- Tcl_AppendResult(interp, "sql: Invalid handle: ", argv[2], NULL); +- return TCL_ERROR; +- } else if (!mgr->inUse(connid)) { +- // This connection is not currently being used +- Tcl_AppendResult(interp, "sql: not connected on handle ", argv[2], NULL); +- return TCL_ERROR; +- } +- Sql_interface *conn = mgr->connection(connid); ++ // Every other command needs a handle. Get it. ++ if (objc <= 2) { ++ Tcl_WrongNumArgs(interp, 2, objv, "handle"); ++ return TCL_ERROR; ++ } else if (Tcl_GetIntFromObj(NULL, objv[2], &connid) ++ != TCL_OK || connid < 0) { ++ Tcl_SetObjResult(interp, objv[2]); ++ Tcl_AppendResult(interp, ": invalid handle", NULL); ++ return TCL_ERROR; ++ } else if (!mgr->inUse(connid)) { ++ // This connection is not currently being used ++ Tcl_SetObjResult(interp, objv[2]); ++ Tcl_AppendResult(interp, ": not connected on " ++ "this handle", NULL); ++ return TCL_ERROR; ++ } ++ Sql_interface *conn = mgr->connection(connid); + +- // take care of the command: +- if (strcmp(argv[1], "exec") == 0) { +- res = execCmd(interp, conn, argv[3]); +- } else if (strcmp(argv[1], "query") == 0) { +- res = queryCmd(interp, conn, argv[3]); +- } else if (strcmp(argv[1], "endquery") == 0) { +- res = endqueryCmd(interp, conn, argv[3]); +- } else if (strcmp(argv[1], "fetchrow") == 0) { +- res = fetchrowCmd(interp, conn, argv[3]); +- } else if (strcmp(argv[1], "numrows") == 0) { +- res = numrowsCmd(interp, conn, argv[3]); +- } else if (strcmp(argv[1], "disconnect") == 0) { +- res = disconnectCmd(interp, mgr, connid); +- } else if (strcmp(argv[1], "selectdb")==0) { +- res = selectdbCmd(interp, conn, argv[3]); +- } else { +- Tcl_AppendResult(interp, "sql: unknown sql command: ", argv[1], NULL); ++ // take care of the command: ++ if (subcommand < Disconnect && subcommand > Query) { ++ /* get the "result handle" returned previously */ ++ if (objc < 4) res = 0; /* oddly, this is how it was -- bug? */ ++ else if (Tcl_GetIntFromObj(NULL, objv[3], &res) != TCL_OK || ++ res < 0) { ++ Tcl_SetObjResult(interp, objv[3]); ++ Tcl_AppendResult(interp, ": invalid result" ++ " handle", NULL); + return TCL_ERROR; +@@ -192,16 +156,26 @@ + } +- +- return res; +- ++ switch (subcommand) { ++ case Execute: ++ return execCmd(interp, conn, Tcl_GetString(objv[3])); ++ case Query: ++ return queryCmd(interp, conn, Tcl_GetString(objv[3])); ++ case EndQuery: ++ return endqueryCmd(interp, conn, res); ++ case FetchRow: ++ return fetchrowCmd(interp, conn, res); ++ case NumRows: ++ return numrowsCmd(interp, conn, res); ++ case Disconnect: ++ return disconnectCmd(interp, mgr, connid); ++ case SelectDB: *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201407281551.s6SFpxbb035777>