|
|
1.1 parser 1: /** @file
2: Parser MySQL driver.
3:
1.40 moko 4: Copyright (c) 2001-2012 Art. Lebedev Studio (http://www.artlebedev.com)
1.1 parser 5:
1.7 paf 6: Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
1.1 parser 7:
1.36 misha 8: 2001-07-30 using MySQL 3.23.22b
1.3 paf 9:
1.36 misha 10: 2001-11-06 numrows on "HP-UX istok1 B.11.00 A 9000/869 448594332 two-user license"
1.3 paf 11: 3.23.42 & 4.0.0.alfa never worked, both subst & .sl version returned 0
1.1 parser 12: */
13:
14: #include "config_includes.h"
15:
16: #include "pa_sql_driver.h"
17:
1.47 ! moko 18: volatile const char * IDENT_PARSER3MYSQL_C="$Id: parser3mysql.C,v 1.46 2013/07/07 16:58:25 moko Exp $" IDENT_PA_SQL_DRIVER_H;
1.40 moko 19:
1.1 parser 20: #define NO_CLIENT_LONG_LONG
21: #include "mysql.h"
22: #include "ltdl.h"
23:
24: #define MAX_STRING 0x400
25: #define MAX_NUMBER 20
26:
27: #if _MSC_VER
28: # define snprintf _snprintf
1.2 parser 29: # define strcasecmp _stricmp
1.1 parser 30: #endif
31:
1.35 misha 32: // for mysql < 4.1
1.36 misha 33: #if !defined(CLIENT_MULTI_RESULTS) || !defined(CLIENT_MULTI_STATEMENTS)
34: # define OLD_MYSQL_CLIENT 1
35: #endif
36:
1.35 misha 37: #ifndef CLIENT_MULTI_RESULTS
1.36 misha 38: # define CLIENT_MULTI_RESULTS (1UL << 17)
1.35 misha 39: #endif
1.36 misha 40:
1.35 misha 41: #ifndef CLIENT_MULTI_STATEMENTS
1.36 misha 42: # define CLIENT_MULTI_STATEMENTS (1UL << 16)
1.35 misha 43: #endif
44:
1.34 misha 45: static char *lsplit(char *string, char delim){
1.32 misha 46: if(string) {
1.34 misha 47: if(char *v=strchr(string, delim)){
1.1 parser 48: *v=0;
49: return v+1;
50: }
1.32 misha 51: }
52: return 0;
1.1 parser 53: }
54:
1.34 misha 55: static char *lsplit(char **string_ref, char delim){
1.32 misha 56: char *result=*string_ref;
1.2 parser 57: char *next=lsplit(*string_ref, delim);
1.32 misha 58: *string_ref=next;
59: return result;
1.2 parser 60: }
61:
1.34 misha 62: static char* rsplit(char* string, char delim){
63: if(string){
64: if(char* v=strrchr(string, delim)){
1.26 paf 65: *v=0;
66: return v+1;
67: }
1.32 misha 68: }
69: return NULL;
1.26 paf 70: }
71:
1.34 misha 72: static void toupper_str(char *out, const char *in, size_t size){
1.19 paf 73: while(size--)
74: *out++=(char)toupper(*in++);
75: }
76:
1.38 misha 77: inline static bool is_column_transcode_required(enum_field_types type) {
78: switch(type) {
79: case MYSQL_TYPE_NULL:
80:
1.45 moko 81: #ifdef FIELD_TYPE_NEWDECIMAL
82: case MYSQL_TYPE_NEWDECIMAL:
83: #endif
1.38 misha 84: case MYSQL_TYPE_DECIMAL:
85: case MYSQL_TYPE_FLOAT:
86: case MYSQL_TYPE_DOUBLE:
87:
88: case MYSQL_TYPE_TINY:
89: case MYSQL_TYPE_SHORT:
90: case MYSQL_TYPE_LONG:
91: case MYSQL_TYPE_LONGLONG:
92: case MYSQL_TYPE_INT24:
1.45 moko 93: #ifdef FIELD_TYPE_BIT
1.38 misha 94: case MYSQL_TYPE_BIT:
1.45 moko 95: #endif
1.38 misha 96:
97: case MYSQL_TYPE_DATE:
98: case MYSQL_TYPE_NEWDATE:
99: case MYSQL_TYPE_TIME:
100: case MYSQL_TYPE_DATETIME:
101: case MYSQL_TYPE_YEAR:
102: case MYSQL_TYPE_TIMESTAMP:
103:
104: case MYSQL_TYPE_BLOB:
105: case MYSQL_TYPE_TINY_BLOB:
106: case MYSQL_TYPE_MEDIUM_BLOB:
107: case MYSQL_TYPE_LONG_BLOB:
108: return false;
109: break;
110: }
111: return true;
112: }
113:
114: inline static const char* strdup(SQL_Driver_services& services, char* str, size_t length) {
115: char *strm=(char*)services.malloc_atomic(length+1);
116: memcpy(strm, str, length);
117: strm[length]=0;
118: return (const char*)strm;
119: }
120:
1.14 paf 121: struct Connection {
1.16 paf 122: SQL_Driver_services* services;
1.15 paf 123:
1.14 paf 124: MYSQL* handle;
1.33 misha 125: const char* client_charset;
1.14 paf 126: bool autocommit;
127: };
128:
1.29 misha 129:
1.1 parser 130: /**
131: MySQL server driver
132: */
133: class MySQL_Driver : public SQL_Driver {
134: public:
135:
1.29 misha 136: MySQL_Driver() : SQL_Driver() {}
137:
1.1 parser 138: /// get api version
139: int api_version() { return SQL_DRIVER_API_VERSION; }
1.33 misha 140:
1.1 parser 141: /// initialize driver by loading sql dynamic link library
1.4 paf 142: const char *initialize(char *dlopen_file_spec) {
1.1 parser 143: return dlopen_file_spec?
144: dlink(dlopen_file_spec):"client library column is empty";
145: }
1.33 misha 146:
1.1 parser 147: /** connect
1.23 paf 148: @param url
1.2 parser 149: format: @b user:pass@host[:port]|[/unix/socket]/database?
1.47 ! moko 150: charset=value& // transcode by server with command 'SET NAMES value'
1.32 misha 151: ClientCharset=charset& // transcode by parser
1.2 parser 152: timeout=3&
1.32 misha 153: compress=0&
154: named_pipe=1&
1.33 misha 155: autocommit=1&
1.35 misha 156: multi_statements=0 // allows more then one statement in one query
157: old_client=1 // simulates 3.xx client. not compatible with multi_statements option
1.33 misha 158: 3.x, 4.0
159: only option for charset is cp1251_koi8.
160: 4.1+ accept not 'cp1251_koi8' but 'cp1251', 'utf8' and much more
161: it is usable for transcoding using sql server
1.1 parser 162: */
163: void connect(
1.33 misha 164: char *url,
165: SQL_Driver_services& services,
166: void **connection_ref ///< output: Connection*
167: ){
1.23 paf 168: char *user=url;
1.26 paf 169: char *s=rsplit(user, '@');
1.1 parser 170: char *host=0;
171: char *unix_socket=0;
172: if(s && s[0]=='[') { // unix socket
173: unix_socket=1+s;
174: s=lsplit(unix_socket, ']');
175: } else { // IP
176: host=s;
177: }
178: char *db=lsplit(s, '/');
179: char *pwd=lsplit(user, ':');
180: char *error_pos=0;
181: char *port_cstr=lsplit(host, ':');
182: int port=port_cstr?strtol(port_cstr, &error_pos, 0):0;
1.2 parser 183: char *options=lsplit(db, '?');
184:
1.33 misha 185: char *charset=0;
1.35 misha 186:
187: #ifdef OLD_MYSQL_CLIENT
188: int client_flag=0;
189: #else
1.34 misha 190: int client_flag=CLIENT_MULTI_RESULTS;
1.35 misha 191: #endif
1.1 parser 192:
1.33 misha 193: Connection& connection=*(Connection *)services.malloc(sizeof(Connection));
194: *connection_ref=&connection;
1.15 paf 195: connection.services=&services;
1.32 misha 196: connection.handle=mysql_init(NULL);
1.33 misha 197: connection.client_charset=0;
1.14 paf 198: connection.autocommit=true;
1.2 parser 199:
1.32 misha 200: while(options){
201: if(char *key=lsplit(&options, '&')){
202: if(*key){
203: if(char *value=lsplit(key, '=')){
1.33 misha 204: if(strcmp(key, "ClientCharset")==0){ // transcoding with parser
1.21 paf 205: toupper_str(value, value, strlen(value));
1.33 misha 206: connection.client_charset=value;
1.32 misha 207: } else if(strcasecmp(key, "charset")==0){ // transcoding with server
1.33 misha 208: charset=value;
1.32 misha 209: } else if(strcasecmp(key, "timeout")==0){
1.2 parser 210: unsigned int timeout=(unsigned int)atoi(value);
1.14 paf 211: if(mysql_options(connection.handle, MYSQL_OPT_CONNECT_TIMEOUT, (const char *)&timeout)!=0)
212: services._throw(mysql_error(connection.handle));
1.32 misha 213: } else if(strcasecmp(key, "compress")==0){
1.2 parser 214: if(atoi(value))
1.14 paf 215: if(mysql_options(connection.handle, MYSQL_OPT_COMPRESS, 0)!=0)
216: services._throw(mysql_error(connection.handle));
1.32 misha 217: } else if(strcasecmp(key, "named_pipe")==0){
1.2 parser 218: if(atoi(value))
1.33 misha 219: if(mysql_options(connection.handle, MYSQL_OPT_NAMED_PIPE, 0)!=0)
1.14 paf 220: services._throw(mysql_error(connection.handle));
1.39 misha 221: } else if(strcasecmp(key, "local_infile")==0){
222: if(atoi(value))
223: if(mysql_options(connection.handle, MYSQL_OPT_LOCAL_INFILE, 0)!=0)
224: services._throw(mysql_error(connection.handle));
1.32 misha 225: } else if(strcasecmp(key, "autocommit")==0){
1.31 misha 226: if(atoi(value)==0)
1.14 paf 227: connection.autocommit=false;
1.34 misha 228: } else if(strcasecmp(key, "multi_statements")==0){
1.35 misha 229: #ifdef OLD_MYSQL_CLIENT
230: services._throw("driver was built with old mysql includes so multi_statements option can't be used");
231: #else
1.34 misha 232: if(!(client_flag==CLIENT_MULTI_RESULTS || client_flag==CLIENT_MULTI_STATEMENTS))
233: services._throw("you can't specify together options old_client and multi_statements");
234: if(atoi(value)!=0)
235: client_flag=CLIENT_MULTI_STATEMENTS;
1.35 misha 236: #endif
1.34 misha 237: } else if(strcasecmp(key, "old_client")==0){
1.35 misha 238: #ifdef OLD_MYSQL_CLIENT
239: services._throw("driver was built with old mysql includes so old_client option can't be used");
240: #else
1.34 misha 241: if(!(client_flag==CLIENT_MULTI_RESULTS || client_flag==0))
242: services._throw("you can't specify together options old_client and multi_statements");
243: if(atoi(value)!=0)
244: client_flag=0;
1.35 misha 245: #endif
1.2 parser 246: } else
247: services._throw("unknown connect option" /*key*/);
248: } else
249: services._throw("connect option without =value" /*key*/);
250: }
251: }
252: }
253:
1.33 misha 254: if(!mysql_real_connect(
255: connection.handle,
256: host, user, pwd, db,
257: port?port:MYSQL_PORT,
258: unix_socket,
1.34 misha 259: client_flag
1.33 misha 260: )
261: ){
1.14 paf 262: services._throw(mysql_error(connection.handle));
1.33 misha 263: }
1.1 parser 264:
1.33 misha 265: if(charset){
1.47 ! moko 266: char statement[MAX_STRING+1]="SET NAMES ";
1.33 misha 267: strncat(statement, charset, MAX_STRING);
268: _exec(connection, statement);
1.1 parser 269: }
270:
1.14 paf 271: if(!connection.autocommit)
1.33 misha 272: _exec(connection, "SET AUTOCOMMIT=0");
1.1 parser 273: }
1.14 paf 274:
275: void disconnect(void *aconnection) {
276: Connection& connection=*static_cast<Connection*>(aconnection);
277: mysql_close(connection.handle);
1.17 paf 278: connection.handle=0;
1.1 parser 279: }
1.32 misha 280:
1.15 paf 281: void commit(void *aconnection) {
1.14 paf 282: Connection& connection=*static_cast<Connection*>(aconnection);
283: if(!connection.autocommit)
1.33 misha 284: _exec(connection, "COMMIT");
1.14 paf 285: }
1.32 misha 286:
1.15 paf 287: void rollback(void *aconnection) {
1.14 paf 288: Connection& connection=*static_cast<Connection*>(aconnection);
289: if(!connection.autocommit)
1.33 misha 290: _exec(connection, "ROLLBACK");
1.14 paf 291: }
292:
1.15 paf 293: bool ping(void *aconnection) {
1.14 paf 294: Connection& connection=*static_cast<Connection*>(aconnection);
295: return mysql_ping(connection.handle)==0;
1.1 parser 296: }
297:
1.37 moko 298: // charset here is services.request_charset(), not connection.client_charset
299: // thus we can't use the sql server quoting support
300: const char* quote(void *aconnection, const char *str, unsigned int length) {
301: const char* from;
302: const char* from_end=str+length;
303:
304: size_t quoted=0;
305:
306: for(from=str; from<from_end; from++){
307: switch (*from) {
308: case 0:
309: case '\n':
310: case '\r':
311: case '\032':
312: case '\\':
313: case '\'':
314: case '"':
315: quoted++;
316: }
317: }
318:
319: if(!quoted)
320: return str;
321:
1.15 paf 322: Connection& connection=*static_cast<Connection*>(aconnection);
1.37 moko 323: char *result=(char*)connection.services->malloc_atomic(length + quoted + 1);
324: char *to = result;
325:
326: for(from=str; from<from_end; from++){
327: char escape;
328: switch (*from) {
329: case 0:
330: escape= '0';
331: break;
332: case '\n':
333: escape= 'n';
334: break;
335: case '\r':
336: escape= 'r';
337: break;
338: case '\032':
339: escape= 'Z';
340: break;
341: case '\\':
342: case '\'':
343: case '"':
344: escape= *from;
345: break;
346: default:
347: *to++=*from;
348: continue;
349: }
350: *to++= '\\';
351: *to++= escape;
352: }
353:
354: *to=0;
1.13 paf 355: return result;
1.1 parser 356: }
1.33 misha 357:
1.24 paf 358: void query(void *aconnection,
1.33 misha 359: const char *astatement,
360: size_t placeholders_count, Placeholder* placeholders,
361: unsigned long offset, unsigned long limit,
362: SQL_Driver_query_event_handlers& handlers
363: ){
1.14 paf 364: Connection& connection=*static_cast<Connection*>(aconnection);
1.15 paf 365: SQL_Driver_services& services=*connection.services;
1.1 parser 366: MYSQL_RES *res=NULL;
1.24 paf 367:
368: if(placeholders_count>0)
369: services._throw("bind variables not supported (yet)");
1.1 parser 370:
1.33 misha 371: bool transcode_needed=_transcode_required(connection);
372:
1.38 misha 373: size_t statement_size=0;
374:
375: if(transcode_needed) {
376: statement_size=strlen(astatement);
377: // transcode query from $request:charset to ?ClientCharset
378: services.transcode(astatement, statement_size,
379: astatement, statement_size,
1.19 paf 380: services.request_charset(),
1.33 misha 381: connection.client_charset);
1.19 paf 382: }
383:
1.1 parser 384: const char *statement;
1.38 misha 385: if(offset || limit!=SQL_NO_LIMIT) {
386: if(!statement_size)
387: statement_size=strlen(astatement);
1.13 paf 388: char *statement_limited=(char *)services.malloc_atomic(
1.33 misha 389: statement_size+MAX_NUMBER*2+8/* LIMIT #,#*/+1);
1.1 parser 390: char *cur=statement_limited;
391: memcpy(cur, astatement, statement_size); cur+=statement_size;
1.33 misha 392: cur+=sprintf(cur, " LIMIT ");
1.1 parser 393: if(offset)
1.42 moko 394: cur+=snprintf(cur, MAX_NUMBER, "%lu,", offset);
1.33 misha 395: if(limit!=SQL_NO_LIMIT)
1.41 moko 396: cur+=snprintf(cur, MAX_NUMBER, "%lu", limit);
1.1 parser 397: statement=statement_limited;
398: } else
399: statement=astatement;
400:
1.14 paf 401: if(mysql_query(connection.handle, statement))
1.33 misha 402: _throw(connection, mysql_error(connection.handle));
1.38 misha 403: if(!(res=mysql_store_result(connection.handle)) && mysql_field_count(connection.handle))
1.33 misha 404: _throw(connection, mysql_error(connection.handle));
1.1 parser 405: if(!res) // empty result: insert|delete|update|...
406: return;
1.38 misha 407:
408: size_t column_count=mysql_num_fields(res);
1.1 parser 409: if(!column_count) // old client
1.14 paf 410: column_count=mysql_field_count(connection.handle);
1.1 parser 411:
1.33 misha 412: if(!column_count){
1.1 parser 413: mysql_free_result(res);
414: services._throw("result contains no columns");
415: }
1.38 misha 416:
1.9 paf 417: bool failed=false;
418: SQL_Error sql_error;
1.38 misha 419:
420: #define CHECK(afailed) \
421: if(afailed) { \
422: failed=true; \
1.9 paf 423: goto cleanup; \
424: }
425:
1.44 moko 426: #define DO_FETCH_FIELDS(transcode_column_name) { \
427: for(size_t i=0; i<column_count; i++) { \
428: if(MYSQL_FIELD *field = mysql_fetch_field(res)){ \
429: size_t length=field->name_length; \
430: const char* str=strdup(services, field->name, length); \
431: transcode_column_name \
432: CHECK(handlers.add_column(sql_error, str, length)); \
433: } else { \
434: /* seen broken client, that reported "44" column count for "select 2+2" */ \
435: column_count=i; \
436: break; \
437: } \
438: } \
439: }
440:
441: #define DO_FETCH_ROWS(transcode_cell_value) { \
442: while(MYSQL_ROW mysql_row=mysql_fetch_row(res)) { \
443: CHECK(handlers.add_row(sql_error)); \
444: unsigned long *lengths=mysql_fetch_lengths(res); \
445: for(size_t i=0; i<column_count; i++) { \
446: const char* str=0; \
447: size_t length=lengths[i]; \
448: if(length) { \
449: str=strdup(services, mysql_row[i], length); \
450: transcode_cell_value \
451: } \
452: CHECK(handlers.add_row_cell(sql_error, str, length)); \
453: } \
454: } \
1.38 misha 455: }
456:
457: bool* transcode_column=0;
458: if(transcode_needed) {
459: transcode_column = new bool[column_count];
460: DO_FETCH_FIELDS(
1.44 moko 461: transcode_column[i] = is_column_transcode_required(field->type);
1.38 misha 462: // transcode column's name from ?ClientCharset to $request:charset
463: services.transcode(str, length,
464: str, length,
465: connection.client_charset,
466: services.request_charset());
467: )
468: CHECK(handlers.before_rows(sql_error));
469: DO_FETCH_ROWS(
470: if(transcode_column[i])
471: // transcode cell's value from ?ClientCharset to $request:charset
1.19 paf 472: services.transcode(str, length,
473: str, length,
1.33 misha 474: connection.client_charset,
1.19 paf 475: services.request_charset());
1.38 misha 476: )
477: } else {
478: // without transcoding
479: DO_FETCH_FIELDS()
480: CHECK(handlers.before_rows(sql_error));
481: DO_FETCH_ROWS()
1.32 misha 482: }
1.9 paf 483: cleanup:
1.38 misha 484: if(transcode_column)
485: delete transcode_column;
1.1 parser 486: mysql_free_result(res);
1.9 paf 487: if(failed)
488: services._throw(sql_error);
1.1 parser 489: }
490:
1.33 misha 491: private:
492: void _exec(Connection& connection, const char* statement) {
493: if(mysql_query(connection.handle, statement))
494: _throw(connection, mysql_error(connection.handle));
495: (*mysql_store_result)(connection.handle); // throw out the result [don't need but must call]
496: }
497:
498: void _throw(Connection& connection, const char* aerr_msg) {
499: size_t length=strlen(aerr_msg);
500: if(length && _transcode_required(connection)) {
501: connection.services->transcode(aerr_msg, length,
502: aerr_msg, length,
503: connection.client_charset,
504: connection.services->request_charset());
505: }
506: connection.services->_throw(aerr_msg);
507: }
508:
509: bool _transcode_required(Connection& connection){
510: return (connection.client_charset && strcmp(connection.client_charset, connection.services->request_charset())!=0);
511: }
512:
1.1 parser 513: private: // mysql client library funcs
514:
1.33 misha 515: typedef MYSQL* (STDCALL *t_mysql_init)(MYSQL *); t_mysql_init mysql_init;
1.1 parser 516:
1.33 misha 517: typedef void (STDCALL *t_mysql_server_end)(); t_mysql_server_end mysql_server_end;
1.29 misha 518:
1.33 misha 519: typedef int (STDCALL *t_mysql_options)(MYSQL *mysql, enum mysql_option option, const char *arg); t_mysql_options mysql_options;
1.2 parser 520:
1.1 parser 521: typedef MYSQL_RES* (STDCALL *t_mysql_store_result)(MYSQL *); t_mysql_store_result mysql_store_result;
522:
523: typedef int (STDCALL *t_mysql_query)(MYSQL *, const char *q); t_mysql_query mysql_query;
524:
1.33 misha 525: typedef char* (STDCALL *t_mysql_error)(MYSQL *); t_mysql_error mysql_error;
1.1 parser 526: static char* STDCALL subst_mysql_error(MYSQL *mysql) { return (mysql)->net.last_error; }
527:
1.33 misha 528: typedef MYSQL* (STDCALL *t_mysql_real_connect)(MYSQL *, const char *host,
529: const char *user,
530: const char *passwd,
531: const char *db,
532: unsigned int port,
533: const char *unix_socket,
534: unsigned int clientflag); t_mysql_real_connect mysql_real_connect;
1.1 parser 535:
1.33 misha 536: typedef void (STDCALL *t_mysql_close)(MYSQL *); t_mysql_close mysql_close;
1.1 parser 537:
538: typedef int (STDCALL *t_mysql_ping)(MYSQL *); t_mysql_ping mysql_ping;
539:
540: typedef unsigned long (STDCALL *t_mysql_escape_string)(char *to,const char *from,
1.33 misha 541: unsigned long from_length); t_mysql_escape_string mysql_escape_string;
1.1 parser 542:
1.33 misha 543: typedef void (STDCALL *t_mysql_free_result)(MYSQL_RES *result); t_mysql_free_result mysql_free_result;
1.1 parser 544:
545: typedef unsigned long* (STDCALL *t_mysql_fetch_lengths)(MYSQL_RES *result); t_mysql_fetch_lengths mysql_fetch_lengths;
546:
547: typedef MYSQL_ROW (STDCALL *t_mysql_fetch_row)(MYSQL_RES *result); t_mysql_fetch_row mysql_fetch_row;
548:
1.44 moko 549: typedef MYSQL_FIELD* (STDCALL *t_mysql_fetch_field)(MYSQL_RES *result); t_mysql_fetch_field mysql_fetch_field;
1.1 parser 550:
1.33 misha 551: typedef unsigned int (STDCALL *t_mysql_num_fields)(MYSQL_RES *); t_mysql_num_fields mysql_num_fields;
552: typedef unsigned int (STDCALL *t_mysql_field_count)(MYSQL *); t_mysql_field_count mysql_field_count;
1.1 parser 553:
1.33 misha 554: static unsigned int STDCALL subst_mysql_num_fields(MYSQL_RES *res) { return res->field_count; }
555: static unsigned int STDCALL subst_mysql_field_count(MYSQL *mysql) { return mysql->field_count; }
1.1 parser 556:
557: private: // mysql client library funcs linking
558:
559: const char *dlink(const char *dlopen_file_spec) {
1.43 moko 560: if(lt_dlinit()){
561: if(const char* result=lt_dlerror())
562: return result;
563: return "can not prepare to dynamic loading";
564: }
1.25 paf 565:
1.33 misha 566: lt_dlhandle handle=lt_dlopen(dlopen_file_spec);
567:
568: if(!handle){
569: if(const char* result=lt_dlerror())
570: return result;
1.1 parser 571: return "can not open the dynamic link module";
1.25 paf 572: }
1.1 parser 573:
1.29 misha 574: #define GLINK(name) \
575: name=(t_##name)lt_dlsym(handle, #name);
576:
1.1 parser 577: #define DSLINK(name, action) \
1.29 misha 578: GLINK(name) \
1.1 parser 579: if(!name) \
580: action;
581:
582: #define DLINK(name) DSLINK(name, return "function " #name " was not found")
583: #define SLINK(name) DSLINK(name, name=subst_##name)
584:
585: DLINK(mysql_init);
1.29 misha 586: GLINK(mysql_server_end);
1.2 parser 587: DLINK(mysql_options);
1.1 parser 588: DLINK(mysql_store_result);
589: DLINK(mysql_query);
590: SLINK(mysql_error);
591: DLINK(mysql_real_connect);
592: DLINK(mysql_close);
593: DLINK(mysql_ping);
594: DLINK(mysql_escape_string);
595: DLINK(mysql_free_result);
596: DLINK(mysql_fetch_lengths);
597: DLINK(mysql_fetch_row);
1.44 moko 598: DLINK(mysql_fetch_field);
1.1 parser 599: SLINK(mysql_num_fields);
600: SLINK(mysql_field_count);
601: return 0;
602: }
603:
604: };
605:
606: extern "C" SQL_Driver *SQL_DRIVER_CREATE() {
1.29 misha 607: static MySQL_Driver Driver;
608: return &Driver;
1.1 parser 609: }