Merge lp:~brianaker/drizzle/bug743783 into lp:~drizzle-trunk/drizzle/development

Proposed by Brian Aker
Status: Merged
Approved by: Brian Aker
Approved revision: 2366
Merged at revision: 2366
Proposed branch: lp:~brianaker/drizzle/bug743783
Merge into: lp:~drizzle-trunk/drizzle/development
Diff against target: 507 lines (+193/-104)
11 files modified
docs/create_schema.rst (+13/-3)
docs/create_table.rst (+10/-0)
drizzled/drizzled.cc (+1/-1)
drizzled/temporal_format.cc (+5/-0)
drizzled/temporal_format.h (+3/-0)
m4/pandora_have_libcurl.m4 (+8/-4)
plugin/json_server/json_server.cc (+126/-29)
plugin/json_server/plugin.ini (+17/-3)
plugin/show_dictionary/show_columns.cc (+1/-53)
plugin/show_dictionary/show_columns.h (+0/-2)
plugin/show_dictionary/tests/r/show_columns.result (+9/-9)
To merge this branch: bzr merge lp:~brianaker/drizzle/bug743783
Reviewer Review Type Date Requested Status
Drizzle Merge Team Pending
Review via email: mp+67790@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 'docs/create_schema.rst'
2--- docs/create_schema.rst 2011-03-30 03:12:02 +0000
3+++ docs/create_schema.rst 2011-07-13 05:38:41 +0000
4@@ -11,14 +11,14 @@
5 engine_options
6 --------------
7
8-You can specify the storage engine to use for creating the schema.
9+You can specify the storage engine to use for creating the schema. Please note, there is currently only one engine.
10
11 ::
12
13 engine_option [[,] engine_option] ...
14
15-engine_option
16--------------
17+collate
18+-------
19
20 There are default settings for character sets and collations at four levels: server, database, table, and column. The COLLATE clause specifies the default database collation.
21
22@@ -26,3 +26,13 @@
23
24 [DEFAULT] COLLATE = collation_name
25 { engine_specific }
26+
27+
28+REPLICATE
29+---------
30+
31+Specify whether or not a SCHEMA should be replicated.
32+
33+::
34+
35+ REPLICATE=[TRUE|FALSE]
36
37=== modified file 'docs/create_table.rst'
38--- docs/create_table.rst 2011-03-08 03:47:42 +0000
39+++ docs/create_table.rst 2011-07-13 05:38:41 +0000
40@@ -9,6 +9,7 @@
41 CREATE [TEMPORARY] TABLE [IF NOT EXISTS] table_name
42 (create_definition, ...)
43 [engine_options]
44+ REPLICATE=[TRUE|FALSE]
45
46 or:
47
48@@ -18,6 +19,7 @@
49 [(create_definition, ...)]
50 [engine_options]
51 select_statement
52+ REPLICATE=[TRUE|FALSE]
53
54 or:
55
56@@ -26,6 +28,7 @@
57 CREATE [TEMPORARY] TABLE [IF NOT EXISTS] table_name
58 LIKE different_table_name
59 [engine_options]
60+ REPLICATE=[TRUE|FALSE]
61
62 create_definition
63 -----------------
64@@ -84,3 +87,10 @@
65
66 ENGINE = engine_name
67 { engine_specific }
68+
69+REPLICATE
70+---------
71+
72+Specify whether or not a TABLE should be replicated.
73+
74+ REPLICATE=[TRUE|FALSE]
75
76=== modified file 'drizzled/drizzled.cc'
77--- drizzled/drizzled.cc 2011-06-24 15:25:06 +0000
78+++ drizzled/drizzled.cc 2011-07-13 05:38:41 +0000
79@@ -1422,7 +1422,7 @@
80 if (sys_var_init())
81 return 1;
82 /* Creates static regex matching for temporal values */
83- if (! init_temporal_formats())
84+ if (not init_temporal_formats())
85 return 1;
86
87 if (!(default_charset_info=
88
89=== modified file 'drizzled/temporal_format.cc'
90--- drizzled/temporal_format.cc 2011-06-23 11:06:21 +0000
91+++ drizzled/temporal_format.cc 2011-07-13 05:38:41 +0000
92@@ -66,6 +66,11 @@
93 );
94 }
95
96+TemporalFormat::~TemporalFormat()
97+{
98+ pcre_free(_re);
99+}
100+
101 bool TemporalFormat::matches(const char *data, size_t data_len, Temporal *to)
102 {
103 if (! is_valid())
104
105=== modified file 'drizzled/temporal_format.h'
106--- drizzled/temporal_format.h 2011-03-29 12:45:08 +0000
107+++ drizzled/temporal_format.h 2011-07-13 05:38:41 +0000
108@@ -63,6 +63,9 @@
109 * @param Pattern to use in matching
110 */
111 TemporalFormat(const char *pattern);
112+
113+ ~TemporalFormat();
114+
115 /**
116 * Returns whether the instance is compiled
117 * and contains a valid regular expression.
118
119=== modified file 'm4/pandora_have_libcurl.m4'
120--- m4/pandora_have_libcurl.m4 2011-03-07 16:42:18 +0000
121+++ m4/pandora_have_libcurl.m4 2011-07-13 05:38:41 +0000
122@@ -32,10 +32,14 @@
123 AC_COMPILE_IFELSE([
124 AC_LANG_PROGRAM(
125 [[
126- CURL *handle;
127- handle=curl_easy_init();
128- rv= curl_easy_setopt(curl_handle, CURLOPT_USERNAME, "foo");
129- ]])],
130+ #include <curl/curl.h>
131+ ]],
132+ [[
133+ CURL *curl_handle=curl_easy_init();
134+ CURLcode rv= curl_easy_setopt(curl_handle, CURLOPT_USERNAME, "foo");
135+ (void)rv;
136+ ]])
137+ ],
138 [pandora_cv_curl_have_username=yes],
139 [pandora_cv_curl_have_username=no])
140 ])
141
142=== modified file 'plugin/json_server/json_server.cc'
143--- plugin/json_server/json_server.cc 2011-04-21 07:15:35 +0000
144+++ plugin/json_server/json_server.cc 2011-07-13 05:38:41 +0000
145@@ -20,10 +20,15 @@
146
147
148 #include <config.h>
149+
150+#include <unistd.h>
151+#include <fcntl.h>
152+
153 #include <drizzled/module/module.h>
154 #include <drizzled/module/context.h>
155 #include <drizzled/plugin/plugin.h>
156 #include <drizzled/plugin.h>
157+#include <drizzled/plugin/daemon.h>
158 #include <drizzled/sys_var.h>
159 #include <drizzled/gettext.h>
160 #include <drizzled/error.h>
161@@ -38,7 +43,6 @@
162 #include <drizzled/constrained_value.h>
163 #include <evhttp.h>
164 #include <event.h>
165-#include <pthread.h>
166 #include <drizzled/execute.h>
167 #include <drizzled/sql/result_set.h>
168
169@@ -46,6 +50,10 @@
170 #include <drizzled/plugin/client.h>
171 #include <drizzled/catalog/local.h>
172
173+#include <drizzled/pthread_globals.h>
174+#include <boost/bind.hpp>
175+
176+
177 #include <drizzled/version.h>
178 #include <plugin/json_server/json/json.h>
179
180@@ -59,8 +67,6 @@
181 {
182
183 static port_constraint port;
184-struct event_base *base= NULL;
185-struct evhttp *httpd;
186
187 static in_port_t getPort(void)
188 {
189@@ -222,48 +228,139 @@
190 evhttp_send_reply(req, HTTP_OK, "OK", buf);
191 }
192
193-extern "C" void *libevent_thread(void*);
194-
195-extern "C" void *libevent_thread(void*)
196+static void shutdown_event(int fd, short, void *arg)
197+{
198+ struct event_base *base= (struct event_base *)arg;
199+ event_base_loopbreak(base);
200+ close(fd);
201+}
202+
203+
204+static void run(struct event_base *base)
205 {
206 internal::my_thread_init();
207
208 event_base_dispatch(base);
209- evhttp_free(httpd);
210- return NULL;
211 }
212
213+
214+class JsonServer : public drizzled::plugin::Daemon
215+{
216+private:
217+ JsonServer(const JsonServer &);
218+ JsonServer& operator=(const JsonServer &);
219+
220+ drizzled::thread_ptr json_thread;
221+ in_port_t _port;
222+ struct evhttp *httpd;
223+ struct event_base *base;
224+ int wakeup_fd[2];
225+ struct event wakeup_event;
226+
227+public:
228+ JsonServer(in_port_t port_arg) :
229+ drizzled::plugin::Daemon("JSON Server"),
230+ _port(port_arg),
231+ httpd(NULL),
232+ base(NULL)
233+ { }
234+
235+ bool init()
236+ {
237+ if (pipe(wakeup_fd) < 0)
238+ {
239+ sql_perror("pipe");
240+ return false;
241+ }
242+
243+ int returned_flags;
244+ if ((returned_flags= fcntl(wakeup_fd[0], F_GETFL, 0)) < 0)
245+ {
246+ sql_perror("fcntl:F_GETFL");
247+ return false;
248+ }
249+
250+ if (fcntl(wakeup_fd[0], F_SETFL, returned_flags | O_NONBLOCK) < 0)
251+
252+ {
253+ sql_perror("F_SETFL");
254+ return false;
255+ }
256+
257+ if ((base= event_init()) == NULL)
258+ {
259+ sql_perror("event_init()");
260+ return false;
261+ }
262+
263+ if ((httpd= evhttp_new(base)) == NULL)
264+ {
265+ sql_perror("evhttp_new()");
266+ return false;
267+ }
268+
269+
270+ if ((evhttp_bind_socket(httpd, "0.0.0.0", getPort())) == -1)
271+ {
272+ sql_perror("evhttp_bind_socket()");
273+ return false;
274+ }
275+
276+ evhttp_set_cb(httpd, "/", process_root_request, NULL);
277+ evhttp_set_cb(httpd, "/0.1/version", process_api01_version_req, NULL);
278+ evhttp_set_cb(httpd, "/0.1/sql", process_api01_sql_req, NULL);
279+ evhttp_set_gencb(httpd, process_request, NULL);
280+
281+ event_set(&wakeup_event, wakeup_fd[0], EV_READ | EV_PERSIST, shutdown_event, base);
282+ event_base_set(base, &wakeup_event);
283+ if (event_add(&wakeup_event, NULL) < 0)
284+ {
285+ sql_perror("event_add");
286+ return false;
287+ }
288+
289+ json_thread.reset(new boost::thread((boost::bind(&run, base))));
290+
291+ if (not json_thread)
292+ return false;
293+
294+ return true;
295+ }
296+
297+ ~JsonServer()
298+ {
299+ // If we can't write(), we will just muddle our way through the shutdown
300+ char buffer[1];
301+ buffer[0]= 4;
302+ if ((write(wakeup_fd[1], &buffer, 1)) == 1)
303+ {
304+ json_thread->join();
305+ evhttp_free(httpd);
306+ event_base_free(base);
307+ }
308+ }
309+};
310+
311 static int json_server_init(drizzled::module::Context &context)
312 {
313 context.registerVariable(new sys_var_constrained_value_readonly<in_port_t>("port", port));
314
315- base= event_init();
316- httpd= evhttp_new(base);
317- if (httpd == NULL)
318- return -1;
319-
320- int r= evhttp_bind_socket(httpd, "0.0.0.0", getPort());
321-
322- if (r != 0)
323+ JsonServer *server;
324+ context.add(server= new JsonServer(port));
325+
326+ if (server and not server->init())
327+ {
328 return -2;
329-
330- evhttp_set_cb(httpd, "/", process_root_request, NULL);
331- evhttp_set_cb(httpd, "/0.1/version", process_api01_version_req, NULL);
332- evhttp_set_cb(httpd, "/0.1/sql", process_api01_sql_req, NULL);
333- evhttp_set_gencb(httpd, process_request, NULL);
334-
335- pthread_t libevent_loop_thread;
336-
337- pthread_create(&libevent_loop_thread, NULL, libevent_thread, NULL);
338-
339- return 0;
340+ }
341+
342+ return bool(server) ? 0 : 1;
343 }
344
345 static void init_options(drizzled::module::option_context &context)
346 {
347 context("port",
348- po::value<port_constraint>(&port)->default_value(80),
349- _("Port number to use for connection or 0 for default (port 80) "));
350+ po::value<port_constraint>(&port)->default_value(8086),
351+ _("Port number to use for connection or 0 for default (port 8086) "));
352 }
353
354 } /* namespace json_server */
355
356=== modified file 'plugin/json_server/plugin.ini'
357--- plugin/json_server/plugin.ini 2011-05-02 07:45:56 +0000
358+++ plugin/json_server/plugin.ini 2011-07-13 05:38:41 +0000
359@@ -4,9 +4,23 @@
360 version=0.1
361 author=Stewart Smith
362 license=PLUGIN_LICENSE_GPL
363-headers= json/autolink.h json/config.h json/features.h json/forwards.h json/json_batchallocator.h json/json.h json/reader.h json/value.h json/writer.h json/json_internalarray.inl json/json_internalmap.inl json/json_valueiterator.inl
364+headers=
365+ json/autolink.h
366+ json/config.h
367+ json/features.h
368+ json/forwards.h
369+ json/json_batchallocator.h
370+ json/json.h
371+ json/reader.h
372+ json/value.h
373+ json/writer.h
374+ json/json_internalarray.inl
375+ json/json_internalmap.inl
376+ json/json_valueiterator.inl
377 sources=
378- json_server.cc json/json_reader.cpp json/json_value.cpp json/json_writer.cpp
379+ json_server.cc
380+ json/json_reader.cpp
381+ json/json_value.cpp
382+ json/json_writer.cpp
383 build_conditional="x${ac_cv_libevent}" = "xyes" -a "x${ac_cv_libcurl}" = "xyes"
384 ldflags=${LTLIBEVENT}
385-
386
387=== modified file 'plugin/show_dictionary/show_columns.cc'
388--- plugin/show_dictionary/show_columns.cc 2011-06-30 12:03:14 +0000
389+++ plugin/show_dictionary/show_columns.cc 2011-07-13 05:38:41 +0000
390@@ -26,20 +26,6 @@
391 using namespace std;
392 using namespace drizzled;
393
394-static const string VARCHAR("VARCHAR");
395-/* VARBINARY already defined elsewhere */
396-static const string VARBIN("VARBINARY");
397-static const string DOUBLE("DOUBLE");
398-static const string BLOB("BLOB");
399-static const string TEXT("TEXT");
400-static const string ENUM("ENUM");
401-static const string INTEGER("INTEGER");
402-static const string BIGINT("BIGINT");
403-static const string DECIMAL("DECIMAL");
404-static const string DATE("DATE");
405-static const string TIMESTAMP("TIMESTAMP");
406-static const string DATETIME("DATETIME");
407-
408 ShowColumns::ShowColumns() :
409 show_dictionary::Show("SHOW_COLUMNS")
410 {
411@@ -126,44 +112,6 @@
412 return true;
413 }
414
415-void ShowColumns::Generator::pushType(message::Table::Field::FieldType type, const string &collation)
416-{
417- switch (type)
418- {
419- default:
420- case message::Table::Field::VARCHAR:
421- push(collation.compare("binary") ? VARCHAR : VARBIN);
422- break;
423- case message::Table::Field::DOUBLE:
424- push(DOUBLE);
425- break;
426- case message::Table::Field::BLOB:
427- push(collation.compare("binary") ? TEXT : BLOB);
428- break;
429- case message::Table::Field::ENUM:
430- push(ENUM);
431- break;
432- case message::Table::Field::INTEGER:
433- push(INTEGER);
434- break;
435- case message::Table::Field::BIGINT:
436- push(BIGINT);
437- break;
438- case message::Table::Field::DECIMAL:
439- push(DECIMAL);
440- break;
441- case message::Table::Field::DATE:
442- push(DATE);
443- break;
444- case message::Table::Field::EPOCH:
445- push(TIMESTAMP);
446- break;
447- case message::Table::Field::DATETIME:
448- push(DATETIME);
449- break;
450- }
451-}
452-
453
454 void ShowColumns::Generator::fill()
455 {
456@@ -171,7 +119,7 @@
457 push(column.name());
458
459 /* Type */
460- pushType(column.type(), column.string_options().collation());
461+ push(drizzled::message::type(column));
462
463 /* Null */
464 push(not column.constraints().is_notnull());
465
466=== modified file 'plugin/show_dictionary/show_columns.h'
467--- plugin/show_dictionary/show_columns.h 2011-06-30 12:03:14 +0000
468+++ plugin/show_dictionary/show_columns.h 2011-07-13 05:38:41 +0000
469@@ -56,8 +56,6 @@
470 return table_name;
471 }
472
473- void pushType(drizzled::message::Table::Field::FieldType type, const std::string &collation);
474-
475 void fill();
476
477 public:
478
479=== modified file 'plugin/show_dictionary/tests/r/show_columns.result'
480--- plugin/show_dictionary/tests/r/show_columns.result 2011-01-06 21:14:45 +0000
481+++ plugin/show_dictionary/tests/r/show_columns.result 2011-07-13 05:38:41 +0000
482@@ -6,16 +6,16 @@
483 COLUMN_TYPE VARCHAR NO NO
484 ORDINAL_POSITION BIGINT NO NO
485 COLUMN_DEFAULT VARBINARY YES YES
486-COLUMN_DEFAULT_IS_NULL VARCHAR NO NO
487+COLUMN_DEFAULT_IS_NULL BOOLEAN NO NO
488 COLUMN_DEFAULT_UPDATE VARCHAR NO NO
489-IS_SIGNED VARCHAR YES YES
490-IS_AUTO_INCREMENT VARCHAR NO NO
491-IS_NULLABLE VARCHAR NO NO
492-IS_INDEXED VARCHAR NO NO
493-IS_USED_IN_PRIMARY VARCHAR NO NO
494-IS_UNIQUE VARCHAR NO NO
495-IS_MULTI VARCHAR NO NO
496-IS_FIRST_IN_MULTI VARCHAR NO NO
497+IS_SIGNED BOOLEAN YES YES
498+IS_AUTO_INCREMENT BOOLEAN NO NO
499+IS_NULLABLE BOOLEAN NO NO
500+IS_INDEXED BOOLEAN NO NO
501+IS_USED_IN_PRIMARY BOOLEAN NO NO
502+IS_UNIQUE BOOLEAN NO NO
503+IS_MULTI BOOLEAN NO NO
504+IS_FIRST_IN_MULTI BOOLEAN NO NO
505 INDEXES_FOUND_IN BIGINT NO NO
506 DATA_TYPE VARCHAR NO NO
507 DATA_ARCHETYPE VARCHAR NO NO