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