Merge lp:~brianaker/libdrizzle/api-reworking into lp:libdrizzle

Proposed by Brian Aker
Status: Merged
Merged at revision: 103
Proposed branch: lp:~brianaker/libdrizzle/api-reworking
Merge into: lp:libdrizzle
Diff against target: 1050 lines (+445/-193)
23 files modified
configure.ac (+1/-0)
libdrizzle-5.1/drizzle.h (+0/-11)
libdrizzle-5.1/drizzle_client.h (+4/-20)
libdrizzle-5.1/include.am (+0/-1)
libdrizzle/common.h (+1/-0)
libdrizzle/conn.cc (+9/-9)
libdrizzle/drizzle.cc (+55/-60)
libdrizzle/drizzle_local.h (+6/-37)
libdrizzle/handshake_client.h (+0/-4)
libdrizzle/include.am (+5/-0)
libdrizzle/statement.cc (+1/-1)
m4/ax_pthread.m4 (+313/-0)
rpm/spec.in (+0/-1)
tests/unit/binlog.cc (+5/-5)
tests/unit/column.c (+5/-5)
tests/unit/connect.c (+5/-5)
tests/unit/connect_uds.c (+5/-4)
tests/unit/insert_id.c (+5/-5)
tests/unit/query.c (+5/-5)
tests/unit/row.c (+5/-5)
tests/unit/statement.c (+5/-5)
tests/unit/statement_char.c (+5/-5)
tests/unit/unbuffered_query.c (+5/-5)
To merge this branch: bzr merge lp:~brianaker/libdrizzle/api-reworking
Reviewer Review Type Date Requested Status
Drizzle Trunk Pending
Review via email: mp+145082@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'configure.ac'
2--- configure.ac 2013-01-26 23:44:28 +0000
3+++ configure.ac 2013-01-27 10:01:22 +0000
4@@ -92,6 +92,7 @@
5 AC_CHECK_FUNCS([poll])
6 AC_CHECK_FUNCS([ppoll])
7
8+AX_PTHREAD(, [AC_MSG_ERROR(could not find libpthread)])
9 AX_ENDIAN
10 AX_HEX_VERSION([LIBDRIZZLE],[$VERSION])
11 AX_HARDEN_COMPILER_FLAGS
12
13=== modified file 'libdrizzle-5.1/drizzle.h'
14--- libdrizzle-5.1/drizzle.h 2013-01-05 15:46:05 +0000
15+++ libdrizzle-5.1/drizzle.h 2013-01-27 10:01:22 +0000
16@@ -82,17 +82,6 @@
17 */
18
19 /**
20- * Intialize the Drizzle library
21- *
22- * Currently only initalizes the SSL library
23- */
24-DRIZZLE_API
25-void drizzle_library_init(void);
26-
27-DRIZZLE_API
28-void drizzle_library_deinit(void);
29-
30-/**
31 * Get library version string.
32 *
33 * @return Pointer to static buffer in library that holds the version string.
34
35=== modified file 'libdrizzle-5.1/drizzle_client.h'
36--- libdrizzle-5.1/drizzle_client.h 2013-01-27 00:09:17 +0000
37+++ libdrizzle-5.1/drizzle_client.h 2013-01-27 10:01:22 +0000
38@@ -55,7 +55,6 @@
39
40 #include <libdrizzle-5.1/drizzle.h>
41 #include <libdrizzle-5.1/conn_client.h>
42-#include <libdrizzle-5.1/handshake_client.h>
43 #include <libdrizzle-5.1/query.h>
44 #include <libdrizzle-5.1/result_client.h>
45 #include <libdrizzle-5.1/column_client.h>
46@@ -94,25 +93,10 @@
47 * @return Same return as drizzle_create().
48 */
49 DRIZZLE_API
50-drizzle_st *drizzle_create_tcp(const char *host, in_port_t port,
51- const char *user, const char *password,
52- const char *db,
53- drizzle_options_st *options);
54-
55-/**
56- * Add unix domain socket connection with common arguments.
57- *
58- * @param[in] uds Path to unix domain socket to use for connection.
59- * @param[in] user User to use while establishing the connection.
60- * @param[in] password Password to use while establishing the connection.
61- * @param[in] db Initial database to connect to.
62- * @param[in] options Drizzle connection options to add.
63- * @return Same return as drizzle_create().
64- */
65-DRIZZLE_API
66-drizzle_st *drizzle_create_uds(const char *uds, const char *user,
67- const char *password, const char *db,
68- drizzle_options_st *options);
69+ drizzle_st *drizzle_create(const char *host, in_port_t port,
70+ const char *user, const char *password,
71+ const char *db,
72+ drizzle_options_st *options);
73
74 /** @} */
75
76
77=== modified file 'libdrizzle-5.1/include.am'
78--- libdrizzle-5.1/include.am 2013-01-26 23:44:28 +0000
79+++ libdrizzle-5.1/include.am 2013-01-27 10:01:22 +0000
80@@ -12,7 +12,6 @@
81 nobase_include_HEADERS+= libdrizzle-5.1/drizzle_client.h
82 nobase_include_HEADERS+= libdrizzle-5.1/error.h
83 nobase_include_HEADERS+= libdrizzle-5.1/field_client.h
84-nobase_include_HEADERS+= libdrizzle-5.1/handshake_client.h
85 nobase_include_HEADERS+= libdrizzle-5.1/libdrizzle.h
86 nobase_include_HEADERS+= libdrizzle-5.1/query.h
87 nobase_include_HEADERS+= libdrizzle-5.1/result.h
88
89=== modified file 'libdrizzle/common.h'
90--- libdrizzle/common.h 2013-01-13 19:35:23 +0000
91+++ libdrizzle/common.h 2013-01-27 10:01:22 +0000
92@@ -88,5 +88,6 @@
93 #include "libdrizzle/statement_local.h"
94 #include "libdrizzle/column.h"
95 #include "libdrizzle/binlog.h"
96+#include "libdrizzle/handshake_client.h"
97
98 #include <memory.h>
99
100=== modified file 'libdrizzle/conn.cc'
101--- libdrizzle/conn.cc 2013-01-27 04:54:08 +0000
102+++ libdrizzle/conn.cc 2013-01-27 10:01:22 +0000
103@@ -113,13 +113,13 @@
104 {
105 if (fds[0].revents & (POLLIN))
106 {
107- drizzle_log_crazy(con, "poll(POLLIN)");
108+ drizzle_log_debug(con, "poll(POLLIN)");
109 return true;
110 }
111
112 if (fds[0].revents & (POLLOUT))
113 {
114- drizzle_log_crazy(con, "poll(POLLOUT)");
115+ drizzle_log_debug(con, "poll(POLLOUT)");
116 return true;
117 }
118
119@@ -155,7 +155,7 @@
120 else if (error == 0)
121 {
122 // "timeout occurred while trying to connect"
123- drizzle_log_crazy(con, "poll(TIMEOUT) %d", con->timeout);
124+ drizzle_log_debug(con, "poll(TIMEOUT) %d", con->timeout);
125 return false;
126 }
127
128@@ -699,7 +699,7 @@
129 {
130 if (con != NULL)
131 {
132- drizzle_log_crazy(con, "shutting down the connection");
133+ drizzle_log_debug(con, "shutting down the connection");
134 con->flags.is_shutdown= true;
135 drizzle_return_t ret;
136 drizzle_result_st *result;
137@@ -945,7 +945,7 @@
138 host= tcp->host;
139 }
140
141- drizzle_log_crazy(con, "host=%s port=%s", host, port);
142+ drizzle_log_debug(con, "host=%s port=%s", host, port);
143 int ret= getaddrinfo(host, port, &ai, &(tcp->addrinfo));
144 if (ret != 0)
145 {
146@@ -1074,7 +1074,7 @@
147 errno= translate_windows_error();
148 #endif /* _WIN32 */
149
150- drizzle_log_crazy(con, "connect return=%d errno=%s", ret, strerror(errno));
151+ drizzle_log_debug(con, "connect return=%d errno=%s", ret, strerror(errno));
152
153 if (ret == 0)
154 {
155@@ -1259,7 +1259,7 @@
156 errno= translate_windows_error();
157 #endif // defined _WIN32 || defined __CYGWIN__
158
159- drizzle_log_crazy(con, "read fd=%d avail= %zd recv=%zd ssl= %d errno=%s",
160+ drizzle_log_debug(con, "read fd=%d avail= %zd recv=%zd ssl= %d errno=%s",
161 con->fd, available_buffer, read_size,
162 (con->ssl_state == DRIZZLE_SSL_STATE_HANDSHAKE_COMPLETE) ? 1 : 0,
163 strerror(errno));
164@@ -1319,7 +1319,7 @@
165
166 case EINVAL:
167 {
168- drizzle_log_crazy(con, "EINVAL fd=%d buffer=%p available_buffer=%zd",
169+ drizzle_log_debug(con, "EINVAL fd=%d buffer=%p available_buffer=%zd",
170 con->fd, (char *)con->buffer_ptr + con->buffer_size, available_buffer);
171 }
172 break;
173@@ -1382,7 +1382,7 @@
174 errno= translate_windows_error();
175 #endif // defined _WIN32 || defined __CYGWIN__
176
177- drizzle_log_crazy(con, "write fd=%d return=%zd ssl=%d errno=%s",
178+ drizzle_log_debug(con, "write fd=%d return=%zd ssl=%d errno=%s",
179 con->fd, write_size,
180 (con->ssl_state == DRIZZLE_SSL_STATE_HANDSHAKE_COMPLETE) ? 1 : 0,
181 strerror(errno));
182
183=== modified file 'libdrizzle/drizzle.cc'
184--- libdrizzle/drizzle.cc 2013-01-27 05:08:57 +0000
185+++ libdrizzle/drizzle.cc 2013-01-27 10:01:22 +0000
186@@ -44,6 +44,7 @@
187 #include "libdrizzle/common.h"
188
189 #include <cerrno>
190+#include <pthread.h>
191
192 /**
193 * @addtogroup drizzle_static Static Drizzle Declarations
194@@ -69,28 +70,46 @@
195 * Common Definitions
196 */
197
198-void drizzle_library_init(void)
199+static pthread_once_t ssl_startup_once= PTHREAD_ONCE_INIT;
200+
201+static void drizzle_library_deinit(void)
202+{
203+#if defined(_WIN32)
204+ /* if it is MS windows, invoke WSACleanup() at the end*/
205+ WSACleanup();
206+#endif
207+}
208+
209+static void ssl_startup_function(void)
210 {
211 #ifdef USE_OPENSSL
212 SSL_library_init();
213+ ERR_load_crypto_strings();
214+ SSL_load_error_strings();
215+ OpenSSL_add_all_algorithms();
216 #endif
217 #if defined(_WIN32)
218 /* if it is MS windows, invoke WSAStartup */
219 WSADATA wsaData;
220 if ( WSAStartup( MAKEWORD(2,2), &wsaData ) != 0 )
221 {
222- printf("Error at WSAStartup()\n");
223+ fprintf(stderr, "Error at WSAStartup()\n");
224 }
225 #endif
226
227+ (void)atexit(drizzle_library_deinit);
228 }
229
230-void drizzle_library_deinit(void)
231+bool drizzle_library_init(drizzle_st* connection)
232 {
233-#if defined(_WIN32)
234- /* if it is MS windows, invoke WSACleanup() at the end*/
235- WSACleanup();
236-#endif
237+ int pthread_error;
238+ if ((pthread_error= pthread_once(&ssl_startup_once, ssl_startup_function)) == -1)
239+ {
240+ drizzle_set_error(connection, "pthread_once", "error:%s", strerror(errno));
241+ return false;
242+ }
243+
244+ return true;
245 }
246
247 const char *drizzle_version(void)
248@@ -153,8 +172,7 @@
249 con->verbose= verbose;
250 }
251
252-void drizzle_set_log_fn(drizzle_st *con, drizzle_log_fn *function,
253- void *context)
254+void drizzle_set_log_fn(drizzle_st *con, drizzle_log_fn *function, void *context)
255 {
256 if (con == NULL)
257 {
258@@ -165,22 +183,9 @@
259 con->log_context= context;
260 }
261
262-drizzle_st *drizzle_create(void)
263-{
264- drizzle_st *con;
265-
266- con= new (std::nothrow) drizzle_st;
267- if (con == NULL)
268- {
269- return NULL;
270- }
271-
272- return con;
273-}
274-
275 drizzle_st *drizzle_clone(drizzle_st *drizzle, const drizzle_st *from)
276 {
277- drizzle= drizzle_create();
278+ drizzle= new (std::nothrow) drizzle_st;
279 if (drizzle == NULL)
280 {
281 return NULL;
282@@ -271,11 +276,11 @@
283 int ret;
284 while (1)
285 {
286- drizzle_log_crazy(con, "poll timeout=%d", con->timeout);
287+ drizzle_log_debug(con, "poll timeout=%d", con->timeout);
288
289 ret= poll(con->pfds, 1, con->timeout);
290
291- drizzle_log_crazy(con, "poll return=%d errno=%d", ret, errno);
292+ drizzle_log_debug(con, "poll return=%d errno=%d", ret, errno);
293
294 if (ret == -1)
295 {
296@@ -319,41 +324,31 @@
297 * Client Definitions
298 */
299
300-drizzle_st *drizzle_create_tcp(const char *host, in_port_t port,
301- const char *user, const char *password,
302- const char *db,
303- drizzle_options_st *options)
304-{
305- drizzle_st *con= drizzle_create();
306- if (con == NULL)
307- {
308- return NULL;
309- }
310-
311- drizzle_set_tcp(con, host, port);
312- drizzle_set_auth(con, user, password);
313- drizzle_set_db(con, db);
314- if (options != NULL)
315- {
316- con->options= *options;
317- }
318-
319- return con;
320-}
321-
322-drizzle_st *drizzle_create_uds(const char *uds, const char *user,
323- const char *password, const char *db,
324- drizzle_options_st *options)
325-{
326- drizzle_st *con;
327-
328- con= drizzle_create();
329- if (con == NULL)
330- {
331- return NULL;
332- }
333-
334- drizzle_set_uds(con, uds);
335+drizzle_st *drizzle_create(const char *host, in_port_t port,
336+ const char *user, const char *password,
337+ const char *db,
338+ drizzle_options_st *options)
339+{
340+ drizzle_st *con= new (std::nothrow) drizzle_st;
341+ if (con == NULL)
342+ {
343+ return NULL;
344+ }
345+
346+ if (drizzle_library_init(con) == false)
347+ {
348+ delete con;
349+ return NULL;
350+ }
351+
352+ if (host and host[0] == '/')
353+ {
354+ drizzle_set_uds(con, host);
355+ }
356+ else
357+ {
358+ drizzle_set_tcp(con, host, port);
359+ }
360 drizzle_set_auth(con, user, password);
361 drizzle_set_db(con, db);
362 if (options != NULL)
363
364=== modified file 'libdrizzle/drizzle_local.h'
365--- libdrizzle/drizzle_local.h 2013-01-27 01:57:09 +0000
366+++ libdrizzle/drizzle_local.h 2013-01-27 10:01:22 +0000
367@@ -58,21 +58,7 @@
368 * @param[in] function Name of function the error happened in.
369 * @param[in] format Format and variable argument list of message.
370 */
371-void drizzle_set_error(drizzle_st *con, const char *function,
372- const char *format, ...);
373-
374-/**
375- * Initialize a connection structure. Always check the return value even if
376- * passing in a pre-allocated structure. Some other initialization may have
377- * failed.
378- *
379- * @param[in] drizzle Drizzle structure previously initialized with
380- * drizzle_create() or drizzle_clone().
381- * @param[in] con Caller allocated structure, or NULL to allocate one.
382- * @return On success, a pointer to the (possibly allocated) structure. On
383- * failure this will be NULL.
384- */
385-drizzle_st *drizzle_create(void);
386+void drizzle_set_error(drizzle_st *con, const char *function, const char *format, ...);
387
388 /**
389 * Free a connection structure.
390@@ -84,6 +70,8 @@
391
392 drizzle_st *drizzle_clone(drizzle_st *drizzle, const drizzle_st *from);
393
394+bool drizzle_library_init(drizzle_st*);
395+
396 /**
397 * Log a message.
398 *
399@@ -123,8 +111,7 @@
400 /**
401 * Log an error message, see drizzle_log() for argument details.
402 */
403-static inline void drizzle_log_error(drizzle_st *con, const char *format,
404- ...)
405+static inline void drizzle_log_error(drizzle_st *con, const char *format, ...)
406 {
407 va_list args;
408
409@@ -139,8 +126,7 @@
410 /**
411 * Log an info message, see drizzle_log() for argument details.
412 */
413-static inline void drizzle_log_info(drizzle_st *con, const char *format,
414- ...)
415+static inline void drizzle_log_info(drizzle_st *con, const char *format, ...)
416 {
417 va_list args;
418
419@@ -155,24 +141,7 @@
420 /**
421 * Log a debug message, see drizzle_log() for argument details.
422 */
423-static inline void drizzle_log_debug(drizzle_st *con, const char *format,
424- ...)
425-{
426- va_list args;
427-
428- if (con->verbose >= DRIZZLE_VERBOSE_DEBUG)
429- {
430- va_start(args, format);
431- drizzle_log(con, DRIZZLE_VERBOSE_DEBUG, format, args);
432- va_end(args);
433- }
434-}
435-
436-/**
437- * Log a crazy message, see drizzle_log() for argument details.
438- */
439-static inline void drizzle_log_crazy(drizzle_st *con, const char *format,
440- ...)
441+static inline void drizzle_log_debug(drizzle_st *con, const char *format, ...)
442 {
443 va_list args;
444
445
446=== renamed file 'libdrizzle-5.1/handshake_client.h' => 'libdrizzle/handshake_client.h'
447--- libdrizzle-5.1/handshake_client.h 2012-12-22 08:54:15 +0000
448+++ libdrizzle/handshake_client.h 2013-01-27 10:01:22 +0000
449@@ -62,7 +62,6 @@
450 * drizzle_create(), drizzle_clone(), or related functions.
451 * @return Standard drizzle return value.
452 */
453-DRIZZLE_API
454 drizzle_return_t drizzle_handshake_server_read(drizzle_st *con);
455
456 /**
457@@ -72,7 +71,6 @@
458 * drizzle_create(), drizzle_clone(), or related functions.
459 * @return Standard drizzle return value.
460 */
461-DRIZZLE_API
462 drizzle_return_t drizzle_handshake_client_write(drizzle_st *con);
463
464 /**
465@@ -82,10 +80,8 @@
466 * drizzle_create(), drizzle_clone(), or related functions.
467 * @return Standard drizzle return value.
468 */
469-DRIZZLE_API
470 drizzle_return_t drizzle_handshake_ssl_client_write(drizzle_st *con);
471
472-DRIZZLE_API
473 int drizzle_compile_capabilities(drizzle_st *con);
474
475 /** @} */
476
477=== modified file 'libdrizzle/include.am'
478--- libdrizzle/include.am 2013-01-27 04:16:09 +0000
479+++ libdrizzle/include.am 2013-01-27 10:01:22 +0000
480@@ -8,6 +8,7 @@
481 noinst_HEADERS+= libdrizzle/conn_local.h
482 noinst_HEADERS+= libdrizzle/datetime.h
483 noinst_HEADERS+= libdrizzle/drizzle_local.h
484+noinst_HEADERS+= libdrizzle/handshake_client.h
485 noinst_HEADERS+= libdrizzle/pack.h
486 noinst_HEADERS+= libdrizzle/packet.h
487 noinst_HEADERS+= libdrizzle/poll.h
488@@ -29,6 +30,10 @@
489 libdrizzle_libdrizzle_la_LDFLAGS+= @OPENSSL_LDFLAGS@
490 libdrizzle_libdrizzle_la_LIBADD+= @OPENSSL_LIBS@
491
492+libdrizzle_libdrizzle_la_CFLAGS+= @PTHREAD_CFLAGS@
493+libdrizzle_libdrizzle_la_CXXFLAGS+= @PTHREAD_CFLAGS@
494+libdrizzle_libdrizzle_la_LIBADD+= @PTHREAD_LIBS@
495+
496 libdrizzle_libdrizzle_la_CFLAGS+= @ZLIB_CFLAGS@
497 libdrizzle_libdrizzle_la_CXXFLAGS+= @ZLIB_CFLAGS@
498 libdrizzle_libdrizzle_la_LDFLAGS+= @ZLIB_LDFLAGS@
499
500=== modified file 'libdrizzle/statement.cc'
501--- libdrizzle/statement.cc 2013-01-27 00:42:59 +0000
502+++ libdrizzle/statement.cc 2013-01-27 10:01:22 +0000
503@@ -2,7 +2,7 @@
504 *
505 * Drizzle Client & Protocol Library
506 *
507- * Copyright (C) 2012 Drizzle Developer Group
508+ * Copyright (C) 2012-2013 Drizzle Developer Group
509 * All rights reserved.
510 *
511 * Redistribution and use in source and binary forms, with or without
512
513=== added file 'm4/ax_pthread.m4'
514--- m4/ax_pthread.m4 1970-01-01 00:00:00 +0000
515+++ m4/ax_pthread.m4 2013-01-27 10:01:22 +0000
516@@ -0,0 +1,313 @@
517+# ===========================================================================
518+# http://www.gnu.org/software/autoconf-archive/ax_pthread.html
519+# ===========================================================================
520+#
521+# SYNOPSIS
522+#
523+# AX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
524+#
525+# DESCRIPTION
526+#
527+# This macro figures out how to build C programs using POSIX threads. It
528+# sets the PTHREAD_LIBS output variable to the threads library and linker
529+# flags, and the PTHREAD_CFLAGS output variable to any special C compiler
530+# flags that are needed. (The user can also force certain compiler
531+# flags/libs to be tested by setting these environment variables.)
532+#
533+# Also sets PTHREAD_CC to any special C compiler that is needed for
534+# multi-threaded programs (defaults to the value of CC otherwise). (This
535+# is necessary on AIX to use the special cc_r compiler alias.)
536+#
537+# NOTE: You are assumed to not only compile your program with these flags,
538+# but also link it with them as well. e.g. you should link with
539+# $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS
540+#
541+# If you are only building threads programs, you may wish to use these
542+# variables in your default LIBS, CFLAGS, and CC:
543+#
544+# LIBS="$PTHREAD_LIBS $LIBS"
545+# CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
546+# CC="$PTHREAD_CC"
547+#
548+# In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant
549+# has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to that name
550+# (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
551+#
552+# Also HAVE_PTHREAD_PRIO_INHERIT is defined if pthread is found and the
553+# PTHREAD_PRIO_INHERIT symbol is defined when compiling with
554+# PTHREAD_CFLAGS.
555+#
556+# ACTION-IF-FOUND is a list of shell commands to run if a threads library
557+# is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it
558+# is not found. If ACTION-IF-FOUND is not specified, the default action
559+# will define HAVE_PTHREAD.
560+#
561+# Please let the authors know if this macro fails on any platform, or if
562+# you have any other suggestions or comments. This macro was based on work
563+# by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help
564+# from M. Frigo), as well as ac_pthread and hb_pthread macros posted by
565+# Alejandro Forero Cuervo to the autoconf macro repository. We are also
566+# grateful for the helpful feedback of numerous users.
567+#
568+# Updated for Autoconf 2.68 by Daniel Richard G.
569+#
570+# LICENSE
571+#
572+# Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
573+# Copyright (c) 2011 Daniel Richard G. <skunk@iSKUNK.ORG>
574+#
575+# This program is free software: you can redistribute it and/or modify it
576+# under the terms of the GNU General Public License as published by the
577+# Free Software Foundation, either version 3 of the License, or (at your
578+# option) any later version.
579+#
580+# This program is distributed in the hope that it will be useful, but
581+# WITHOUT ANY WARRANTY; without even the implied warranty of
582+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
583+# Public License for more details.
584+#
585+# You should have received a copy of the GNU General Public License along
586+# with this program. If not, see <http://www.gnu.org/licenses/>.
587+#
588+# As a special exception, the respective Autoconf Macro's copyright owner
589+# gives unlimited permission to copy, distribute and modify the configure
590+# scripts that are the output of Autoconf when processing the Macro. You
591+# need not follow the terms of the GNU General Public License when using
592+# or distributing such scripts, even though portions of the text of the
593+# Macro appear in them. The GNU General Public License (GPL) does govern
594+# all other use of the material that constitutes the Autoconf Macro.
595+#
596+# This special exception to the GPL applies to versions of the Autoconf
597+# Macro released by the Autoconf Archive. When you make and distribute a
598+# modified version of the Autoconf Macro, you may extend this special
599+# exception to the GPL to apply to your modified version as well.
600+
601+#serial 19
602+
603+AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD])
604+AC_DEFUN([AX_PTHREAD], [
605+AC_REQUIRE([AC_CANONICAL_HOST])
606+AC_LANG_PUSH([C])
607+ax_pthread_ok=no
608+
609+# We used to check for pthread.h first, but this fails if pthread.h
610+# requires special compiler flags (e.g. on True64 or Sequent).
611+# It gets checked for in the link test anyway.
612+
613+# First of all, check if the user has set any of the PTHREAD_LIBS,
614+# etcetera environment variables, and if threads linking works using
615+# them:
616+if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
617+ save_CFLAGS="$CFLAGS"
618+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
619+ save_LIBS="$LIBS"
620+ LIBS="$PTHREAD_LIBS $LIBS"
621+ AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
622+ AC_TRY_LINK_FUNC(pthread_join, ax_pthread_ok=yes)
623+ AC_MSG_RESULT($ax_pthread_ok)
624+ if test x"$ax_pthread_ok" = xno; then
625+ PTHREAD_LIBS=""
626+ PTHREAD_CFLAGS=""
627+ fi
628+ LIBS="$save_LIBS"
629+ CFLAGS="$save_CFLAGS"
630+fi
631+
632+# We must check for the threads library under a number of different
633+# names; the ordering is very important because some systems
634+# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
635+# libraries is broken (non-POSIX).
636+
637+# Create a list of thread flags to try. Items starting with a "-" are
638+# C compiler flags, and other items are library names, except for "none"
639+# which indicates that we try without any flags at all, and "pthread-config"
640+# which is a program returning the flags for the Pth emulation library.
641+
642+ax_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
643+
644+# The ordering *is* (sometimes) important. Some notes on the
645+# individual items follow:
646+
647+# pthreads: AIX (must check this before -lpthread)
648+# none: in case threads are in libc; should be tried before -Kthread and
649+# other compiler flags to prevent continual compiler warnings
650+# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
651+# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
652+# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
653+# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
654+# -pthreads: Solaris/gcc
655+# -mthreads: Mingw32/gcc, Lynx/gcc
656+# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
657+# doesn't hurt to check since this sometimes defines pthreads too;
658+# also defines -D_REENTRANT)
659+# ... -mt is also the pthreads flag for HP/aCC
660+# pthread: Linux, etcetera
661+# --thread-safe: KAI C++
662+# pthread-config: use pthread-config program (for GNU Pth library)
663+
664+case ${host_os} in
665+ solaris*)
666+
667+ # On Solaris (at least, for some versions), libc contains stubbed
668+ # (non-functional) versions of the pthreads routines, so link-based
669+ # tests will erroneously succeed. (We need to link with -pthreads/-mt/
670+ # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
671+ # a function called by this macro, so we could check for that, but
672+ # who knows whether they'll stub that too in a future libc.) So,
673+ # we'll just look for -pthreads and -lpthread first:
674+
675+ ax_pthread_flags="-pthreads pthread -mt -pthread $ax_pthread_flags"
676+ ;;
677+
678+ darwin12*)
679+ ax_pthread_flags="$ax_pthread_flags"
680+ ;;
681+
682+ darwin*)
683+ ax_pthread_flags="-pthread $ax_pthread_flags"
684+ ;;
685+esac
686+
687+if test x"$ax_pthread_ok" = xno; then
688+for flag in $ax_pthread_flags; do
689+
690+ case $flag in
691+ none)
692+ AC_MSG_CHECKING([whether pthreads work without any flags])
693+ ;;
694+
695+ -*)
696+ AC_MSG_CHECKING([whether pthreads work with $flag])
697+ PTHREAD_CFLAGS="$flag"
698+ ;;
699+
700+ pthread-config)
701+ AC_CHECK_PROG(ax_pthread_config, pthread-config, yes, no)
702+ if test x"$ax_pthread_config" = xno; then continue; fi
703+ PTHREAD_CFLAGS="`pthread-config --cflags`"
704+ PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
705+ ;;
706+
707+ *)
708+ AC_MSG_CHECKING([for the pthreads library -l$flag])
709+ PTHREAD_LIBS="-l$flag"
710+ ;;
711+ esac
712+
713+ save_LIBS="$LIBS"
714+ save_CFLAGS="$CFLAGS"
715+ LIBS="$PTHREAD_LIBS $LIBS"
716+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
717+
718+ # Check for various functions. We must include pthread.h,
719+ # since some functions may be macros. (On the Sequent, we
720+ # need a special flag -Kthread to make this header compile.)
721+ # We check for pthread_join because it is in -lpthread on IRIX
722+ # while pthread_create is in libc. We check for pthread_attr_init
723+ # due to DEC craziness with -lpthreads. We check for
724+ # pthread_cleanup_push because it is one of the few pthread
725+ # functions on Solaris that doesn't have a non-functional libc stub.
726+ # We try pthread_create on general principles.
727+ AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>
728+ static void routine(void *a) { a = 0; }
729+ static void *start_routine(void *a) { return a; }],
730+ [pthread_t th; pthread_attr_t attr;
731+ pthread_create(&th, 0, start_routine, 0);
732+ pthread_join(th, 0);
733+ pthread_attr_init(&attr);
734+ pthread_cleanup_push(routine, 0);
735+ pthread_cleanup_pop(0) /* ; */])],
736+ [ax_pthread_ok=yes],
737+ [])
738+
739+ LIBS="$save_LIBS"
740+ CFLAGS="$save_CFLAGS"
741+
742+ AC_MSG_RESULT($ax_pthread_ok)
743+ if test "x$ax_pthread_ok" = xyes; then
744+ break;
745+ fi
746+
747+ PTHREAD_LIBS=""
748+ PTHREAD_CFLAGS=""
749+done
750+fi
751+
752+# Various other checks:
753+if test "x$ax_pthread_ok" = xyes; then
754+ save_LIBS="$LIBS"
755+ LIBS="$PTHREAD_LIBS $LIBS"
756+ save_CFLAGS="$CFLAGS"
757+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
758+
759+ # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
760+ AC_MSG_CHECKING([for joinable pthread attribute])
761+ attr_name=unknown
762+ for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
763+ AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>],
764+ [int attr = $attr; return attr /* ; */])],
765+ [attr_name=$attr; break],
766+ [])
767+ done
768+ AC_MSG_RESULT($attr_name)
769+ if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
770+ AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name,
771+ [Define to necessary symbol if this constant
772+ uses a non-standard name on your system.])
773+ fi
774+
775+ AC_MSG_CHECKING([if more special flags are required for pthreads])
776+ flag=no
777+ case ${host_os} in
778+ aix* | freebsd* | darwin*) flag="-D_THREAD_SAFE";;
779+ osf* | hpux*) flag="-D_REENTRANT";;
780+ solaris*)
781+ if test "$GCC" = "yes"; then
782+ flag="-D_REENTRANT"
783+ else
784+ flag="-mt -D_REENTRANT"
785+ fi
786+ ;;
787+ esac
788+ AC_MSG_RESULT(${flag})
789+ if test "x$flag" != xno; then
790+ PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
791+ fi
792+
793+ AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT],
794+ ax_cv_PTHREAD_PRIO_INHERIT, [
795+ AC_LINK_IFELSE([
796+ AC_LANG_PROGRAM([[#include <pthread.h>]], [[int i = PTHREAD_PRIO_INHERIT;]])],
797+ [ax_cv_PTHREAD_PRIO_INHERIT=yes],
798+ [ax_cv_PTHREAD_PRIO_INHERIT=no])
799+ ])
800+ AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes"],
801+ AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], 1, [Have PTHREAD_PRIO_INHERIT.]))
802+
803+ LIBS="$save_LIBS"
804+ CFLAGS="$save_CFLAGS"
805+
806+ # More AIX lossage: must compile with xlc_r or cc_r
807+ if test x"$GCC" != xyes; then
808+ AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC})
809+ else
810+ PTHREAD_CC=$CC
811+ fi
812+else
813+ PTHREAD_CC="$CC"
814+fi
815+
816+AC_SUBST(PTHREAD_LIBS)
817+AC_SUBST(PTHREAD_CFLAGS)
818+AC_SUBST(PTHREAD_CC)
819+
820+# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
821+if test x"$ax_pthread_ok" = xyes; then
822+ ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])
823+ :
824+else
825+ ax_pthread_ok=no
826+ $2
827+fi
828+AC_LANG_POP
829+])dnl AX_PTHREAD
830
831=== modified file 'rpm/spec.in'
832--- rpm/spec.in 2013-01-27 00:42:59 +0000
833+++ rpm/spec.in 2013-01-27 10:01:22 +0000
834@@ -69,7 +69,6 @@
835 %{_includedir}/libdrizzle-5.1/drizzle_client.h
836 %{_includedir}/libdrizzle-5.1/error.h
837 %{_includedir}/libdrizzle-5.1/field_client.h
838-%{_includedir}/libdrizzle-5.1/handshake_client.h
839 %{_includedir}/libdrizzle-5.1/libdrizzle.h
840 %{_includedir}/libdrizzle-5.1/query.h
841 %{_includedir}/libdrizzle-5.1/result.h
842
843=== modified file 'tests/unit/binlog.cc'
844--- tests/unit/binlog.cc 2013-01-27 05:08:57 +0000
845+++ tests/unit/binlog.cc 2013-01-27 10:01:22 +0000
846@@ -73,11 +73,11 @@
847 (void) argv;
848 drizzle_binlog_st *binlog;
849
850- con= drizzle_create_tcp(getenv("MYSQL_SERVER"),
851- getenv("MYSQL_PORT") ? atoi("MYSQL_PORT") : DRIZZLE_DEFAULT_TCP_PORT,
852- getenv("MYSQL_USER"),
853- getenv("MYSQL_PASSWORD"),
854- getenv("MYSQL_SCHEMA"), NULL);
855+ con= drizzle_create(getenv("MYSQL_SERVER"),
856+ getenv("MYSQL_PORT") ? atoi("MYSQL_PORT") : DRIZZLE_DEFAULT_TCP_PORT,
857+ getenv("MYSQL_USER"),
858+ getenv("MYSQL_PASSWORD"),
859+ getenv("MYSQL_SCHEMA"), NULL);
860
861 CLOSE_ON_EXIT(con);
862 ASSERT_NOT_NULL_(con, "Drizzle connection object creation error");
863
864=== modified file 'tests/unit/column.c'
865--- tests/unit/column.c 2013-01-26 23:44:28 +0000
866+++ tests/unit/column.c 2013-01-27 10:01:22 +0000
867@@ -51,11 +51,11 @@
868 drizzle_row_t row;
869 int num_fields;
870
871- con= drizzle_create_tcp(getenv("MYSQL_SERVER"),
872- getenv("MYSQL_PORT") ? atoi("MYSQL_PORT") : DRIZZLE_DEFAULT_TCP_PORT,
873- getenv("MYSQL_USER"),
874- getenv("MYSQL_PASSWORD"),
875- getenv("MYSQL_SCHEMA"), 0);
876+ con= drizzle_create(getenv("MYSQL_SERVER"),
877+ getenv("MYSQL_PORT") ? atoi("MYSQL_PORT") : DRIZZLE_DEFAULT_TCP_PORT,
878+ getenv("MYSQL_USER"),
879+ getenv("MYSQL_PASSWORD"),
880+ getenv("MYSQL_SCHEMA"), 0);
881 ASSERT_NOT_NULL_(con, "Drizzle connection object creation error");
882 CLOSE_ON_EXIT(con);
883
884
885=== modified file 'tests/unit/connect.c'
886--- tests/unit/connect.c 2013-01-27 06:00:56 +0000
887+++ tests/unit/connect.c 2013-01-27 10:01:22 +0000
888@@ -47,11 +47,11 @@
889 (void) argc;
890 (void) argv;
891
892- drizzle_st *con= drizzle_create_tcp(getenv("MYSQL_SERVER"),
893- getenv("MYSQL_PORT") ? atoi("MYSQL_PORT") : DRIZZLE_DEFAULT_TCP_PORT,
894- getenv("MYSQL_USER"),
895- getenv("MYSQL_PASSWORD"),
896- getenv("MYSQL_SCHEMA"), 0);
897+ drizzle_st *con= drizzle_create(getenv("MYSQL_SERVER"),
898+ getenv("MYSQL_PORT") ? atoi("MYSQL_PORT") : DRIZZLE_DEFAULT_TCP_PORT,
899+ getenv("MYSQL_USER"),
900+ getenv("MYSQL_PASSWORD"),
901+ getenv("MYSQL_SCHEMA"), 0);
902 ASSERT_NOT_NULL_(con, "Drizzle connection object creation error");
903
904 drizzle_return_t ret= drizzle_connect(con);
905
906=== modified file 'tests/unit/connect_uds.c'
907--- tests/unit/connect_uds.c 2013-01-12 14:14:18 +0000
908+++ tests/unit/connect_uds.c 2013-01-27 10:01:22 +0000
909@@ -47,10 +47,11 @@
910 (void) argc;
911 (void) argv;
912
913- drizzle_st *con= drizzle_create_uds(getenv("MYSQL_SOCK"),
914- getenv("MYSQL_USER"),
915- getenv("MYSQL_PASSWORD"),
916- getenv("MYSQL_SCHEMA"), 0);
917+ drizzle_st *con= drizzle_create(getenv("MYSQL_SOCK"),
918+ 0,
919+ getenv("MYSQL_USER"),
920+ getenv("MYSQL_PASSWORD"),
921+ getenv("MYSQL_SCHEMA"), 0);
922 ASSERT_NOT_NULL_(con, "Drizzle connection object creation error");
923
924 drizzle_return_t ret= drizzle_connect(con);
925
926=== modified file 'tests/unit/insert_id.c'
927--- tests/unit/insert_id.c 2013-01-12 13:40:18 +0000
928+++ tests/unit/insert_id.c 2013-01-27 10:01:22 +0000
929@@ -48,11 +48,11 @@
930 (void) argc;
931 (void) argv;
932
933- drizzle_st *con= drizzle_create_tcp(getenv("MYSQL_SERVER"),
934- getenv("MYSQL_PORT") ? atoi("MYSQL_PORT") : DRIZZLE_DEFAULT_TCP_PORT,
935- getenv("MYSQL_USER"),
936- getenv("MYSQL_PASSWORD"),
937- getenv("MYSQL_SCHEMA"), 0);
938+ drizzle_st *con= drizzle_create(getenv("MYSQL_SERVER"),
939+ getenv("MYSQL_PORT") ? atoi("MYSQL_PORT") : DRIZZLE_DEFAULT_TCP_PORT,
940+ getenv("MYSQL_USER"),
941+ getenv("MYSQL_PASSWORD"),
942+ getenv("MYSQL_SCHEMA"), 0);
943 ASSERT_NOT_NULL_(con, "Drizzle connection object creation error");
944
945 drizzle_return_t ret= drizzle_connect(con);
946
947=== modified file 'tests/unit/query.c'
948--- tests/unit/query.c 2013-01-12 13:40:18 +0000
949+++ tests/unit/query.c 2013-01-27 10:01:22 +0000
950@@ -49,11 +49,11 @@
951 drizzle_row_t row;
952 int num_fields;
953
954- drizzle_st *con= drizzle_create_tcp(getenv("MYSQL_SERVER"),
955- getenv("MYSQL_PORT") ? atoi("MYSQL_PORT") : DRIZZLE_DEFAULT_TCP_PORT,
956- getenv("MYSQL_USER"),
957- getenv("MYSQL_PASSWORD"),
958- getenv("MYSQL_SCHEMA"), 0);
959+ drizzle_st *con= drizzle_create(getenv("MYSQL_SERVER"),
960+ getenv("MYSQL_PORT") ? atoi("MYSQL_PORT") : DRIZZLE_DEFAULT_TCP_PORT,
961+ getenv("MYSQL_USER"),
962+ getenv("MYSQL_PASSWORD"),
963+ getenv("MYSQL_SCHEMA"), 0);
964 ASSERT_NOT_NULL_(con, "Drizzle connection object creation error");
965
966 drizzle_return_t ret= drizzle_connect(con);
967
968=== modified file 'tests/unit/row.c'
969--- tests/unit/row.c 2013-01-12 13:40:18 +0000
970+++ tests/unit/row.c 2013-01-27 10:01:22 +0000
971@@ -49,11 +49,11 @@
972 drizzle_row_t row;
973 int num_fields;
974
975- drizzle_st *con= drizzle_create_tcp(getenv("MYSQL_SERVER"),
976- getenv("MYSQL_PORT") ? atoi("MYSQL_PORT") : DRIZZLE_DEFAULT_TCP_PORT,
977- getenv("MYSQL_USER"),
978- getenv("MYSQL_PASSWORD"),
979- getenv("MYSQL_SCHEMA"), 0);
980+ drizzle_st *con= drizzle_create(getenv("MYSQL_SERVER"),
981+ getenv("MYSQL_PORT") ? atoi("MYSQL_PORT") : DRIZZLE_DEFAULT_TCP_PORT,
982+ getenv("MYSQL_USER"),
983+ getenv("MYSQL_PASSWORD"),
984+ getenv("MYSQL_SCHEMA"), 0);
985 ASSERT_NOT_NULL_(con, "Drizzle connection object creation error");
986
987 drizzle_return_t ret= drizzle_connect(con);
988
989=== modified file 'tests/unit/statement.c'
990--- tests/unit/statement.c 2013-01-27 00:42:59 +0000
991+++ tests/unit/statement.c 2013-01-27 10:01:22 +0000
992@@ -53,11 +53,11 @@
993
994 ASSERT_EQ(UINT64_MAX, drizzle_stmt_row_count(stmt));
995
996- drizzle_st *con= drizzle_create_tcp(getenv("MYSQL_SERVER"),
997- getenv("MYSQL_PORT") ? atoi("MYSQL_PORT") : DRIZZLE_DEFAULT_TCP_PORT,
998- getenv("MYSQL_USER"),
999- getenv("MYSQL_PASSWORD"),
1000- getenv("MYSQL_SCHEMA"), 0);
1001+ drizzle_st *con= drizzle_create(getenv("MYSQL_SERVER"),
1002+ getenv("MYSQL_PORT") ? atoi("MYSQL_PORT") : DRIZZLE_DEFAULT_TCP_PORT,
1003+ getenv("MYSQL_USER"),
1004+ getenv("MYSQL_PASSWORD"),
1005+ getenv("MYSQL_SCHEMA"), 0);
1006 ASSERT_NOT_NULL_(con, "Drizzle connection object creation error");
1007
1008 drizzle_return_t ret= drizzle_connect(con);
1009
1010=== modified file 'tests/unit/statement_char.c'
1011--- tests/unit/statement_char.c 2013-01-27 01:57:09 +0000
1012+++ tests/unit/statement_char.c 2013-01-27 10:01:22 +0000
1013@@ -51,11 +51,11 @@
1014 (void) argv;
1015 drizzle_stmt_st *stmt;
1016
1017- drizzle_st *con= drizzle_create_tcp(getenv("MYSQL_SERVER"),
1018- getenv("MYSQL_PORT") ? atoi("MYSQL_PORT") : DRIZZLE_DEFAULT_TCP_PORT,
1019- getenv("MYSQL_USER"),
1020- getenv("MYSQL_PASSWORD"),
1021- getenv("MYSQL_SCHEMA"), 0);
1022+ drizzle_st *con= drizzle_create(getenv("MYSQL_SERVER"),
1023+ getenv("MYSQL_PORT") ? atoi("MYSQL_PORT") : DRIZZLE_DEFAULT_TCP_PORT,
1024+ getenv("MYSQL_USER"),
1025+ getenv("MYSQL_PASSWORD"),
1026+ getenv("MYSQL_SCHEMA"), 0);
1027
1028 ASSERT_NOT_NULL_(con, "Drizzle connection object creation error");
1029
1030
1031=== modified file 'tests/unit/unbuffered_query.c'
1032--- tests/unit/unbuffered_query.c 2013-01-12 13:40:18 +0000
1033+++ tests/unit/unbuffered_query.c 2013-01-27 10:01:22 +0000
1034@@ -49,11 +49,11 @@
1035 drizzle_row_t row;
1036 int num_fields;
1037
1038- drizzle_st *con= drizzle_create_tcp(getenv("MYSQL_SERVER"),
1039- getenv("MYSQL_PORT") ? atoi("MYSQL_PORT") : DRIZZLE_DEFAULT_TCP_PORT,
1040- getenv("MYSQL_USER"),
1041- getenv("MYSQL_PASSWORD"),
1042- getenv("MYSQL_SCHEMA"), 0);
1043+ drizzle_st *con= drizzle_create(getenv("MYSQL_SERVER"),
1044+ getenv("MYSQL_PORT") ? atoi("MYSQL_PORT") : DRIZZLE_DEFAULT_TCP_PORT,
1045+ getenv("MYSQL_USER"),
1046+ getenv("MYSQL_PASSWORD"),
1047+ getenv("MYSQL_SCHEMA"), 0);
1048 ASSERT_NOT_NULL_(con, "Drizzle connection object creation error");
1049
1050 drizzle_return_t ret= drizzle_connect(con);

Subscribers

People subscribed via source and target branches

to all changes:
to status/vote changes: