|
From: <dav...@us...> - 2007-04-12 22:40:02
|
Revision: 1655
http://svn.sourceforge.net/frontierkernel/?rev=1655&view=rev
Author: davidgewirtz
Date: 2007-04-12 15:39:57 -0700 (Thu, 12 Apr 2007)
Log Message:
-----------
Yet more MySQL verbs.
Modified Paths:
--------------
Frontier/branches/mysql/Common/headers/langmysql.h
Frontier/branches/mysql/Common/resources/Mac/kernelverbs.r
Frontier/branches/mysql/Common/resources/Win32/kernelverbs.rc
Frontier/branches/mysql/Common/source/langmysql.c
Modified: Frontier/branches/mysql/Common/headers/langmysql.h
===================================================================
--- Frontier/branches/mysql/Common/headers/langmysql.h 2007-04-11 04:22:15 UTC (rev 1654)
+++ Frontier/branches/mysql/Common/headers/langmysql.h 2007-04-12 22:39:57 UTC (rev 1655)
@@ -55,6 +55,24 @@
extern boolean mysqlgetqueryinfoverb (hdltreenode, tyvaluerecord *, bigstring); /* 2007-04-10 gewirtz */
+extern boolean mysqlgetaffectedrowcountverb (hdltreenode, tyvaluerecord *, bigstring); /* 2007-04-11 gewirtz */
+
+extern boolean mysqlgetselectedrowcountverb (hdltreenode, tyvaluerecord *, bigstring); /* 2007-04-11 gewirtz */
+
+extern boolean mysqlgetcolumncountverb (hdltreenode, tyvaluerecord *, bigstring); /* 2007-04-11 gewirtz */
+
+extern boolean mysqlgetserverstatusverb (hdltreenode, tyvaluerecord *, bigstring); /* 2007-04-11 gewirtz */
+
+extern boolean mysqlgetquerywarningcountverb (hdltreenode, tyvaluerecord *, bigstring); /* 2007-04-11 gewirtz */
+
+extern boolean mysqlpingserververb (hdltreenode, tyvaluerecord *, bigstring); /* 2007-04-11 gewirtz */
+
+extern boolean mysqlseekrowverb (hdltreenode, tyvaluerecord *, bigstring); /* 2007-04-11 gewirtz */
+
+extern boolean mysqlselectdatabaseverb (hdltreenode, tyvaluerecord *, bigstring); /* 2007-04-11 gewirtz */
+
+extern boolean mysqlgetsqlstateverb (hdltreenode, tyvaluerecord *, bigstring); /* 2007-04-12 gewirtz */
+
extern boolean mysqlcloseverb (hdltreenode, tyvaluerecord *, bigstring); /* 2007-04-08 gewirtz */
Modified: Frontier/branches/mysql/Common/resources/Mac/kernelverbs.r
===================================================================
--- Frontier/branches/mysql/Common/resources/Mac/kernelverbs.r 2007-04-11 04:22:15 UTC (rev 1654)
+++ Frontier/branches/mysql/Common/resources/Mac/kernelverbs.r 2007-04-12 22:39:57 UTC (rev 1655)
@@ -1183,6 +1183,15 @@
"getProtocolInfo",
"getServerInfo",
"getQueryInfo",
+ "getAffectedRowCount",
+ "getSelectedRowCount",
+ "getColumnCount",
+ "getServerStatus",
+ "getQueryWarningCount",
+ "pingServer",
+ "seekRow",
+ "selectDatabase",
+ "getSQLSTATE",
"close"
}
}
Modified: Frontier/branches/mysql/Common/resources/Win32/kernelverbs.rc
===================================================================
--- Frontier/branches/mysql/Common/resources/Win32/kernelverbs.rc 2007-04-11 04:22:15 UTC (rev 1654)
+++ Frontier/branches/mysql/Common/resources/Win32/kernelverbs.rc 2007-04-12 22:39:57 UTC (rev 1655)
@@ -1106,7 +1106,7 @@
1, // Number of "blocks" in this resource
"mysql\0", // Function Processor name
false, // Window required
- 15, // Count of verbs
+ 24, // Count of verbs
"init\0",
"connect\0",
"compileQuery\0",
@@ -1120,6 +1120,15 @@
"getServerVersion\0",
"getProtocolInfo\0",
"getServerInfo\0",
- "getQueryInfo\0",
+ "getQueryInfo\0",
+ "getAffectedRowCount\0",
+ "getSelectedRowCount\0",
+ "getColumnCount\0",
+ "getServerStatus\0",
+ "getQueryWarningCount\0",
+ "pingServer\0",
+ "seekRow\0",
+ "selectDatabase\0",
+ "getSQLSTATE\0",
"close\0"
END
Modified: Frontier/branches/mysql/Common/source/langmysql.c
===================================================================
--- Frontier/branches/mysql/Common/source/langmysql.c 2007-04-11 04:22:15 UTC (rev 1654)
+++ Frontier/branches/mysql/Common/source/langmysql.c 2007-04-12 22:39:57 UTC (rev 1655)
@@ -80,13 +80,22 @@
getrowfunc,
geterrornumberfunc,
geterrormessagefunc,
- getclientinfofunc,
- getclientversionfunc,
- gethostinfofunc,
- getserverversionfunc,
- getprotocolinfofunc,
- getserverinfofunc,
+ getclientinfofunc,
+ getclientversionfunc,
+ gethostinfofunc,
+ getserverversionfunc,
+ getprotocolinfofunc,
+ getserverinfofunc,
getqueryinfofunc,
+ getaffectedrowcountfunc,
+ getselectedrowcountfunc,
+ getcolumncountfunc,
+ getserverstatusfunc,
+ getquerywarningcountfunc,
+ pingserverfunc,
+ seekrowfunc,
+ selectdatabasefunc,
+ getsqlstatefunc,
closefunc,
ctmysqlverbs
} tymysqlverbtoken;
@@ -143,6 +152,33 @@
case getqueryinfofunc: { /* 2007-04-10 gewirtz: get the results messages from the last query */
return (mysqlgetqueryinfoverb (hp1, v, bserror));
} /* getqueryinfofunc */
+ case getaffectedrowcountfunc: { /* 2007-04-11 gewirtz: get the rows added, deleted, updated */
+ return (mysqlgetaffectedrowcountverb (hp1, v, bserror));
+ } /* getaffectedrowcountfunc */
+ case getselectedrowcountfunc: { /* 2007-04-11 gewirtz: get the rows selected in last query */
+ return (mysqlgetselectedrowcountverb (hp1, v, bserror));
+ } /* getselectedrowcountfunc */
+ case getcolumncountfunc: { /* 2007-04-11 gewirtz: get the columns returned in last query */
+ return (mysqlgetcolumncountverb (hp1, v, bserror));
+ } /* getcolumncountfunc */
+ case getserverstatusfunc: { /* 2007-04-11 gewirtz: get the MySQL server status */
+ return (mysqlgetserverstatusverb (hp1, v, bserror));
+ } /* getserverstatusfunc */
+ case getquerywarningcountfunc: { /* 2007-04-11 gewirtz: get the number of warnings returned by the last query */
+ return (mysqlgetquerywarningcountverb (hp1, v, bserror));
+ } /* getquerywarningcountfunc */
+ case pingserverfunc: { /* 2007-04-11 gewirtz: check to see if there's still a connection with the server */
+ return (mysqlpingserververb (hp1, v, bserror));
+ } /* pingserverfunc */
+ case seekrowfunc: { /* 2007-04-11 gewirtz: move to specific row in query result set */
+ return (mysqlseekrowverb (hp1, v, bserror));
+ } /* seekrowfunc */
+ case selectdatabasefunc: { /* 2007-04-11 gewirtz: choose a MySQL database as current */
+ return (mysqlselectdatabaseverb (hp1, v, bserror));
+ } /* selectdatabasefunc */
+ case getsqlstatefunc: { /* 2007-04-11 gewirtz: choose a MySQL database as current */
+ return (mysqlgetsqlstateverb (hp1, v, bserror));
+ } /* getsqlstatefunc */
case closefunc: { /* 2007-04-08 gewirtz: close a MySQL db */
return (mysqlcloseverb (hp1, v, bserror));
} /* closefunc */
@@ -209,16 +245,16 @@
if (!getlongvalue (hparam1, 1, (long *) &dbid)) /* Get the long value, which becomes the db pointer */
return (false);
- if (!getreadonlytextvalue (hparam1, 2, &host)) /* get the host param */
+ if (!gettextvalue (hparam1, 2, &host)) /* get the host param */
return (false);
- if (!getreadonlytextvalue (hparam1, 3, &user)) /* get the user param */
+ if (!gettextvalue (hparam1, 3, &user)) /* get the user param */
return (false);
- if (!getreadonlytextvalue (hparam1, 4, &passwd)) /* get the passwd param */
+ if (!gettextvalue (hparam1, 4, &passwd)) /* get the passwd param */
return (false);
- if (!getreadonlytextvalue (hparam1, 5, &dbname)) /* get the dbname param */
+ if (!gettextvalue (hparam1, 5, &dbname)) /* get the dbname param */
return (false);
flnextparamislast = true; /* makes sure Frontier throws an error if more than one param is passed */
@@ -227,10 +263,10 @@
return (false);
// Null terminate strings
- pushcharhandle (0x00, host);
- pushcharhandle (0x00, user);
- pushcharhandle (0x00, passwd);
- pushcharhandle (0x00, dbname);
+ if (!pushcharhandle (0x00, host)) return (false);
+ if (!pushcharhandle (0x00, user)) return (false);
+ if (!pushcharhandle (0x00, passwd)) return (false);
+ if (!pushcharhandle (0x00, dbname)) return (false);
// Attempt the connection
dbid = mysql_real_connect(dbid, *host, *user, *passwd, *dbname, (unsigned int) port, NULL, 0 );
@@ -264,6 +300,12 @@
if (!getlongvalue (hparam1, 1, (long *) &dbid)) /* Get the long value, which becomes the db pointer */
return (false);
+ // Check that server's still alive
+ if (mysql_ping(dbid) != 0) {
+ langerrormessage ("\x20""Lost connection to MySQL server.");
+ return (false);
+ }
+
/* Process the SQLite sequence */
mysql_close(dbid);
returnCode = 0; // placeholder for debugging. mysql_close doesn't return anything.
@@ -277,7 +319,6 @@
MYSQL *dbid; // the MySQL object handle
MYSQL_RES *queryid; // the returned MySQL query id
int returnCode; // return code from MySQL query
- const char *mysqlMsg; // pointer to the message DEBUG
/*
sqlite.compileQuery(dbid, query)
@@ -299,12 +340,19 @@
flnextparamislast = true; /* makes sure Frontier throws an error if more than one param is passed */
- if (!getreadonlytextvalue (hparam1, 2, &query)) /* get the query param */
+ if (!gettextvalue (hparam1, 2, &query)) /* get the query param */
return (false);
// Null terminate strings
- pushcharhandle (0x00, query);
+ if (!pushcharhandle (0x00, query))
+ return (false);
+ // Check that server's still alive
+ if (mysql_ping(dbid) != 0) {
+ langerrormessage ("\x20""Lost connection to MySQL server.");
+ return (false);
+ }
+
/* Process the initial query sequence */
returnCode = mysql_query(dbid, *query);
if(returnCode != 0) {
@@ -312,16 +360,12 @@
return (false);
}
- mysqlMsg = mysql_info(dbid); // DEBUG
-
queryid = mysql_store_result(dbid);
if(mysql_errno(dbid) != 0) {
langerrormessage ("\x21""Could initialize MySQL query.");
return (false);
}
- mysqlMsg = mysql_info(dbid); // DEBUG
-
if (mysql_field_count(dbid) == 0)
return (setlongvalue ((long) 0, vreturned)); /* return 0 to the scripter */
else
@@ -387,12 +431,14 @@
// **** NOTE THIS COULD ALSO MEAN AN ERROR, MIGHT BE GOOD TO CHECK
return (setlongvalue ((long) 0, vreturned));
}
+
fieldCount = mysql_num_fields(queryid);
if (fieldCount == 0) {
langerrormessage ("\x2D""MySQL.getRow requires a minimum of one field.");
return (false);
}
+
mysql_field_seek(queryid, 0); // restart gathering field data from the first field
if (!opnewlist (&hlist, false)) /* fail out if we can't create the list */
@@ -508,6 +554,12 @@
if (!getlongvalue (hparam1, 1, (long *) &dbid)) /* Get the long value, which becomes the pline pointer */
return (false);
+ // Check that server's still alive
+ if (mysql_ping(dbid) != 0) {
+ langerrormessage ("\x20""Lost connection to MySQL server.");
+ return (false);
+ }
+
/* Process the MySQL call */
returnCode = mysql_errno(dbid);
@@ -536,6 +588,12 @@
if (!getlongvalue (hparam1, 1, (long *) &dbid)) /* Get the long value, which becomes the db pointer */
return (false);
+ // Check that server's still alive
+ if (mysql_ping(dbid) != 0) {
+ langerrormessage ("\x20""Lost connection to MySQL server.");
+ return (false);
+ }
+
/* Process the SQLite sequence */
mysqlError = mysql_error(dbid);
@@ -615,6 +673,12 @@
if (!getlongvalue (hparam1, 1, (long *) &dbid)) /* Get the long value, which becomes the db pointer */
return (false);
+ // Check that server's still alive
+ if (mysql_ping(dbid) != 0) {
+ langerrormessage ("\x20""Lost connection to MySQL server.");
+ return (false);
+ }
+
/* Process the SQLite sequence */
mysqlMsg = mysql_get_host_info(dbid);
@@ -647,6 +711,12 @@
if (!getlongvalue (hparam1, 1, (long *) &dbid)) /* Get the long value, which becomes the db pointer */
return (false);
+ // Check that server's still alive
+ if (mysql_ping(dbid) != 0) {
+ langerrormessage ("\x20""Lost connection to MySQL server.");
+ return (false);
+ }
+
/* Process the SQLite sequence */
returnCode = mysql_get_server_version(dbid);
@@ -676,6 +746,12 @@
if (!getlongvalue (hparam1, 1, (long *) &dbid)) /* Get the long value, which becomes the db pointer */
return (false);
+ // Check that server's still alive
+ if (mysql_ping(dbid) != 0) {
+ langerrormessage ("\x20""Lost connection to MySQL server.");
+ return (false);
+ }
+
/* Process the SQLite sequence */
returnCode = mysql_get_proto_info(dbid);
@@ -705,6 +781,12 @@
if (!getlongvalue (hparam1, 1, (long *) &dbid)) /* Get the long value, which becomes the db pointer */
return (false);
+ // Check that server's still alive
+ if (mysql_ping(dbid) != 0) {
+ langerrormessage ("\x20""Lost connection to MySQL server.");
+ return (false);
+ }
+
/* Process the SQLite sequence */
mysqlMsg = mysql_get_server_info(dbid);
@@ -737,6 +819,12 @@
if (!getlongvalue (hparam1, 1, (long *) &dbid)) /* Get the long value, which becomes the db pointer */
return (false);
+ // Check that server's still alive
+ if (mysql_ping(dbid) != 0) {
+ langerrormessage ("\x20""Lost connection to MySQL server.");
+ return (false);
+ }
+
/* Process the SQLite sequence */
mysqlMsg = mysql_info(dbid);
@@ -752,4 +840,305 @@
return (setheapvalue (returnH, stringvaluetype, vreturned));
-} /* mysqlgetqueryinfoverb */
\ No newline at end of file
+} /* mysqlgetqueryinfoverb */
+
+boolean mysqlgetaffectedrowcountverb (hdltreenode hparam1, tyvaluerecord *vreturned, bigstring bserror) {
+ MYSQL *dbid; // the MySQL object handle
+ my_ulonglong rowCount; // this datastructure is too big for Frontier
+
+ /*
+ sqlite.getColumnInt(queryid, columnNumber)
+
+ Action: Retrieve the value of the specified integer-type column
+ Params: a query id and the number of the column (1 base)
+ Returns: an SQLite result code
+ Notes: do not pass the opened database ID across threads.
+
+ SQLite docs: http://www.sqlite.org/capi3ref.html#sqlite3_column_int.
+ */
+
+ flnextparamislast = true; /* makes sure Frontier throws an error if more than one param is passed */
+
+ if (!getlongvalue (hparam1, 1, (long *) &dbid)) /* Get the long value, which becomes the pointer */
+ return (false);
+
+ // Check that server's still alive
+ if (mysql_ping(dbid) != 0) {
+ langerrormessage ("\x20""Lost connection to MySQL server.");
+ return (false);
+ }
+
+ /* Process the MySQL call */
+ rowCount = mysql_affected_rows(dbid);
+
+ return (setdoublevalue ((double) rowCount, vreturned));
+
+} /* mysqlgetaffectedrowcountverb */
+
+boolean mysqlgetselectedrowcountverb (hdltreenode hparam1, tyvaluerecord *vreturned, bigstring bserror) {
+ MYSQL_RES *queryid; // query id
+ my_ulonglong rowCount; // this datastructure is too big for Frontier
+
+ /*
+ sqlite.getColumnInt(queryid, columnNumber)
+
+ Action: Retrieve the value of the specified integer-type column
+ Params: a query id and the number of the column (1 base)
+ Returns: an SQLite result code
+ Notes: do not pass the opened database ID across threads.
+
+ SQLite docs: http://www.sqlite.org/capi3ref.html#sqlite3_column_int.
+ */
+
+ flnextparamislast = true; /* makes sure Frontier throws an error if more than one param is passed */
+
+ if (!getlongvalue (hparam1, 1, (long *) &queryid)) /* Get the long value, which becomes the pointer */
+ return (false);
+
+ /* Process the MySQL call */
+ rowCount = mysql_num_rows(queryid);
+
+ return (setdoublevalue ((double) rowCount, vreturned));
+
+} /* mysqlgetselectedrowcountverb */
+
+boolean mysqlgetcolumncountverb (hdltreenode hparam1, tyvaluerecord *vreturned, bigstring bserror) {
+ MYSQL *dbid; // the MySQL object handle
+ unsigned int returnCode; // return code from MySQL call
+
+ /*
+ sqlite.getColumnInt(queryid, columnNumber)
+
+ Action: Retrieve the value of the specified integer-type column
+ Params: a query id and the number of the column (1 base)
+ Returns: an SQLite result code
+ Notes: do not pass the opened database ID across threads.
+
+ SQLite docs: http://www.sqlite.org/capi3ref.html#sqlite3_column_int.
+ */
+
+ flnextparamislast = true; /* makes sure Frontier throws an error if more than one param is passed */
+
+ if (!getlongvalue (hparam1, 1, (long *) &dbid)) /* Get the long value, which becomes the pline pointer */
+ return (false);
+
+ // Check that server's still alive
+ if (mysql_ping(dbid) != 0) {
+ langerrormessage ("\x20""Lost connection to MySQL server.");
+ return (false);
+ }
+
+ /* Process the MySQL call */
+ returnCode = mysql_field_count(dbid);
+
+ return (setlongvalue ((long) returnCode, vreturned));
+
+} /* mysqlgetcolumncountverb */
+
+boolean mysqlgetserverstatusverb (hdltreenode hparam1, tyvaluerecord *vreturned, bigstring bserror) {
+ MYSQL *dbid; // the MySQL object handle
+ const char *mysqlStatus; // pointer to the status message
+ Handle returnH = nil; // The handle being returned back to Frontier
+
+ /*
+ Status will fail/crash if mysql.connect hasn't previously succeeded
+ */
+
+ flnextparamislast = true; /* makes sure Frontier throws an error if more than one param is passed */
+
+ if (!getlongvalue (hparam1, 1, (long *) &dbid)) /* Get the long value, which becomes the db pointer */
+ return (false);
+
+ // Check that server's still alive
+ if (mysql_ping(dbid) != 0) {
+ langerrormessage ("\x20""Lost connection to MySQL server.");
+ return (false);
+ }
+
+ /* Process the SQLite sequence */
+ mysqlStatus = mysql_stat(dbid);
+
+ if (mysqlStatus == NULL) {
+ return (setlongvalue ((long) 0, vreturned));
+ }
+ else {
+ /* Exit the verb, converting errMsg back to Frontier handle */
+ if(!newfilledhandle ((ptrvoid) mysqlStatus, strlen (mysqlStatus), &returnH))
+ return false; /* Allocation failed */
+ }
+
+ return (setheapvalue (returnH, stringvaluetype, vreturned));
+
+} /* mysqlgetserverstatusverb */
+
+boolean mysqlgetquerywarningcountverb (hdltreenode hparam1, tyvaluerecord *vreturned, bigstring bserror) {
+ MYSQL *dbid; // the MySQL object handle
+ unsigned int returnCode; // return code from MySQL call
+
+ /*
+ sqlite.getColumnInt(queryid, columnNumber)
+
+ Action: Retrieve the value of the specified integer-type column
+ Params: a query id and the number of the column (1 base)
+ Returns: an SQLite result code
+ Notes: do not pass the opened database ID across threads.
+
+ SQLite docs: http://www.sqlite.org/capi3ref.html#sqlite3_column_int.
+ */
+
+ flnextparamislast = true; /* makes sure Frontier throws an error if more than one param is passed */
+
+ if (!getlongvalue (hparam1, 1, (long *) &dbid)) /* Get the long value, which becomes the pline pointer */
+ return (false);
+
+ // Check that server's still alive
+ if (mysql_ping(dbid) != 0) {
+ langerrormessage ("\x20""Lost connection to MySQL server.");
+ return (false);
+ }
+
+ /* Process the MySQL call */
+ returnCode = mysql_warning_count(dbid);
+
+ return (setlongvalue ((long) returnCode, vreturned));
+
+} /* mysqlgetquerywarningcountverb */
+
+boolean mysqlpingserververb (hdltreenode hparam1, tyvaluerecord *vreturned, bigstring bserror) {
+ MYSQL *dbid; // the MySQL object handle
+ unsigned int returnCode; // return code from MySQL call
+
+ /*
+ sqlite.getColumnInt(queryid, columnNumber)
+
+ Action: Retrieve the value of the specified integer-type column
+ Params: a query id and the number of the column (1 base)
+ Returns: an SQLite result code
+ Notes: do not pass the opened database ID across threads.
+
+ SQLite docs: http://www.sqlite.org/capi3ref.html#sqlite3_column_int.
+ */
+
+ flnextparamislast = true; /* makes sure Frontier throws an error if more than one param is passed */
+
+ if (!getlongvalue (hparam1, 1, (long *) &dbid)) /* Get the long value, which becomes the pline pointer */
+ return (false);
+
+ /* Process the MySQL call */
+ returnCode = mysql_ping(dbid);
+
+ return (setlongvalue ((long) returnCode, vreturned));
+
+} /* mysqlpingserververb */
+
+boolean mysqlseekrowverb (hdltreenode hparam1, tyvaluerecord *vreturned, bigstring bserror) {
+ MYSQL_RES *queryid; // the returned MySQL query id
+ tyvaluerecord v1;
+ double row; // row to seek
+
+ /*
+ sqlite.compileQuery(dbid, query)
+
+ Action: compile an SQLite query
+ Params: a database id and a query string
+ Returns: a query id
+ Usage: call in a try statement
+ Notes: do not pass the opened database ID across threads.
+
+ SQLite docs: http://www.sqlite.org/capi3ref.html#sqlite3_prepare.
+
+ Code that is a good example of prepare in use:
+ http://souptonuts.sourceforge.net/code/eatblob.c.html
+ */
+
+ if (!getlongvalue (hparam1, 1, (long *) &queryid)) /* Get the long value, which becomes the query pointer */
+ return (false);
+
+ flnextparamislast = true; /* makes sure Frontier throws an error if more than one param is passed */
+
+ if (!getdoubleparam (hparam1, 2, &v1)) /* get the seek row */
+ return (false);
+
+ row = **v1.data.doublevalue;
+
+ mysql_data_seek(queryid, (my_ulonglong) row);
+
+ return (setlongvalue ((long) 0, vreturned));
+
+} /* mysqlseekrowverb */
+
+boolean mysqlselectdatabaseverb ( hdltreenode hparam1, tyvaluerecord *vreturned, bigstring bserror ) {
+
+ MYSQL *dbid; // the MySQL object handle
+ int resultCode; // result code
+ Handle dbname; // existing database on MySQL server
+
+ //
+ // mysql.connect (dbid, host, user, password, database, port)
+ //
+ // Action: connects to a MySQL server and database, initializing the mySQL connection object
+ // Params: dbid (the MySQL object) the hostname, user id, password, existing database name, and port
+ // Returns: a MySQL object handle or an error
+ // Usage: call in a try statement
+ //
+ // MySQL docs: http://dev.mysql.com/doc/refman/5.1/en/mysql-real-connect.html
+ //
+ // If problems are encountered connecting to a Windows-based MySQL server, see:
+ // http://dev.mysql.com/doc/refman/5.1/en/can-not-connect-to-server.html#can-not-connect-to-server-on-windows
+ //
+
+ if (!getlongvalue (hparam1, 1, (long *) &dbid)) /* Get the long value, which becomes the db pointer */
+ return (false);
+
+ flnextparamislast = true; /* makes sure Frontier throws an error if more than one param is passed */
+
+ if (!gettextvalue (hparam1, 2, &dbname)) /* get the dbname param */
+ return (false);
+
+ // Null terminate strings
+ if (!pushcharhandle (0x00, dbname))
+ return (false);
+
+ // Check that server's still alive
+ if (mysql_ping(dbid) != 0) {
+ langerrormessage ("\x20""Lost connection to MySQL server.");
+ return (false);
+ }
+
+ // Process the MySQL request
+ resultCode = mysql_select_db(dbid, *dbname);
+ if (resultCode != 0) {
+ langerrormessage ("\x24""Could not connect to MySQL database.");
+ return (false);
+ }
+
+ return (setlongvalue ((long) 0, vreturned));
+
+} // mysqlselectdatabaseverb
+
+boolean mysqlgetsqlstateverb (hdltreenode hparam1, tyvaluerecord *vreturned, bigstring bserror) {
+ MYSQL *dbid; // the MySQL object handle
+ const char *mysqlStatus; // pointer to the status message
+ Handle returnH = nil; // The handle being returned back to Frontier
+
+ flnextparamislast = true; /* makes sure Frontier throws an error if more than one param is passed */
+
+ if (!getlongvalue (hparam1, 1, (long *) &dbid)) /* Get the long value, which becomes the db pointer */
+ return (false);
+
+ // Check that server's still alive
+ if (mysql_ping(dbid) != 0) {
+ langerrormessage ("\x20""Lost connection to MySQL server.");
+ return (false);
+ }
+
+ /* Process the SQLite sequence */
+ mysqlStatus = mysql_sqlstate(dbid);
+
+ /* Exit the verb, converting errMsg back to Frontier handle */
+ if(!newfilledhandle ((ptrvoid) mysqlStatus, strlen (mysqlStatus), &returnH))
+ return false; /* Allocation failed */
+
+ return (setheapvalue (returnH, stringvaluetype, vreturned));
+
+} /* mysqlgetsqlstateverb */
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|