77.3.7
by Monty Taylor
Made mysql into a pure-C program. |
1 |
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
|
77.3.1
by Monty Taylor
First steps in removing sql_string and using glib instead. |
2 |
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
|
3 |
*
|
|
1719.2.3
by Vijay Samuel
Merge removed the drizzled/option.h include from client_priv.h and archive_reader. |
4 |
* Copyright (C) 2010 Vijay Samuel
|
77.3.1
by Monty Taylor
First steps in removing sql_string and using glib instead. |
5 |
* Copyright (C) 2008 MySQL
|
6 |
*
|
|
7 |
* This program is free software; you can redistribute it and/or modify
|
|
8 |
* it under the terms of the GNU General Public License as published by
|
|
9 |
* the Free Software Foundation; either version 2 of the License, or
|
|
10 |
* (at your option) any later version.
|
|
11 |
*
|
|
12 |
* This program is distributed in the hope that it will be useful,
|
|
1675.1.3
by Monty Taylor
Merged in local client config lookup paths from vijay. Thanks. |
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
77.3.1
by Monty Taylor
First steps in removing sql_string and using glib instead. |
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
* GNU General Public License for more details.
|
|
16 |
*
|
|
17 |
* You should have received a copy of the GNU General Public License
|
|
18 |
* along with this program; if not, write to the Free Software
|
|
19 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
20 |
*/
|
|
1
by brian
clean slate |
21 |
|
206.3.1
by Patrick Galbraith
Most everything working with client rename |
22 |
/* drizzle command tool
|
1
by brian
clean slate |
23 |
* Commands compatible with mSQL by David J. Hughes
|
24 |
*
|
|
25 |
* Written by:
|
|
26 |
* Michael 'Monty' Widenius
|
|
27 |
* Andi Gutmans <andi@zend.com>
|
|
28 |
* Zeev Suraski <zeev@zend.com>
|
|
202.1.25
by Monty Taylor
Fixed change of mysql.com -> drizzle.com. |
29 |
* Jani Tolonen <jani@mysql.com>
|
30 |
* Matt Wagner <matt@mysql.com>
|
|
31 |
* Jeremy Cole <jcole@mysql.com>
|
|
32 |
* Tonu Samuel <tonu@mysql.com>
|
|
33 |
* Harrison Fisk <harrison@mysql.com>
|
|
1
by brian
clean slate |
34 |
*
|
35 |
**/
|
|
36 |
||
2173.2.1
by Monty Taylor
Fixes incorrect usage of include |
37 |
#include <config.h> |
2226.1.6
by Monty Taylor
Moved drizzle/drizzle.h to libdrizzle/libdrizzle.h - we don't have a drizzle |
38 |
#include <libdrizzle/libdrizzle.h> |
1567.3.15
by Monty Taylor
Removed the last vestiges of my_sys from drizzle.cc. |
39 |
|
2187.3.2
by Andrew Hutchings
Separate the server detection functions into a .h file |
40 |
#include "server_detect.h" |
2187.3.7
by Monty Taylor
Fixed two tiny things. |
41 |
#include "get_password.h" |
1567.3.15
by Monty Taylor
Removed the last vestiges of my_sys from drizzle.cc. |
42 |
|
2173.2.1
by Monty Taylor
Fixes incorrect usage of include |
43 |
#include <boost/date_time/posix_time/posix_time.hpp> |
1567.3.15
by Monty Taylor
Removed the last vestiges of my_sys from drizzle.cc. |
44 |
|
1567.3.22
by Monty Taylor
Include cerrno for ENOMEM on FreeBSD. |
45 |
#include <cerrno> |
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
46 |
#include <string> |
1241.9.1
by Monty Taylor
Removed global.h. Fixed all the headers. |
47 |
#include <drizzled/gettext.h> |
48 |
#include <iostream> |
|
1567.3.8
by Vijay Samuel
Refactor drizzle client. |
49 |
#include <fstream> |
1241.9.1
by Monty Taylor
Removed global.h. Fixed all the headers. |
50 |
#include <map> |
713.1.4
by Monty Taylor
Fixed max() problem for solaris |
51 |
#include <algorithm> |
1241.9.1
by Monty Taylor
Removed global.h. Fixed all the headers. |
52 |
#include <limits.h> |
53 |
#include <cassert> |
|
1
by brian
clean slate |
54 |
#include <stdarg.h> |
1241.9.1
by Monty Taylor
Removed global.h. Fixed all the headers. |
55 |
#include <math.h> |
1929.1.13
by Stewart Smith
fix large stack usage in handle_sigint in drizzle client |
56 |
#include <memory> |
2173.2.1
by Monty Taylor
Fixes incorrect usage of include |
57 |
#include <client/linebuffer.h> |
1
by brian
clean slate |
58 |
#include <signal.h> |
212.5.30
by Monty Taylor
Removed my_net.h. Pointless. |
59 |
#include <sys/ioctl.h> |
722.1.4
by Monty Taylor
Removed all the setting of DEFS everywhere. Use configmake.h to get the values |
60 |
#include <drizzled/configmake.h> |
2173.2.1
by Monty Taylor
Fixes incorrect usage of include |
61 |
#include <drizzled/utf8/utf8.h> |
1671.2.1
by Vijay Samuel
Merge new user config file processing system. |
62 |
#include <cstdlib> |
212.5.30
by Monty Taylor
Removed my_net.h. Pointless. |
63 |
|
1
by brian
clean slate |
64 |
#if defined(HAVE_CURSES_H) && defined(HAVE_TERM_H)
|
65 |
#include <curses.h> |
|
139.1.15
by Trond Norbye
curses.h defines clear and erase as macros causing problems calling the std::string members |
66 |
#ifdef __sun
|
67 |
#undef clear
|
|
68 |
#undef erase
|
|
69 |
#endif
|
|
1
by brian
clean slate |
70 |
#include <term.h> |
71 |
#else
|
|
72 |
#if defined(HAVE_TERMIOS_H)
|
|
73 |
#include <termios.h> |
|
74 |
#include <unistd.h> |
|
75 |
#elif defined(HAVE_TERMBITS_H)
|
|
76 |
#include <termbits.h> |
|
77 |
#elif defined(HAVE_ASM_TERMBITS_H) && (!defined __GLIBC__ || !(__GLIBC__ > 2 || __GLIBC__ == 2 && __GLIBC_MINOR__ > 0))
|
|
206.3.1
by Patrick Galbraith
Most everything working with client rename |
78 |
#include <asm/termbits.h> // Standard linux |
1
by brian
clean slate |
79 |
#endif
|
80 |
#if defined(HAVE_TERMCAP_H)
|
|
81 |
#include <termcap.h> |
|
82 |
#else
|
|
83 |
#ifdef HAVE_CURSES_H
|
|
84 |
#include <curses.h> |
|
85 |
#endif
|
|
206.3.1
by Patrick Galbraith
Most everything working with client rename |
86 |
#undef SYSV // hack to avoid syntax error |
1
by brian
clean slate |
87 |
#ifdef HAVE_TERM_H
|
88 |
#include <term.h> |
|
89 |
#endif
|
|
90 |
#endif
|
|
91 |
#endif
|
|
92 |
||
779.2.4
by Monty Taylor
Updated some more build stuff. |
93 |
#ifdef HAVE_LIBREADLINE
|
94 |
# if defined(HAVE_READLINE_READLINE_H)
|
|
95 |
# include <readline/readline.h>
|
|
96 |
# elif defined(HAVE_READLINE_H)
|
|
97 |
# include <readline.h>
|
|
98 |
# else /* !defined(HAVE_READLINE_H) */ |
|
99 |
extern char *readline (); |
|
100 |
# endif /* !defined(HAVE_READLINE_H) */ |
|
101 |
char *cmdline = NULL; |
|
102 |
#else /* !defined(HAVE_READLINE_READLINE_H) */ |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
103 |
/* no readline */
|
779.2.4
by Monty Taylor
Updated some more build stuff. |
104 |
# error Readline Required
|
105 |
#endif /* HAVE_LIBREADLINE */ |
|
106 |
||
107 |
#ifdef HAVE_READLINE_HISTORY
|
|
108 |
# if defined(HAVE_READLINE_HISTORY_H)
|
|
109 |
# include <readline/history.h>
|
|
110 |
# elif defined(HAVE_HISTORY_H)
|
|
111 |
# include <history.h>
|
|
112 |
# else /* !defined(HAVE_HISTORY_H) */ |
|
113 |
extern void add_history (); |
|
114 |
extern int write_history (); |
|
115 |
extern int read_history (); |
|
116 |
# endif /* defined(HAVE_READLINE_HISTORY_H) */ |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
117 |
/* no history */
|
779.2.4
by Monty Taylor
Updated some more build stuff. |
118 |
#endif /* HAVE_READLINE_HISTORY */ |
119 |
||
779.2.14
by Monty Taylor
Fixed a coupla oopses on the Mac. |
120 |
/**
|
1441.3.1
by Vijay Samuel
all required updations have been made |
121 |
Make the old readline interface look like the new one.
|
779.2.14
by Monty Taylor
Fixed a coupla oopses on the Mac. |
122 |
*/
|
1149.2.1
by Monty Taylor
Workaround for half-present new-interface on Snow Leopard, combined |
123 |
#ifndef HAVE_RL_COMPLETION
|
124 |
typedef char **rl_completion_func_t(const char *, int, int); |
|
779.2.14
by Monty Taylor
Fixed a coupla oopses on the Mac. |
125 |
#define rl_completion_matches(str, func) \
|
126 |
completion_matches((char *)str, (CPFunction *)func)
|
|
127 |
#endif
|
|
779.2.4
by Monty Taylor
Updated some more build stuff. |
128 |
|
1149.2.1
by Monty Taylor
Workaround for half-present new-interface on Snow Leopard, combined |
129 |
#ifdef HAVE_RL_COMPENTRY
|
130 |
# ifdef HAVE_WORKING_RL_COMPENTRY
|
|
131 |
typedef rl_compentry_func_t drizzle_compentry_func_t; |
|
132 |
# else
|
|
133 |
/* Snow Leopard ships an rl_compentry which cannot be assigned to
|
|
134 |
* rl_completion_entry_function. We must undo the complete and total
|
|
135 |
* ass-bagery.
|
|
136 |
*/
|
|
137 |
typedef Function drizzle_compentry_func_t; |
|
138 |
# endif
|
|
139 |
#else
|
|
1149.2.2
by Monty Taylor
Fixed bad assumption about non-Snow Leopard. |
140 |
typedef Function drizzle_compentry_func_t; |
1149.2.1
by Monty Taylor
Workaround for half-present new-interface on Snow Leopard, combined |
141 |
#endif
|
142 |
||
779.2.4
by Monty Taylor
Updated some more build stuff. |
143 |
#if defined(HAVE_LOCALE_H)
|
144 |
#include <locale.h> |
|
145 |
#endif
|
|
146 |
||
147 |
||
148 |
||
1
by brian
clean slate |
149 |
#if !defined(HAVE_VIDATTR)
|
150 |
#undef vidattr
|
|
206.3.1
by Patrick Galbraith
Most everything working with client rename |
151 |
#define vidattr(A) {} // Can't get this to work |
1
by brian
clean slate |
152 |
#endif
|
1567.3.5
by Vijay Samuel
Refactored client. |
153 |
#include <boost/program_options.hpp> |
1929.1.40
by Monty Taylor
Replaced auto_ptr with scoped_ptr. |
154 |
#include <boost/scoped_ptr.hpp> |
2173.2.1
by Monty Taylor
Fixes incorrect usage of include |
155 |
#include <drizzled/program_options/config_file.h> |
1
by brian
clean slate |
156 |
|
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
157 |
using namespace std; |
1567.3.5
by Vijay Samuel
Refactored client. |
158 |
namespace po=boost::program_options; |
1815.1.1
by Monty Taylor
Embed a modified version of parse_config_file. There are several more bugs |
159 |
namespace dpo=drizzled::program_options; |
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
160 |
|
919.2.11
by Monty Taylor
Removed C99 isnan() usage, which allows us to remove the util/math.{cc,h} workarounds. Yay for standards! |
161 |
/* Don't try to make a nice table if the data is too big */
|
162 |
const uint32_t MAX_COLUMN_LENGTH= 1024; |
|
163 |
||
164 |
/* Buffer to hold 'version' and 'version_comment' */
|
|
165 |
const int MAX_SERVER_VERSION_LENGTH= 128; |
|
166 |
||
2203.2.2
by Brian Aker
First pass through in going over work for MySQL AUTH PLUGIN style support. |
167 |
/* Options used during connect */
|
168 |
drizzle_con_options_t global_con_options= DRIZZLE_CON_NONE; |
|
169 |
||
1
by brian
clean slate |
170 |
#define PROMPT_CHAR '\\'
|
171 |
||
1441.3.1
by Vijay Samuel
all required updations have been made |
172 |
class Status |
1
by brian
clean slate |
173 |
{
|
1441.3.1
by Vijay Samuel
all required updations have been made |
174 |
public: |
175 |
||
176 |
Status(int in_exit_status, |
|
177 |
uint32_t in_query_start_line, |
|
1891.2.1
by Monty Taylor
Fixed things to make things compile with clang |
178 |
char *in_file_name, |
1441.3.1
by Vijay Samuel
all required updations have been made |
179 |
LineBuffer *in_line_buff, |
1891.2.1
by Monty Taylor
Fixed things to make things compile with clang |
180 |
bool in_batch, |
181 |
bool in_add_to_history) |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
182 |
:
|
183 |
exit_status(in_exit_status), |
|
184 |
query_start_line(in_query_start_line), |
|
185 |
file_name(in_file_name), |
|
186 |
line_buff(in_line_buff), |
|
187 |
batch(in_batch), |
|
188 |
add_to_history(in_add_to_history) |
|
189 |
{}
|
|
190 |
||
1891.2.1
by Monty Taylor
Fixed things to make things compile with clang |
191 |
Status() : |
192 |
exit_status(0), |
|
193 |
query_start_line(0), |
|
194 |
file_name(NULL), |
|
195 |
line_buff(NULL), |
|
196 |
batch(false), |
|
197 |
add_to_history(false) |
|
198 |
{}
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
199 |
|
200 |
int getExitStatus() const |
|
201 |
{
|
|
202 |
return exit_status; |
|
203 |
}
|
|
204 |
||
205 |
uint32_t getQueryStartLine() const |
|
206 |
{
|
|
207 |
return query_start_line; |
|
208 |
}
|
|
209 |
||
210 |
const char *getFileName() const |
|
211 |
{
|
|
212 |
return file_name; |
|
213 |
}
|
|
214 |
||
215 |
LineBuffer *getLineBuff() const |
|
216 |
{
|
|
217 |
return line_buff; |
|
218 |
}
|
|
219 |
||
220 |
bool getBatch() const |
|
221 |
{
|
|
222 |
return batch; |
|
223 |
}
|
|
224 |
||
225 |
bool getAddToHistory() const |
|
226 |
{
|
|
227 |
return add_to_history; |
|
228 |
}
|
|
229 |
||
230 |
void setExitStatus(int in_exit_status) |
|
231 |
{
|
|
232 |
exit_status= in_exit_status; |
|
233 |
}
|
|
234 |
||
235 |
void setQueryStartLine(uint32_t in_query_start_line) |
|
236 |
{
|
|
237 |
query_start_line= in_query_start_line; |
|
238 |
}
|
|
239 |
||
240 |
void setFileName(char *in_file_name) |
|
241 |
{
|
|
242 |
file_name= in_file_name; |
|
243 |
}
|
|
244 |
||
245 |
void setLineBuff(int max_size, FILE *file=NULL) |
|
246 |
{
|
|
2246.3.1
by Olaf van der Spek
Remove std::nothrow from new() |
247 |
line_buff= new LineBuffer(max_size, file); |
1441.3.1
by Vijay Samuel
all required updations have been made |
248 |
}
|
249 |
||
250 |
void setLineBuff(LineBuffer *in_line_buff) |
|
251 |
{
|
|
252 |
line_buff= in_line_buff; |
|
253 |
}
|
|
254 |
||
255 |
void setBatch(bool in_batch) |
|
256 |
{
|
|
257 |
batch= in_batch; |
|
258 |
}
|
|
259 |
||
260 |
void setAddToHistory(bool in_add_to_history) |
|
261 |
{
|
|
262 |
add_to_history= in_add_to_history; |
|
263 |
}
|
|
264 |
||
265 |
private: |
|
1
by brian
clean slate |
266 |
int exit_status; |
77.1.107
by Monty Taylor
Fixed build warnings. |
267 |
uint32_t query_start_line; |
1
by brian
clean slate |
268 |
char *file_name; |
1095.2.1
by Robert Klahn
Replace typedef struct LINE_BUFFER with class LineBuffer, encapsulating current logic |
269 |
LineBuffer *line_buff; |
1
by brian
clean slate |
270 |
bool batch,add_to_history; |
1441.3.1
by Vijay Samuel
all required updations have been made |
271 |
};
|
1
by brian
clean slate |
272 |
|
923.2.6
by Monty Taylor
Removing hand-done completion hash functions. |
273 |
static map<string, string>::iterator completion_iter; |
923.2.7
by Monty Taylor
Finished replacing custom HashMap with std::map. We use a map and not a set |
274 |
static map<string, string>::iterator completion_end; |
923.2.6
by Monty Taylor
Removing hand-done completion hash functions. |
275 |
static map<string, string> completion_map; |
923.2.7
by Monty Taylor
Finished replacing custom HashMap with std::map. We use a map and not a set |
276 |
static string completion_string; |
277 |
||
1
by brian
clean slate |
278 |
|
279 |
enum enum_info_type { INFO_INFO,INFO_ERROR,INFO_RESULT}; |
|
280 |
typedef enum enum_info_type INFO_TYPE; |
|
281 |
||
928.1.1
by Eric Day
Started client changes. |
282 |
static drizzle_st drizzle; /* The library handle */ |
283 |
static drizzle_con_st con; /* The connection */ |
|
673.5.2
by Andrew Hutchings
Code cleanups |
284 |
static bool ignore_errors= false, quick= false, |
1441.3.1
by Vijay Samuel
all required updations have been made |
285 |
connected= false, opt_raw_data= false, unbuffered= false, |
286 |
output_tables= false, opt_rehash= true, skip_updates= false, |
|
287 |
safe_updates= false, one_database= false, |
|
1802.13.2
by Andrew Hutchings
Remove compress option |
288 |
opt_shutdown= false, opt_ping= false, |
1441.3.1
by Vijay Samuel
all required updations have been made |
289 |
vertical= false, line_numbers= true, column_names= true, |
290 |
opt_nopager= true, opt_outfile= false, named_cmds= false, |
|
1627.2.2
by Monty Taylor
Moved password parsing code into get_password.cc. |
291 |
opt_nobeep= false, opt_reconnect= true, |
1567.3.15
by Monty Taylor
Removed the last vestiges of my_sys from drizzle.cc. |
292 |
opt_secure_auth= false, |
1441.3.1
by Vijay Samuel
all required updations have been made |
293 |
default_pager_set= false, opt_sigint_ignore= false, |
294 |
auto_vertical_output= false, |
|
295 |
show_warnings= false, executing_query= false, interrupted_query= false, |
|
1745.2.1
by LinuxJedi
Remove the --mysql option and convert the --protocol option to do something similar. |
296 |
use_drizzle_protocol= false, opt_local_infile; |
2191.1.1
by Brian Aker
Add in KILL protocol support. |
297 |
static uint32_t opt_kill= 0; |
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
298 |
static uint32_t show_progress_size= 0; |
143
by Brian Aker
Bool cleanup. |
299 |
static bool column_types_flag; |
673.5.2
by Andrew Hutchings
Code cleanups |
300 |
static bool preserve_comments= false; |
1567.4.2
by Jay Pipes
Some style fixes and removal of deprecated stuff... |
301 |
static uint32_t opt_max_input_line; |
302 |
static uint32_t opt_drizzle_port= 0; |
|
1923.3.4
by Andrew Hutchings
Revert -v fix |
303 |
static int opt_silent, verbose= 0; |
1
by brian
clean slate |
304 |
static char *histfile; |
305 |
static char *histfile_tmp; |
|
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
306 |
static string *glob_buffer; |
307 |
static string *processed_prompt= NULL; |
|
182.1.2
by Jim Winstead
Various fixes to enable compilation on Mac OS X, and remove the glib dependency. |
308 |
static char *default_prompt= NULL; |
673.5.2
by Andrew Hutchings
Code cleanups |
309 |
static char *full_username= NULL,*part_username= NULL; |
1441.3.1
by Vijay Samuel
all required updations have been made |
310 |
static Status status; |
164
by Brian Aker
Commit cleanup of export types. |
311 |
static uint32_t select_limit; |
77.1.107
by Monty Taylor
Fixed build warnings. |
312 |
static uint32_t max_join_size; |
288
by Brian Aker
ulong cleanp in client apps |
313 |
static uint32_t opt_connect_timeout= 0; |
2187.3.2
by Andrew Hutchings
Separate the server detection functions into a .h file |
314 |
static ServerDetect::server_type server_type= ServerDetect::SERVER_UNKNOWN_FOUND; |
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
315 |
std::string current_db, |
316 |
delimiter_str, |
|
317 |
current_host, |
|
318 |
current_prompt, |
|
319 |
current_user, |
|
1923.3.4
by Andrew Hutchings
Revert -v fix |
320 |
opt_verbose, |
1567.3.5
by Vijay Samuel
Refactored client. |
321 |
current_password, |
1745.2.1
by LinuxJedi
Remove the --mysql option and convert the --protocol option to do something similar. |
322 |
opt_password, |
323 |
opt_protocol; |
|
2155.4.1
by Stewart Smith
make day names and month names in drizzle client (for prompt) internationalizable |
324 |
|
325 |
static const char* get_day_name(int day_of_week) |
|
326 |
{
|
|
327 |
switch(day_of_week) |
|
328 |
{
|
|
329 |
case 0: |
|
330 |
return _("Sun"); |
|
331 |
case 1: |
|
332 |
return _("Mon"); |
|
333 |
case 2: |
|
334 |
return _("Tue"); |
|
335 |
case 3: |
|
336 |
return _("Wed"); |
|
337 |
case 4: |
|
338 |
return _("Thu"); |
|
339 |
case 5: |
|
340 |
return _("Fri"); |
|
341 |
case 6: |
|
342 |
return _("Sat"); |
|
343 |
}
|
|
344 |
||
345 |
return NULL; |
|
346 |
}
|
|
347 |
||
348 |
static const char* get_month_name(int month) |
|
349 |
{
|
|
350 |
switch(month) |
|
351 |
{
|
|
352 |
case 0: |
|
353 |
return _("Jan"); |
|
354 |
case 1: |
|
355 |
return _("Feb"); |
|
356 |
case 2: |
|
357 |
return _("Mar"); |
|
358 |
case 3: |
|
359 |
return _("Apr"); |
|
360 |
case 4: |
|
361 |
return _("May"); |
|
362 |
case 5: |
|
363 |
return _("Jun"); |
|
364 |
case 6: |
|
365 |
return _("Jul"); |
|
366 |
case 7: |
|
367 |
return _("Aug"); |
|
368 |
case 8: |
|
369 |
return _("Sep"); |
|
370 |
case 9: |
|
371 |
return _("Oct"); |
|
372 |
case 10: |
|
373 |
return _("Nov"); |
|
374 |
case 11: |
|
375 |
return _("Dec"); |
|
376 |
}
|
|
377 |
||
378 |
return NULL; |
|
379 |
}
|
|
380 |
||
1567.3.15
by Monty Taylor
Removed the last vestiges of my_sys from drizzle.cc. |
381 |
/* @TODO: Remove this */
|
382 |
#define FN_REFLEN 512
|
|
383 |
||
1567.3.17
by Monty Taylor
Removed more C-string strings. replaced with std::string. |
384 |
static string default_pager(""); |
385 |
static string pager(""); |
|
386 |
static string outfile(""); |
|
1
by brian
clean slate |
387 |
static FILE *PAGER, *OUTFILE; |
893
by Brian Aker
First pass of stripping uint |
388 |
static uint32_t prompt_counter; |
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
389 |
static char *delimiter= NULL; |
893
by Brian Aker
First pass of stripping uint |
390 |
static uint32_t delimiter_length= 1; |
1
by brian
clean slate |
391 |
unsigned short terminal_width= 80; |
392 |
||
1877.1.1
by Andrew Hutchings
Use size_t for command in drizzle.cc |
393 |
int drizzleclient_real_query_for_lazy(const char *buf, size_t length, |
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
394 |
drizzle_result_st *result, |
395 |
uint32_t *error_code); |
|
928.1.4
by Eric Day
Fixed a few bugs, more progress on conversion. |
396 |
int drizzleclient_store_result_for_lazy(drizzle_result_st *result); |
77.3.7
by Monty Taylor
Made mysql into a pure-C program. |
397 |
|
1
by brian
clean slate |
398 |
|
399 |
void tee_fprintf(FILE *file, const char *fmt, ...); |
|
400 |
void tee_fputs(const char *s, FILE *file); |
|
401 |
void tee_puts(const char *s, FILE *file); |
|
402 |
void tee_putc(int c, FILE *file); |
|
403 |
static void tee_print_sized_data(const char *, unsigned int, unsigned int, bool); |
|
404 |
/* The names of functions that actually do the manipulation. */
|
|
1567.5.3
by Vijay Samuel
Merge patch for sql_connect() and style issue. |
405 |
static int process_options(void); |
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
406 |
static int com_quit(string *str,const char*), |
1441.3.1
by Vijay Samuel
all required updations have been made |
407 |
com_go(string *str,const char*), com_ego(string *str,const char*), |
408 |
com_print(string *str,const char*), |
|
409 |
com_help(string *str,const char*), com_clear(string *str,const char*), |
|
410 |
com_connect(string *str,const char*), com_status(string *str,const char*), |
|
411 |
com_use(string *str,const char*), com_source(string *str, const char*), |
|
1954
by Brian Aker
This adds the command "shutdown" to the command line client. It does require |
412 |
com_shutdown(string *str,const char*), |
1441.3.1
by Vijay Samuel
all required updations have been made |
413 |
com_rehash(string *str, const char*), com_tee(string *str, const char*), |
414 |
com_notee(string *str, const char*), |
|
415 |
com_prompt(string *str, const char*), com_delimiter(string *str, const char*), |
|
416 |
com_warnings(string *str, const char*), com_nowarnings(string *str, const char*), |
|
417 |
com_nopager(string *str, const char*), com_pager(string *str, const char*); |
|
1
by brian
clean slate |
418 |
|
419 |
static int read_and_execute(bool interactive); |
|
2053.2.1
by Andrew Hutchings
Fix hidden connect messages |
420 |
static int sql_connect(const string &host, const string &database, const string &user, const string &password); |
928.1.1
by Eric Day
Started client changes. |
421 |
static const char *server_version_string(drizzle_con_st *con); |
893
by Brian Aker
First pass of stripping uint |
422 |
static int put_info(const char *str,INFO_TYPE info,uint32_t error, |
77.3.7
by Monty Taylor
Made mysql into a pure-C program. |
423 |
const char *sql_state); |
928.1.1
by Eric Day
Started client changes. |
424 |
static int put_error(drizzle_con_st *con, drizzle_result_st *res); |
288
by Brian Aker
ulong cleanp in client apps |
425 |
static void safe_put_field(const char *pos,uint32_t length); |
77.3.7
by Monty Taylor
Made mysql into a pure-C program. |
426 |
static void init_pager(void); |
427 |
static void end_pager(void); |
|
1
by brian
clean slate |
428 |
static void init_tee(const char *); |
77.3.7
by Monty Taylor
Made mysql into a pure-C program. |
429 |
static void end_tee(void); |
430 |
static const char* construct_prompt(void); |
|
143
by Brian Aker
Bool cleanup. |
431 |
static char *get_arg(char *line, bool get_next_arg); |
77.3.7
by Monty Taylor
Made mysql into a pure-C program. |
432 |
static void init_username(void); |
1
by brian
clean slate |
433 |
static void add_int_to_prompt(int toadd); |
928.1.1
by Eric Day
Started client changes. |
434 |
static int get_result_width(drizzle_result_st *res); |
435 |
static int get_field_disp_length(drizzle_column_st * field); |
|
2187.4.1
by Olaf van der Spek
Remove register keyword |
436 |
static const char * strcont(const char *str, const char *set); |
1
by brian
clean slate |
437 |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
438 |
/* A class which contains information on the commands this program
|
439 |
can understand. */
|
|
440 |
class Commands |
|
441 |
{
|
|
442 |
private: |
|
202.1.25
by Monty Taylor
Fixed change of mysql.com -> drizzle.com. |
443 |
const char *name; /* User printable name of the function. */ |
444 |
char cmd_char; /* msql command character */ |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
445 |
public: |
446 |
Commands(const char *in_name, |
|
447 |
char in_cmd_char, |
|
448 |
int (*in_func)(string *str,const char *name), |
|
449 |
bool in_takes_params, |
|
450 |
const char *in_doc) |
|
451 |
:
|
|
452 |
name(in_name), |
|
453 |
cmd_char(in_cmd_char), |
|
454 |
func(in_func), |
|
455 |
takes_params(in_takes_params), |
|
456 |
doc(in_doc) |
|
457 |
{}
|
|
458 |
||
459 |
Commands() |
|
460 |
:
|
|
461 |
name(), |
|
462 |
cmd_char(), |
|
463 |
func(NULL), |
|
464 |
takes_params(false), |
|
465 |
doc() |
|
466 |
{}
|
|
467 |
||
468 |
int (*func)(string *str,const char *);/* Function to call to do the job. */ |
|
469 |
||
470 |
const char *getName() const |
|
471 |
{
|
|
472 |
return name; |
|
473 |
}
|
|
474 |
||
475 |
char getCmdChar() const |
|
476 |
{
|
|
477 |
return cmd_char; |
|
478 |
}
|
|
479 |
||
480 |
bool getTakesParams() const |
|
481 |
{
|
|
482 |
return takes_params; |
|
483 |
}
|
|
484 |
||
485 |
const char *getDoc() const |
|
486 |
{
|
|
487 |
return doc; |
|
488 |
}
|
|
489 |
||
490 |
void setName(const char *in_name) |
|
491 |
{
|
|
492 |
name= in_name; |
|
493 |
}
|
|
494 |
||
495 |
void setCmdChar(char in_cmd_char) |
|
496 |
{
|
|
497 |
cmd_char= in_cmd_char; |
|
498 |
}
|
|
499 |
||
500 |
void setTakesParams(bool in_takes_params) |
|
501 |
{
|
|
502 |
takes_params= in_takes_params; |
|
503 |
}
|
|
504 |
||
505 |
void setDoc(const char *in_doc) |
|
506 |
{
|
|
507 |
doc= in_doc; |
|
508 |
}
|
|
509 |
||
510 |
private: |
|
202.1.25
by Monty Taylor
Fixed change of mysql.com -> drizzle.com. |
511 |
bool takes_params; /* Max parameters for command */ |
512 |
const char *doc; /* Documentation for this function. */ |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
513 |
};
|
514 |
||
515 |
||
516 |
static Commands commands[] = { |
|
1441.3.3
by Vijay Samuel
Changes made to the struct conversion |
517 |
Commands( "?", '?', com_help, 0, N_("Synonym for `help'.") ), |
518 |
Commands( "clear", 'c', com_clear, 0, N_("Clear command.")), |
|
519 |
Commands( "connect",'r', com_connect,1, |
|
520 |
N_("Reconnect to the server. Optional arguments are db and host.")), |
|
521 |
Commands( "delimiter", 'd', com_delimiter, 1, |
|
522 |
N_("Set statement delimiter. NOTE: Takes the rest of the line as new delimiter.") ), |
|
523 |
Commands( "ego", 'G', com_ego, 0, |
|
524 |
N_("Send command to drizzle server, display result vertically.")), |
|
525 |
Commands( "exit", 'q', com_quit, 0, N_("Exit drizzle. Same as quit.")), |
|
526 |
Commands( "go", 'g', com_go, 0, N_("Send command to drizzle server.") ), |
|
527 |
Commands( "help", 'h', com_help, 0, N_("Display this help.") ), |
|
528 |
Commands( "nopager",'n', com_nopager,0, N_("Disable pager, print to stdout.") ), |
|
529 |
Commands( "notee", 't', com_notee, 0, N_("Don't write into outfile.") ), |
|
530 |
Commands( "pager", 'P', com_pager, 1, |
|
531 |
N_("Set PAGER [to_pager]. Print the query results via PAGER.") ), |
|
532 |
Commands( "print", 'p', com_print, 0, N_("Print current command.") ), |
|
533 |
Commands( "prompt", 'R', com_prompt, 1, N_("Change your drizzle prompt.")), |
|
534 |
Commands( "quit", 'q', com_quit, 0, N_("Quit drizzle.") ), |
|
535 |
Commands( "rehash", '#', com_rehash, 0, N_("Rebuild completion hash.") ), |
|
536 |
Commands( "source", '.', com_source, 1, |
|
537 |
N_("Execute an SQL script file. Takes a file name as an argument.")), |
|
538 |
Commands( "status", 's', com_status, 0, N_("Get status information from the server.")), |
|
539 |
Commands( "tee", 'T', com_tee, 1, |
|
540 |
N_("Set outfile [to_outfile]. Append everything into given outfile.") ), |
|
541 |
Commands( "use", 'u', com_use, 1, |
|
2005.2.2
by Andrew Hutchings
Change most places to use 'schema' instead of 'database' |
542 |
N_("Use another schema. Takes schema name as argument.") ), |
1954
by Brian Aker
This adds the command "shutdown" to the command line client. It does require |
543 |
Commands( "shutdown", 'u', com_shutdown, 1, |
544 |
N_("Shutdown the instance you are connected too.") ), |
|
1441.3.3
by Vijay Samuel
Changes made to the struct conversion |
545 |
Commands( "warnings", 'W', com_warnings, 0, |
546 |
N_("Show warnings after every statement.") ), |
|
547 |
Commands( "nowarning", 'w', com_nowarnings, 0, |
|
548 |
N_("Don't show warnings after every statement.") ), |
|
1
by brian
clean slate |
549 |
/* Get bash-like expansion for some commands */
|
1441.3.3
by Vijay Samuel
Changes made to the struct conversion |
550 |
Commands( "create table", 0, 0, 0, ""), |
551 |
Commands( "create database", 0, 0, 0, ""), |
|
552 |
Commands( "show databases", 0, 0, 0, ""), |
|
553 |
Commands( "show fields from", 0, 0, 0, ""), |
|
554 |
Commands( "show keys from", 0, 0, 0, ""), |
|
555 |
Commands( "show tables", 0, 0, 0, ""), |
|
556 |
Commands( "load data from", 0, 0, 0, ""), |
|
557 |
Commands( "alter table", 0, 0, 0, ""), |
|
558 |
Commands( "set option", 0, 0, 0, ""), |
|
559 |
Commands( "lock tables", 0, 0, 0, ""), |
|
560 |
Commands( "unlock tables", 0, 0, 0, ""), |
|
1
by brian
clean slate |
561 |
/* generated 2006-12-28. Refresh occasionally from lexer. */
|
1441.3.3
by Vijay Samuel
Changes made to the struct conversion |
562 |
Commands( "ACTION", 0, 0, 0, ""), |
563 |
Commands( "ADD", 0, 0, 0, ""), |
|
564 |
Commands( "AFTER", 0, 0, 0, ""), |
|
565 |
Commands( "AGAINST", 0, 0, 0, ""), |
|
566 |
Commands( "AGGREGATE", 0, 0, 0, ""), |
|
567 |
Commands( "ALL", 0, 0, 0, ""), |
|
568 |
Commands( "ALGORITHM", 0, 0, 0, ""), |
|
569 |
Commands( "ALTER", 0, 0, 0, ""), |
|
570 |
Commands( "ANALYZE", 0, 0, 0, ""), |
|
571 |
Commands( "AND", 0, 0, 0, ""), |
|
572 |
Commands( "ANY", 0, 0, 0, ""), |
|
573 |
Commands( "AS", 0, 0, 0, ""), |
|
574 |
Commands( "ASC", 0, 0, 0, ""), |
|
575 |
Commands( "ASCII", 0, 0, 0, ""), |
|
576 |
Commands( "ASENSITIVE", 0, 0, 0, ""), |
|
577 |
Commands( "AUTO_INCREMENT", 0, 0, 0, ""), |
|
578 |
Commands( "AVG", 0, 0, 0, ""), |
|
579 |
Commands( "AVG_ROW_LENGTH", 0, 0, 0, ""), |
|
580 |
Commands( "BEFORE", 0, 0, 0, ""), |
|
581 |
Commands( "BEGIN", 0, 0, 0, ""), |
|
582 |
Commands( "BETWEEN", 0, 0, 0, ""), |
|
583 |
Commands( "BIGINT", 0, 0, 0, ""), |
|
584 |
Commands( "BINARY", 0, 0, 0, ""), |
|
585 |
Commands( "BIT", 0, 0, 0, ""), |
|
586 |
Commands( "BLOB", 0, 0, 0, ""), |
|
587 |
Commands( "BOOL", 0, 0, 0, ""), |
|
588 |
Commands( "BOOLEAN", 0, 0, 0, ""), |
|
589 |
Commands( "BOTH", 0, 0, 0, ""), |
|
590 |
Commands( "BTREE", 0, 0, 0, ""), |
|
591 |
Commands( "BY", 0, 0, 0, ""), |
|
592 |
Commands( "BYTE", 0, 0, 0, ""), |
|
593 |
Commands( "CACHE", 0, 0, 0, ""), |
|
594 |
Commands( "CALL", 0, 0, 0, ""), |
|
595 |
Commands( "CASCADE", 0, 0, 0, ""), |
|
596 |
Commands( "CASCADED", 0, 0, 0, ""), |
|
597 |
Commands( "CASE", 0, 0, 0, ""), |
|
598 |
Commands( "CHAIN", 0, 0, 0, ""), |
|
599 |
Commands( "CHANGE", 0, 0, 0, ""), |
|
600 |
Commands( "CHANGED", 0, 0, 0, ""), |
|
601 |
Commands( "CHAR", 0, 0, 0, ""), |
|
602 |
Commands( "CHARACTER", 0, 0, 0, ""), |
|
603 |
Commands( "CHECK", 0, 0, 0, ""), |
|
604 |
Commands( "CHECKSUM", 0, 0, 0, ""), |
|
605 |
Commands( "CLIENT", 0, 0, 0, ""), |
|
606 |
Commands( "CLOSE", 0, 0, 0, ""), |
|
607 |
Commands( "COLLATE", 0, 0, 0, ""), |
|
608 |
Commands( "COLLATION", 0, 0, 0, ""), |
|
609 |
Commands( "COLUMN", 0, 0, 0, ""), |
|
610 |
Commands( "COLUMNS", 0, 0, 0, ""), |
|
611 |
Commands( "COMMENT", 0, 0, 0, ""), |
|
612 |
Commands( "COMMIT", 0, 0, 0, ""), |
|
613 |
Commands( "COMMITTED", 0, 0, 0, ""), |
|
614 |
Commands( "COMPACT", 0, 0, 0, ""), |
|
615 |
Commands( "COMPRESSED", 0, 0, 0, ""), |
|
616 |
Commands( "CONCURRENT", 0, 0, 0, ""), |
|
617 |
Commands( "CONDITION", 0, 0, 0, ""), |
|
618 |
Commands( "CONNECTION", 0, 0, 0, ""), |
|
619 |
Commands( "CONSISTENT", 0, 0, 0, ""), |
|
620 |
Commands( "CONSTRAINT", 0, 0, 0, ""), |
|
621 |
Commands( "CONTAINS", 0, 0, 0, ""), |
|
622 |
Commands( "CONTINUE", 0, 0, 0, ""), |
|
623 |
Commands( "CONVERT", 0, 0, 0, ""), |
|
624 |
Commands( "CREATE", 0, 0, 0, ""), |
|
625 |
Commands( "CROSS", 0, 0, 0, ""), |
|
626 |
Commands( "CUBE", 0, 0, 0, ""), |
|
627 |
Commands( "CURRENT_DATE", 0, 0, 0, ""), |
|
628 |
Commands( "CURRENT_TIMESTAMP", 0, 0, 0, ""), |
|
629 |
Commands( "CURRENT_USER", 0, 0, 0, ""), |
|
630 |
Commands( "CURSOR", 0, 0, 0, ""), |
|
631 |
Commands( "DATA", 0, 0, 0, ""), |
|
632 |
Commands( "DATABASE", 0, 0, 0, ""), |
|
633 |
Commands( "DATABASES", 0, 0, 0, ""), |
|
634 |
Commands( "DATE", 0, 0, 0, ""), |
|
635 |
Commands( "DATETIME", 0, 0, 0, ""), |
|
636 |
Commands( "DAY", 0, 0, 0, ""), |
|
637 |
Commands( "DAY_HOUR", 0, 0, 0, ""), |
|
638 |
Commands( "DAY_MICROSECOND", 0, 0, 0, ""), |
|
639 |
Commands( "DAY_MINUTE", 0, 0, 0, ""), |
|
640 |
Commands( "DAY_SECOND", 0, 0, 0, ""), |
|
641 |
Commands( "DEALLOCATE", 0, 0, 0, ""), |
|
642 |
Commands( "DEC", 0, 0, 0, ""), |
|
643 |
Commands( "DECIMAL", 0, 0, 0, ""), |
|
644 |
Commands( "DECLARE", 0, 0, 0, ""), |
|
645 |
Commands( "DEFAULT", 0, 0, 0, ""), |
|
646 |
Commands( "DEFINER", 0, 0, 0, ""), |
|
647 |
Commands( "DELAYED", 0, 0, 0, ""), |
|
648 |
Commands( "DELETE", 0, 0, 0, ""), |
|
649 |
Commands( "DESC", 0, 0, 0, ""), |
|
650 |
Commands( "DESCRIBE", 0, 0, 0, ""), |
|
651 |
Commands( "DETERMINISTIC", 0, 0, 0, ""), |
|
652 |
Commands( "DISABLE", 0, 0, 0, ""), |
|
653 |
Commands( "DISCARD", 0, 0, 0, ""), |
|
654 |
Commands( "DISTINCT", 0, 0, 0, ""), |
|
655 |
Commands( "DISTINCTROW", 0, 0, 0, ""), |
|
656 |
Commands( "DIV", 0, 0, 0, ""), |
|
657 |
Commands( "DOUBLE", 0, 0, 0, ""), |
|
658 |
Commands( "DROP", 0, 0, 0, ""), |
|
659 |
Commands( "DUMPFILE", 0, 0, 0, ""), |
|
660 |
Commands( "DUPLICATE", 0, 0, 0, ""), |
|
661 |
Commands( "DYNAMIC", 0, 0, 0, ""), |
|
662 |
Commands( "EACH", 0, 0, 0, ""), |
|
663 |
Commands( "ELSE", 0, 0, 0, ""), |
|
664 |
Commands( "ELSEIF", 0, 0, 0, ""), |
|
665 |
Commands( "ENABLE", 0, 0, 0, ""), |
|
666 |
Commands( "ENCLOSED", 0, 0, 0, ""), |
|
667 |
Commands( "END", 0, 0, 0, ""), |
|
668 |
Commands( "ENGINE", 0, 0, 0, ""), |
|
669 |
Commands( "ENGINES", 0, 0, 0, ""), |
|
670 |
Commands( "ENUM", 0, 0, 0, ""), |
|
671 |
Commands( "ERRORS", 0, 0, 0, ""), |
|
672 |
Commands( "ESCAPE", 0, 0, 0, ""), |
|
673 |
Commands( "ESCAPED", 0, 0, 0, ""), |
|
674 |
Commands( "EXISTS", 0, 0, 0, ""), |
|
675 |
Commands( "EXIT", 0, 0, 0, ""), |
|
676 |
Commands( "EXPLAIN", 0, 0, 0, ""), |
|
677 |
Commands( "EXTENDED", 0, 0, 0, ""), |
|
678 |
Commands( "FALSE", 0, 0, 0, ""), |
|
679 |
Commands( "FAST", 0, 0, 0, ""), |
|
680 |
Commands( "FETCH", 0, 0, 0, ""), |
|
681 |
Commands( "FIELDS", 0, 0, 0, ""), |
|
682 |
Commands( "FILE", 0, 0, 0, ""), |
|
683 |
Commands( "FIRST", 0, 0, 0, ""), |
|
684 |
Commands( "FIXED", 0, 0, 0, ""), |
|
685 |
Commands( "FLOAT", 0, 0, 0, ""), |
|
686 |
Commands( "FLOAT4", 0, 0, 0, ""), |
|
687 |
Commands( "FLOAT8", 0, 0, 0, ""), |
|
688 |
Commands( "FLUSH", 0, 0, 0, ""), |
|
689 |
Commands( "FOR", 0, 0, 0, ""), |
|
690 |
Commands( "FORCE", 0, 0, 0, ""), |
|
691 |
Commands( "FOREIGN", 0, 0, 0, ""), |
|
692 |
Commands( "FOUND", 0, 0, 0, ""), |
|
693 |
Commands( "FRAC_SECOND", 0, 0, 0, ""), |
|
694 |
Commands( "FROM", 0, 0, 0, ""), |
|
695 |
Commands( "FULL", 0, 0, 0, ""), |
|
696 |
Commands( "FUNCTION", 0, 0, 0, ""), |
|
697 |
Commands( "GLOBAL", 0, 0, 0, ""), |
|
698 |
Commands( "GRANT", 0, 0, 0, ""), |
|
699 |
Commands( "GRANTS", 0, 0, 0, ""), |
|
700 |
Commands( "GROUP", 0, 0, 0, ""), |
|
701 |
Commands( "HANDLER", 0, 0, 0, ""), |
|
702 |
Commands( "HASH", 0, 0, 0, ""), |
|
703 |
Commands( "HAVING", 0, 0, 0, ""), |
|
704 |
Commands( "HELP", 0, 0, 0, ""), |
|
705 |
Commands( "HIGH_PRIORITY", 0, 0, 0, ""), |
|
706 |
Commands( "HOSTS", 0, 0, 0, ""), |
|
707 |
Commands( "HOUR", 0, 0, 0, ""), |
|
708 |
Commands( "HOUR_MICROSECOND", 0, 0, 0, ""), |
|
709 |
Commands( "HOUR_MINUTE", 0, 0, 0, ""), |
|
710 |
Commands( "HOUR_SECOND", 0, 0, 0, ""), |
|
711 |
Commands( "IDENTIFIED", 0, 0, 0, ""), |
|
712 |
Commands( "IF", 0, 0, 0, ""), |
|
713 |
Commands( "IGNORE", 0, 0, 0, ""), |
|
714 |
Commands( "IMPORT", 0, 0, 0, ""), |
|
715 |
Commands( "IN", 0, 0, 0, ""), |
|
716 |
Commands( "INDEX", 0, 0, 0, ""), |
|
717 |
Commands( "INDEXES", 0, 0, 0, ""), |
|
718 |
Commands( "INFILE", 0, 0, 0, ""), |
|
719 |
Commands( "INNER", 0, 0, 0, ""), |
|
720 |
Commands( "INNOBASE", 0, 0, 0, ""), |
|
721 |
Commands( "INNODB", 0, 0, 0, ""), |
|
722 |
Commands( "INOUT", 0, 0, 0, ""), |
|
723 |
Commands( "INSENSITIVE", 0, 0, 0, ""), |
|
724 |
Commands( "INSERT", 0, 0, 0, ""), |
|
725 |
Commands( "INSERT_METHOD", 0, 0, 0, ""), |
|
726 |
Commands( "INT", 0, 0, 0, ""), |
|
727 |
Commands( "INT1", 0, 0, 0, ""), |
|
728 |
Commands( "INT2", 0, 0, 0, ""), |
|
729 |
Commands( "INT3", 0, 0, 0, ""), |
|
730 |
Commands( "INT4", 0, 0, 0, ""), |
|
731 |
Commands( "INT8", 0, 0, 0, ""), |
|
732 |
Commands( "INTEGER", 0, 0, 0, ""), |
|
733 |
Commands( "INTERVAL", 0, 0, 0, ""), |
|
734 |
Commands( "INTO", 0, 0, 0, ""), |
|
735 |
Commands( "IO_THREAD", 0, 0, 0, ""), |
|
736 |
Commands( "IS", 0, 0, 0, ""), |
|
737 |
Commands( "ISOLATION", 0, 0, 0, ""), |
|
738 |
Commands( "ISSUER", 0, 0, 0, ""), |
|
739 |
Commands( "ITERATE", 0, 0, 0, ""), |
|
740 |
Commands( "INVOKER", 0, 0, 0, ""), |
|
741 |
Commands( "JOIN", 0, 0, 0, ""), |
|
742 |
Commands( "KEY", 0, 0, 0, ""), |
|
743 |
Commands( "KEYS", 0, 0, 0, ""), |
|
744 |
Commands( "KILL", 0, 0, 0, ""), |
|
745 |
Commands( "LANGUAGE", 0, 0, 0, ""), |
|
746 |
Commands( "LAST", 0, 0, 0, ""), |
|
747 |
Commands( "LEADING", 0, 0, 0, ""), |
|
748 |
Commands( "LEAVE", 0, 0, 0, ""), |
|
749 |
Commands( "LEAVES", 0, 0, 0, ""), |
|
750 |
Commands( "LEFT", 0, 0, 0, ""), |
|
751 |
Commands( "LEVEL", 0, 0, 0, ""), |
|
752 |
Commands( "LIKE", 0, 0, 0, ""), |
|
753 |
Commands( "LIMIT", 0, 0, 0, ""), |
|
754 |
Commands( "LINES", 0, 0, 0, ""), |
|
755 |
Commands( "LINESTRING", 0, 0, 0, ""), |
|
756 |
Commands( "LOAD", 0, 0, 0, ""), |
|
757 |
Commands( "LOCAL", 0, 0, 0, ""), |
|
758 |
Commands( "LOCALTIMESTAMP", 0, 0, 0, ""), |
|
759 |
Commands( "LOCK", 0, 0, 0, ""), |
|
760 |
Commands( "LOCKS", 0, 0, 0, ""), |
|
761 |
Commands( "LOGS", 0, 0, 0, ""), |
|
762 |
Commands( "LONG", 0, 0, 0, ""), |
|
763 |
Commands( "LOOP", 0, 0, 0, ""), |
|
764 |
Commands( "MATCH", 0, 0, 0, ""), |
|
765 |
Commands( "MAX_CONNECTIONS_PER_HOUR", 0, 0, 0, ""), |
|
766 |
Commands( "MAX_QUERIES_PER_HOUR", 0, 0, 0, ""), |
|
767 |
Commands( "MAX_ROWS", 0, 0, 0, ""), |
|
768 |
Commands( "MAX_UPDATES_PER_HOUR", 0, 0, 0, ""), |
|
769 |
Commands( "MAX_USER_CONNECTIONS", 0, 0, 0, ""), |
|
770 |
Commands( "MEDIUM", 0, 0, 0, ""), |
|
771 |
Commands( "MERGE", 0, 0, 0, ""), |
|
772 |
Commands( "MICROSECOND", 0, 0, 0, ""), |
|
773 |
Commands( "MIGRATE", 0, 0, 0, ""), |
|
774 |
Commands( "MINUTE", 0, 0, 0, ""), |
|
775 |
Commands( "MINUTE_MICROSECOND", 0, 0, 0, ""), |
|
776 |
Commands( "MINUTE_SECOND", 0, 0, 0, ""), |
|
777 |
Commands( "MIN_ROWS", 0, 0, 0, ""), |
|
778 |
Commands( "MOD", 0, 0, 0, ""), |
|
779 |
Commands( "MODE", 0, 0, 0, ""), |
|
780 |
Commands( "MODIFIES", 0, 0, 0, ""), |
|
781 |
Commands( "MODIFY", 0, 0, 0, ""), |
|
782 |
Commands( "MONTH", 0, 0, 0, ""), |
|
783 |
Commands( "MULTILINESTRING", 0, 0, 0, ""), |
|
784 |
Commands( "MULTIPOINT", 0, 0, 0, ""), |
|
785 |
Commands( "MULTIPOLYGON", 0, 0, 0, ""), |
|
786 |
Commands( "MUTEX", 0, 0, 0, ""), |
|
787 |
Commands( "NAME", 0, 0, 0, ""), |
|
788 |
Commands( "NAMES", 0, 0, 0, ""), |
|
789 |
Commands( "NATIONAL", 0, 0, 0, ""), |
|
790 |
Commands( "NATURAL", 0, 0, 0, ""), |
|
791 |
Commands( "NCHAR", 0, 0, 0, ""), |
|
792 |
Commands( "NEW", 0, 0, 0, ""), |
|
793 |
Commands( "NEXT", 0, 0, 0, ""), |
|
794 |
Commands( "NO", 0, 0, 0, ""), |
|
795 |
Commands( "NONE", 0, 0, 0, ""), |
|
796 |
Commands( "NOT", 0, 0, 0, ""), |
|
797 |
Commands( "NULL", 0, 0, 0, ""), |
|
798 |
Commands( "NUMERIC", 0, 0, 0, ""), |
|
799 |
Commands( "NVARCHAR", 0, 0, 0, ""), |
|
800 |
Commands( "OFFSET", 0, 0, 0, ""), |
|
801 |
Commands( "ON", 0, 0, 0, ""), |
|
802 |
Commands( "ONE", 0, 0, 0, ""), |
|
803 |
Commands( "ONE_SHOT", 0, 0, 0, ""), |
|
804 |
Commands( "OPEN", 0, 0, 0, ""), |
|
805 |
Commands( "OPTIMIZE", 0, 0, 0, ""), |
|
806 |
Commands( "OPTION", 0, 0, 0, ""), |
|
807 |
Commands( "OPTIONALLY", 0, 0, 0, ""), |
|
808 |
Commands( "OR", 0, 0, 0, ""), |
|
809 |
Commands( "ORDER", 0, 0, 0, ""), |
|
810 |
Commands( "OUT", 0, 0, 0, ""), |
|
811 |
Commands( "OUTER", 0, 0, 0, ""), |
|
812 |
Commands( "OUTFILE", 0, 0, 0, ""), |
|
813 |
Commands( "PACK_KEYS", 0, 0, 0, ""), |
|
814 |
Commands( "PARTIAL", 0, 0, 0, ""), |
|
815 |
Commands( "PASSWORD", 0, 0, 0, ""), |
|
816 |
Commands( "PHASE", 0, 0, 0, ""), |
|
817 |
Commands( "PRECISION", 0, 0, 0, ""), |
|
818 |
Commands( "PREPARE", 0, 0, 0, ""), |
|
819 |
Commands( "PREV", 0, 0, 0, ""), |
|
820 |
Commands( "PRIMARY", 0, 0, 0, ""), |
|
821 |
Commands( "PRIVILEGES", 0, 0, 0, ""), |
|
822 |
Commands( "PROCEDURE", 0, 0, 0, ""), |
|
823 |
Commands( "PROCESS", 0, 0, 0, ""), |
|
824 |
Commands( "PROCESSLIST", 0, 0, 0, ""), |
|
825 |
Commands( "PURGE", 0, 0, 0, ""), |
|
826 |
Commands( "QUARTER", 0, 0, 0, ""), |
|
827 |
Commands( "QUERY", 0, 0, 0, ""), |
|
828 |
Commands( "QUICK", 0, 0, 0, ""), |
|
829 |
Commands( "READ", 0, 0, 0, ""), |
|
830 |
Commands( "READS", 0, 0, 0, ""), |
|
831 |
Commands( "REAL", 0, 0, 0, ""), |
|
832 |
Commands( "RECOVER", 0, 0, 0, ""), |
|
833 |
Commands( "REDUNDANT", 0, 0, 0, ""), |
|
834 |
Commands( "REFERENCES", 0, 0, 0, ""), |
|
835 |
Commands( "REGEXP", 0, 0, 0, ""), |
|
836 |
Commands( "RELEASE", 0, 0, 0, ""), |
|
837 |
Commands( "RELOAD", 0, 0, 0, ""), |
|
838 |
Commands( "RENAME", 0, 0, 0, ""), |
|
839 |
Commands( "REPAIR", 0, 0, 0, ""), |
|
840 |
Commands( "REPEATABLE", 0, 0, 0, ""), |
|
841 |
Commands( "REPLACE", 0, 0, 0, ""), |
|
842 |
Commands( "REPEAT", 0, 0, 0, ""), |
|
843 |
Commands( "REQUIRE", 0, 0, 0, ""), |
|
844 |
Commands( "RESET", 0, 0, 0, ""), |
|
845 |
Commands( "RESTORE", 0, 0, 0, ""), |
|
846 |
Commands( "RESTRICT", 0, 0, 0, ""), |
|
847 |
Commands( "RESUME", 0, 0, 0, ""), |
|
848 |
Commands( "RETURN", 0, 0, 0, ""), |
|
849 |
Commands( "RETURNS", 0, 0, 0, ""), |
|
850 |
Commands( "REVOKE", 0, 0, 0, ""), |
|
851 |
Commands( "RIGHT", 0, 0, 0, ""), |
|
852 |
Commands( "RLIKE", 0, 0, 0, ""), |
|
853 |
Commands( "ROLLBACK", 0, 0, 0, ""), |
|
854 |
Commands( "ROLLUP", 0, 0, 0, ""), |
|
855 |
Commands( "ROUTINE", 0, 0, 0, ""), |
|
856 |
Commands( "ROW", 0, 0, 0, ""), |
|
857 |
Commands( "ROWS", 0, 0, 0, ""), |
|
858 |
Commands( "ROW_FORMAT", 0, 0, 0, ""), |
|
859 |
Commands( "RTREE", 0, 0, 0, ""), |
|
860 |
Commands( "SAVEPOINT", 0, 0, 0, ""), |
|
861 |
Commands( "SCHEMA", 0, 0, 0, ""), |
|
862 |
Commands( "SCHEMAS", 0, 0, 0, ""), |
|
863 |
Commands( "SECOND", 0, 0, 0, ""), |
|
864 |
Commands( "SECOND_MICROSECOND", 0, 0, 0, ""), |
|
865 |
Commands( "SECURITY", 0, 0, 0, ""), |
|
866 |
Commands( "SELECT", 0, 0, 0, ""), |
|
867 |
Commands( "SENSITIVE", 0, 0, 0, ""), |
|
868 |
Commands( "SEPARATOR", 0, 0, 0, ""), |
|
869 |
Commands( "SERIAL", 0, 0, 0, ""), |
|
870 |
Commands( "SERIALIZABLE", 0, 0, 0, ""), |
|
871 |
Commands( "SESSION", 0, 0, 0, ""), |
|
872 |
Commands( "SET", 0, 0, 0, ""), |
|
873 |
Commands( "SHARE", 0, 0, 0, ""), |
|
874 |
Commands( "SHOW", 0, 0, 0, ""), |
|
875 |
Commands( "SHUTDOWN", 0, 0, 0, ""), |
|
876 |
Commands( "SIGNED", 0, 0, 0, ""), |
|
877 |
Commands( "SIMPLE", 0, 0, 0, ""), |
|
878 |
Commands( "SLAVE", 0, 0, 0, ""), |
|
879 |
Commands( "SNAPSHOT", 0, 0, 0, ""), |
|
880 |
Commands( "SOME", 0, 0, 0, ""), |
|
881 |
Commands( "SONAME", 0, 0, 0, ""), |
|
882 |
Commands( "SOUNDS", 0, 0, 0, ""), |
|
883 |
Commands( "SPATIAL", 0, 0, 0, ""), |
|
884 |
Commands( "SPECIFIC", 0, 0, 0, ""), |
|
885 |
Commands( "SQL", 0, 0, 0, ""), |
|
886 |
Commands( "SQLEXCEPTION", 0, 0, 0, ""), |
|
887 |
Commands( "SQLSTATE", 0, 0, 0, ""), |
|
888 |
Commands( "SQLWARNING", 0, 0, 0, ""), |
|
889 |
Commands( "SQL_BIG_RESULT", 0, 0, 0, ""), |
|
890 |
Commands( "SQL_BUFFER_RESULT", 0, 0, 0, ""), |
|
891 |
Commands( "SQL_CACHE", 0, 0, 0, ""), |
|
892 |
Commands( "SQL_CALC_FOUND_ROWS", 0, 0, 0, ""), |
|
893 |
Commands( "SQL_NO_CACHE", 0, 0, 0, ""), |
|
894 |
Commands( "SQL_SMALL_RESULT", 0, 0, 0, ""), |
|
895 |
Commands( "SQL_THREAD", 0, 0, 0, ""), |
|
896 |
Commands( "SQL_TSI_FRAC_SECOND", 0, 0, 0, ""), |
|
897 |
Commands( "SQL_TSI_SECOND", 0, 0, 0, ""), |
|
898 |
Commands( "SQL_TSI_MINUTE", 0, 0, 0, ""), |
|
899 |
Commands( "SQL_TSI_HOUR", 0, 0, 0, ""), |
|
900 |
Commands( "SQL_TSI_DAY", 0, 0, 0, ""), |
|
901 |
Commands( "SQL_TSI_WEEK", 0, 0, 0, ""), |
|
902 |
Commands( "SQL_TSI_MONTH", 0, 0, 0, ""), |
|
903 |
Commands( "SQL_TSI_QUARTER", 0, 0, 0, ""), |
|
904 |
Commands( "SQL_TSI_YEAR", 0, 0, 0, ""), |
|
905 |
Commands( "SSL", 0, 0, 0, ""), |
|
906 |
Commands( "START", 0, 0, 0, ""), |
|
907 |
Commands( "STARTING", 0, 0, 0, ""), |
|
908 |
Commands( "STATUS", 0, 0, 0, ""), |
|
909 |
Commands( "STOP", 0, 0, 0, ""), |
|
910 |
Commands( "STORAGE", 0, 0, 0, ""), |
|
911 |
Commands( "STRAIGHT_JOIN", 0, 0, 0, ""), |
|
912 |
Commands( "STRING", 0, 0, 0, ""), |
|
913 |
Commands( "STRIPED", 0, 0, 0, ""), |
|
914 |
Commands( "SUBJECT", 0, 0, 0, ""), |
|
915 |
Commands( "SUPER", 0, 0, 0, ""), |
|
916 |
Commands( "SUSPEND", 0, 0, 0, ""), |
|
917 |
Commands( "TABLE", 0, 0, 0, ""), |
|
918 |
Commands( "TABLES", 0, 0, 0, ""), |
|
919 |
Commands( "TABLESPACE", 0, 0, 0, ""), |
|
920 |
Commands( "TEMPORARY", 0, 0, 0, ""), |
|
921 |
Commands( "TEMPTABLE", 0, 0, 0, ""), |
|
922 |
Commands( "TERMINATED", 0, 0, 0, ""), |
|
923 |
Commands( "TEXT", 0, 0, 0, ""), |
|
924 |
Commands( "THEN", 0, 0, 0, ""), |
|
925 |
Commands( "TIMESTAMP", 0, 0, 0, ""), |
|
926 |
Commands( "TIMESTAMPADD", 0, 0, 0, ""), |
|
927 |
Commands( "TIMESTAMPDIFF", 0, 0, 0, ""), |
|
928 |
Commands( "TO", 0, 0, 0, ""), |
|
929 |
Commands( "TRAILING", 0, 0, 0, ""), |
|
930 |
Commands( "TRANSACTION", 0, 0, 0, ""), |
|
931 |
Commands( "TRUE", 0, 0, 0, ""), |
|
932 |
Commands( "TRUNCATE", 0, 0, 0, ""), |
|
933 |
Commands( "TYPE", 0, 0, 0, ""), |
|
934 |
Commands( "TYPES", 0, 0, 0, ""), |
|
935 |
Commands( "UNCOMMITTED", 0, 0, 0, ""), |
|
936 |
Commands( "UNDEFINED", 0, 0, 0, ""), |
|
937 |
Commands( "UNDO", 0, 0, 0, ""), |
|
938 |
Commands( "UNICODE", 0, 0, 0, ""), |
|
939 |
Commands( "UNION", 0, 0, 0, ""), |
|
940 |
Commands( "UNIQUE", 0, 0, 0, ""), |
|
941 |
Commands( "UNKNOWN", 0, 0, 0, ""), |
|
942 |
Commands( "UNLOCK", 0, 0, 0, ""), |
|
943 |
Commands( "UNTIL", 0, 0, 0, ""), |
|
944 |
Commands( "UPDATE", 0, 0, 0, ""), |
|
945 |
Commands( "UPGRADE", 0, 0, 0, ""), |
|
946 |
Commands( "USAGE", 0, 0, 0, ""), |
|
947 |
Commands( "USE", 0, 0, 0, ""), |
|
948 |
Commands( "USER", 0, 0, 0, ""), |
|
949 |
Commands( "USER_RESOURCES", 0, 0, 0, ""), |
|
950 |
Commands( "USING", 0, 0, 0, ""), |
|
951 |
Commands( "UTC_DATE", 0, 0, 0, ""), |
|
952 |
Commands( "UTC_TIMESTAMP", 0, 0, 0, ""), |
|
953 |
Commands( "VALUE", 0, 0, 0, ""), |
|
954 |
Commands( "VALUES", 0, 0, 0, ""), |
|
955 |
Commands( "VARBINARY", 0, 0, 0, ""), |
|
956 |
Commands( "VARCHAR", 0, 0, 0, ""), |
|
957 |
Commands( "VARCHARACTER", 0, 0, 0, ""), |
|
958 |
Commands( "VARIABLES", 0, 0, 0, ""), |
|
959 |
Commands( "VARYING", 0, 0, 0, ""), |
|
960 |
Commands( "WARNINGS", 0, 0, 0, ""), |
|
961 |
Commands( "WEEK", 0, 0, 0, ""), |
|
962 |
Commands( "WHEN", 0, 0, 0, ""), |
|
963 |
Commands( "WHERE", 0, 0, 0, ""), |
|
964 |
Commands( "WHILE", 0, 0, 0, ""), |
|
965 |
Commands( "VIEW", 0, 0, 0, ""), |
|
966 |
Commands( "WITH", 0, 0, 0, ""), |
|
967 |
Commands( "WORK", 0, 0, 0, ""), |
|
968 |
Commands( "WRITE", 0, 0, 0, ""), |
|
969 |
Commands( "XOR", 0, 0, 0, ""), |
|
970 |
Commands( "XA", 0, 0, 0, ""), |
|
971 |
Commands( "YEAR", 0, 0, 0, ""), |
|
972 |
Commands( "YEAR_MONTH", 0, 0, 0, ""), |
|
973 |
Commands( "ZEROFILL", 0, 0, 0, ""), |
|
974 |
Commands( "ABS", 0, 0, 0, ""), |
|
975 |
Commands( "ACOS", 0, 0, 0, ""), |
|
976 |
Commands( "ADDDATE", 0, 0, 0, ""), |
|
977 |
Commands( "AREA", 0, 0, 0, ""), |
|
978 |
Commands( "ASIN", 0, 0, 0, ""), |
|
979 |
Commands( "ASBINARY", 0, 0, 0, ""), |
|
980 |
Commands( "ASTEXT", 0, 0, 0, ""), |
|
981 |
Commands( "ATAN", 0, 0, 0, ""), |
|
982 |
Commands( "ATAN2", 0, 0, 0, ""), |
|
983 |
Commands( "BENCHMARK", 0, 0, 0, ""), |
|
984 |
Commands( "BIN", 0, 0, 0, ""), |
|
985 |
Commands( "BIT_OR", 0, 0, 0, ""), |
|
986 |
Commands( "BIT_AND", 0, 0, 0, ""), |
|
987 |
Commands( "BIT_XOR", 0, 0, 0, ""), |
|
988 |
Commands( "CAST", 0, 0, 0, ""), |
|
989 |
Commands( "CEIL", 0, 0, 0, ""), |
|
990 |
Commands( "CEILING", 0, 0, 0, ""), |
|
991 |
Commands( "CENTROID", 0, 0, 0, ""), |
|
992 |
Commands( "CHAR_LENGTH", 0, 0, 0, ""), |
|
993 |
Commands( "CHARACTER_LENGTH", 0, 0, 0, ""), |
|
994 |
Commands( "COALESCE", 0, 0, 0, ""), |
|
995 |
Commands( "COERCIBILITY", 0, 0, 0, ""), |
|
996 |
Commands( "COMPRESS", 0, 0, 0, ""), |
|
997 |
Commands( "CONCAT", 0, 0, 0, ""), |
|
998 |
Commands( "CONCAT_WS", 0, 0, 0, ""), |
|
999 |
Commands( "CONNECTION_ID", 0, 0, 0, ""), |
|
1000 |
Commands( "CONV", 0, 0, 0, ""), |
|
1001 |
Commands( "CONVERT_TZ", 0, 0, 0, ""), |
|
1002 |
Commands( "COUNT", 0, 0, 0, ""), |
|
1003 |
Commands( "COS", 0, 0, 0, ""), |
|
1004 |
Commands( "COT", 0, 0, 0, ""), |
|
1005 |
Commands( "CRC32", 0, 0, 0, ""), |
|
1006 |
Commands( "CROSSES", 0, 0, 0, ""), |
|
1007 |
Commands( "CURDATE", 0, 0, 0, ""), |
|
1008 |
Commands( "DATE_ADD", 0, 0, 0, ""), |
|
1009 |
Commands( "DATEDIFF", 0, 0, 0, ""), |
|
1010 |
Commands( "DATE_FORMAT", 0, 0, 0, ""), |
|
1011 |
Commands( "DATE_SUB", 0, 0, 0, ""), |
|
1012 |
Commands( "DAYNAME", 0, 0, 0, ""), |
|
1013 |
Commands( "DAYOFMONTH", 0, 0, 0, ""), |
|
1014 |
Commands( "DAYOFWEEK", 0, 0, 0, ""), |
|
1015 |
Commands( "DAYOFYEAR", 0, 0, 0, ""), |
|
1016 |
Commands( "DECODE", 0, 0, 0, ""), |
|
1017 |
Commands( "DEGREES", 0, 0, 0, ""), |
|
1018 |
Commands( "DES_ENCRYPT", 0, 0, 0, ""), |
|
1019 |
Commands( "DES_DECRYPT", 0, 0, 0, ""), |
|
1020 |
Commands( "DIMENSION", 0, 0, 0, ""), |
|
1021 |
Commands( "DISJOINT", 0, 0, 0, ""), |
|
1022 |
Commands( "ELT", 0, 0, 0, ""), |
|
1023 |
Commands( "ENCODE", 0, 0, 0, ""), |
|
1024 |
Commands( "ENCRYPT", 0, 0, 0, ""), |
|
1025 |
Commands( "ENDPOINT", 0, 0, 0, ""), |
|
1026 |
Commands( "ENVELOPE", 0, 0, 0, ""), |
|
1027 |
Commands( "EQUALS", 0, 0, 0, ""), |
|
1028 |
Commands( "EXTERIORRING", 0, 0, 0, ""), |
|
1029 |
Commands( "EXTRACT", 0, 0, 0, ""), |
|
1030 |
Commands( "EXP", 0, 0, 0, ""), |
|
1031 |
Commands( "EXPORT_SET", 0, 0, 0, ""), |
|
1032 |
Commands( "FIELD", 0, 0, 0, ""), |
|
1033 |
Commands( "FIND_IN_SET", 0, 0, 0, ""), |
|
1034 |
Commands( "FLOOR", 0, 0, 0, ""), |
|
1035 |
Commands( "FORMAT", 0, 0, 0, ""), |
|
1036 |
Commands( "FOUND_ROWS", 0, 0, 0, ""), |
|
1037 |
Commands( "FROM_DAYS", 0, 0, 0, ""), |
|
1038 |
Commands( "FROM_UNIXTIME", 0, 0, 0, ""), |
|
1039 |
Commands( "GET_LOCK", 0, 0, 0, ""), |
|
1040 |
Commands( "GLENGTH", 0, 0, 0, ""), |
|
1041 |
Commands( "GREATEST", 0, 0, 0, ""), |
|
1042 |
Commands( "GROUP_CONCAT", 0, 0, 0, ""), |
|
1043 |
Commands( "GROUP_UNIQUE_USERS", 0, 0, 0, ""), |
|
1044 |
Commands( "HEX", 0, 0, 0, ""), |
|
1045 |
Commands( "IFNULL", 0, 0, 0, ""), |
|
1046 |
Commands( "INSTR", 0, 0, 0, ""), |
|
1047 |
Commands( "INTERIORRINGN", 0, 0, 0, ""), |
|
1048 |
Commands( "INTERSECTS", 0, 0, 0, ""), |
|
1049 |
Commands( "ISCLOSED", 0, 0, 0, ""), |
|
1050 |
Commands( "ISEMPTY", 0, 0, 0, ""), |
|
1051 |
Commands( "ISNULL", 0, 0, 0, ""), |
|
1052 |
Commands( "IS_FREE_LOCK", 0, 0, 0, ""), |
|
1053 |
Commands( "IS_USED_LOCK", 0, 0, 0, ""), |
|
1054 |
Commands( "LAST_INSERT_ID", 0, 0, 0, ""), |
|
1055 |
Commands( "ISSIMPLE", 0, 0, 0, ""), |
|
1056 |
Commands( "LAST_DAY", 0, 0, 0, ""), |
|
1057 |
Commands( "LCASE", 0, 0, 0, ""), |
|
1058 |
Commands( "LEAST", 0, 0, 0, ""), |
|
1059 |
Commands( "LENGTH", 0, 0, 0, ""), |
|
1060 |
Commands( "LN", 0, 0, 0, ""), |
|
1061 |
Commands( "LOAD_FILE", 0, 0, 0, ""), |
|
1062 |
Commands( "LOCATE", 0, 0, 0, ""), |
|
1063 |
Commands( "LOG", 0, 0, 0, ""), |
|
1064 |
Commands( "LOG2", 0, 0, 0, ""), |
|
1065 |
Commands( "LOG10", 0, 0, 0, ""), |
|
1066 |
Commands( "LOWER", 0, 0, 0, ""), |
|
1067 |
Commands( "LPAD", 0, 0, 0, ""), |
|
1068 |
Commands( "LTRIM", 0, 0, 0, ""), |
|
1069 |
Commands( "MAKE_SET", 0, 0, 0, ""), |
|
1070 |
Commands( "MAKEDATE", 0, 0, 0, ""), |
|
1071 |
Commands( "MASTER_POS_WAIT", 0, 0, 0, ""), |
|
1072 |
Commands( "MAX", 0, 0, 0, ""), |
|
1073 |
Commands( "MBRCONTAINS", 0, 0, 0, ""), |
|
1074 |
Commands( "MBRDISJOINT", 0, 0, 0, ""), |
|
1075 |
Commands( "MBREQUAL", 0, 0, 0, ""), |
|
1076 |
Commands( "MBRINTERSECTS", 0, 0, 0, ""), |
|
1077 |
Commands( "MBROVERLAPS", 0, 0, 0, ""), |
|
1078 |
Commands( "MBRTOUCHES", 0, 0, 0, ""), |
|
1079 |
Commands( "MBRWITHIN", 0, 0, 0, ""), |
|
1080 |
Commands( "MD5", 0, 0, 0, ""), |
|
1081 |
Commands( "MID", 0, 0, 0, ""), |
|
1082 |
Commands( "MIN", 0, 0, 0, ""), |
|
1083 |
Commands( "MONTHNAME", 0, 0, 0, ""), |
|
1084 |
Commands( "NAME_CONST", 0, 0, 0, ""), |
|
1085 |
Commands( "NOW", 0, 0, 0, ""), |
|
1086 |
Commands( "NULLIF", 0, 0, 0, ""), |
|
1087 |
Commands( "NUMPOINTS", 0, 0, 0, ""), |
|
1088 |
Commands( "OCTET_LENGTH", 0, 0, 0, ""), |
|
1089 |
Commands( "OCT", 0, 0, 0, ""), |
|
1090 |
Commands( "ORD", 0, 0, 0, ""), |
|
1091 |
Commands( "OVERLAPS", 0, 0, 0, ""), |
|
1092 |
Commands( "PERIOD_ADD", 0, 0, 0, ""), |
|
1093 |
Commands( "PERIOD_DIFF", 0, 0, 0, ""), |
|
1094 |
Commands( "PI", 0, 0, 0, ""), |
|
1095 |
Commands( "POINTN", 0, 0, 0, ""), |
|
1096 |
Commands( "POSITION", 0, 0, 0, ""), |
|
1097 |
Commands( "POW", 0, 0, 0, ""), |
|
1098 |
Commands( "POWER", 0, 0, 0, ""), |
|
1099 |
Commands( "QUOTE", 0, 0, 0, ""), |
|
1100 |
Commands( "RADIANS", 0, 0, 0, ""), |
|
1101 |
Commands( "RAND", 0, 0, 0, ""), |
|
1102 |
Commands( "RELEASE_LOCK", 0, 0, 0, ""), |
|
1103 |
Commands( "REVERSE", 0, 0, 0, ""), |
|
1104 |
Commands( "ROUND", 0, 0, 0, ""), |
|
1105 |
Commands( "ROW_COUNT", 0, 0, 0, ""), |
|
1106 |
Commands( "RPAD", 0, 0, 0, ""), |
|
1107 |
Commands( "RTRIM", 0, 0, 0, ""), |
|
1108 |
Commands( "SESSION_USER", 0, 0, 0, ""), |
|
1109 |
Commands( "SUBDATE", 0, 0, 0, ""), |
|
1110 |
Commands( "SIGN", 0, 0, 0, ""), |
|
1111 |
Commands( "SIN", 0, 0, 0, ""), |
|
1112 |
Commands( "SHA", 0, 0, 0, ""), |
|
1113 |
Commands( "SHA1", 0, 0, 0, ""), |
|
1114 |
Commands( "SLEEP", 0, 0, 0, ""), |
|
1115 |
Commands( "SOUNDEX", 0, 0, 0, ""), |
|
1116 |
Commands( "SPACE", 0, 0, 0, ""), |
|
1117 |
Commands( "SQRT", 0, 0, 0, ""), |
|
1118 |
Commands( "SRID", 0, 0, 0, ""), |
|
1119 |
Commands( "STARTPOINT", 0, 0, 0, ""), |
|
1120 |
Commands( "STD", 0, 0, 0, ""), |
|
1121 |
Commands( "STDDEV", 0, 0, 0, ""), |
|
1122 |
Commands( "STDDEV_POP", 0, 0, 0, ""), |
|
1123 |
Commands( "STDDEV_SAMP", 0, 0, 0, ""), |
|
1124 |
Commands( "STR_TO_DATE", 0, 0, 0, ""), |
|
1125 |
Commands( "STRCMP", 0, 0, 0, ""), |
|
1126 |
Commands( "SUBSTR", 0, 0, 0, ""), |
|
1127 |
Commands( "SUBSTRING", 0, 0, 0, ""), |
|
1128 |
Commands( "SUBSTRING_INDEX", 0, 0, 0, ""), |
|
1129 |
Commands( "SUM", 0, 0, 0, ""), |
|
1130 |
Commands( "SYSDATE", 0, 0, 0, ""), |
|
1131 |
Commands( "SYSTEM_USER", 0, 0, 0, ""), |
|
1132 |
Commands( "TAN", 0, 0, 0, ""), |
|
1133 |
Commands( "TIME_FORMAT", 0, 0, 0, ""), |
|
1134 |
Commands( "TO_DAYS", 0, 0, 0, ""), |
|
1135 |
Commands( "TOUCHES", 0, 0, 0, ""), |
|
1136 |
Commands( "TRIM", 0, 0, 0, ""), |
|
1137 |
Commands( "UCASE", 0, 0, 0, ""), |
|
1138 |
Commands( "UNCOMPRESS", 0, 0, 0, ""), |
|
1139 |
Commands( "UNCOMPRESSED_LENGTH", 0, 0, 0, ""), |
|
1140 |
Commands( "UNHEX", 0, 0, 0, ""), |
|
1141 |
Commands( "UNIQUE_USERS", 0, 0, 0, ""), |
|
1142 |
Commands( "UNIX_TIMESTAMP", 0, 0, 0, ""), |
|
1143 |
Commands( "UPPER", 0, 0, 0, ""), |
|
1144 |
Commands( "UUID", 0, 0, 0, ""), |
|
1145 |
Commands( "VARIANCE", 0, 0, 0, ""), |
|
1146 |
Commands( "VAR_POP", 0, 0, 0, ""), |
|
1147 |
Commands( "VAR_SAMP", 0, 0, 0, ""), |
|
1148 |
Commands( "VERSION", 0, 0, 0, ""), |
|
1149 |
Commands( "WEEKDAY", 0, 0, 0, ""), |
|
1150 |
Commands( "WEEKOFYEAR", 0, 0, 0, ""), |
|
1151 |
Commands( "WITHIN", 0, 0, 0, ""), |
|
1152 |
Commands( "X", 0, 0, 0, ""), |
|
1153 |
Commands( "Y", 0, 0, 0, ""), |
|
1154 |
Commands( "YEARWEEK", 0, 0, 0, ""), |
|
1
by brian
clean slate |
1155 |
/* end sentinel */
|
1441.3.3
by Vijay Samuel
Changes made to the struct conversion |
1156 |
Commands((char *)NULL, 0, 0, 0, "") |
1
by brian
clean slate |
1157 |
};
|
1158 |
||
1159 |
||
77.3.18
by Monty Taylor
Merged in codestyle. |
1160 |
int history_length; |
1
by brian
clean slate |
1161 |
static int not_in_history(const char *line); |
1567.5.2
by Vijay Samuel
Merge OSX fix for client drizzle. |
1162 |
static void initialize_readline (char *name); |
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
1163 |
static void fix_history(string *final_command); |
1
by brian
clean slate |
1164 |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1165 |
static Commands *find_command(const char *name,char cmd_name); |
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
1166 |
static bool add_line(string *buffer,char *line,char *in_string, |
1
by brian
clean slate |
1167 |
bool *ml_comment); |
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
1168 |
static void remove_cntrl(string *buffer); |
928.1.1
by Eric Day
Started client changes. |
1169 |
static void print_table_data(drizzle_result_st *result); |
1170 |
static void print_tab_data(drizzle_result_st *result); |
|
1171 |
static void print_table_data_vertically(drizzle_result_st *result); |
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
1172 |
static void print_warnings(uint32_t error_code); |
2148.6.2
by Stewart Smith
use boost::posix_time::ptime instead of gettimeofday() to be a bit more portable |
1173 |
static boost::posix_time::ptime start_timer(void); |
1174 |
static void end_timer(boost::posix_time::ptime, string &buff); |
|
1175 |
static void drizzle_end_timer(boost::posix_time::ptime, string &buff); |
|
2148.6.3
by Stewart Smith
use boost time_duration to generate our nice query duration stsring instead of math on a double |
1176 |
static void nice_time(boost::posix_time::time_duration duration, string &buff); |
779.2.11
by Monty Taylor
General build cleanup - removed cruft, removed depreated checks. |
1177 |
extern "C" void drizzle_end(int sig); |
1178 |
extern "C" void handle_sigint(int sig); |
|
1
by brian
clean slate |
1179 |
#if defined(HAVE_TERMIOS_H) && defined(GWINSZ_IN_SYS_IOCTL)
|
779.2.11
by Monty Taylor
General build cleanup - removed cruft, removed depreated checks. |
1180 |
static void window_resize(int sig); |
1
by brian
clean slate |
1181 |
#endif
|
1182 |
||
973.1.2
by Toru Maesaka
Cosmetic fixes pointed out by Jay and added comments for doxygen |
1183 |
/**
|
1184 |
Shutdown the server that we are currently connected to.
|
|
1185 |
||
1186 |
@retval
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1187 |
true success
|
973.1.2
by Toru Maesaka
Cosmetic fixes pointed out by Jay and added comments for doxygen |
1188 |
@retval
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1189 |
false failure
|
973.1.2
by Toru Maesaka
Cosmetic fixes pointed out by Jay and added comments for doxygen |
1190 |
*/
|
973.1.1
by Toru Maesaka
Added server shutdown and ping functionalities to the drizzle client app |
1191 |
static bool server_shutdown(void) |
1192 |
{
|
|
1193 |
drizzle_result_st result; |
|
1194 |
drizzle_return_t ret; |
|
1195 |
||
1196 |
if (verbose) |
|
1197 |
{
|
|
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
1198 |
printf(_("shutting down drizzled")); |
973.1.1
by Toru Maesaka
Added server shutdown and ping functionalities to the drizzle client app |
1199 |
if (opt_drizzle_port > 0) |
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
1200 |
printf(_(" on port %d"), opt_drizzle_port); |
973.1.2
by Toru Maesaka
Cosmetic fixes pointed out by Jay and added comments for doxygen |
1201 |
printf("... "); |
973.1.1
by Toru Maesaka
Added server shutdown and ping functionalities to the drizzle client app |
1202 |
}
|
1203 |
||
1204 |
if (drizzle_shutdown(&con, &result, DRIZZLE_SHUTDOWN_DEFAULT, |
|
1205 |
&ret) == NULL || ret != DRIZZLE_RETURN_OK) |
|
1206 |
{
|
|
1207 |
if (ret == DRIZZLE_RETURN_ERROR_CODE) |
|
1208 |
{
|
|
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
1209 |
fprintf(stderr, _("shutdown failed; error: '%s'"), |
973.1.1
by Toru Maesaka
Added server shutdown and ping functionalities to the drizzle client app |
1210 |
drizzle_result_error(&result)); |
1211 |
drizzle_result_free(&result); |
|
1212 |
}
|
|
1213 |
else
|
|
1214 |
{
|
|
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
1215 |
fprintf(stderr, _("shutdown failed; error: '%s'"), |
973.1.1
by Toru Maesaka
Added server shutdown and ping functionalities to the drizzle client app |
1216 |
drizzle_con_error(&con)); |
1217 |
}
|
|
1218 |
return false; |
|
1219 |
}
|
|
1220 |
||
1221 |
drizzle_result_free(&result); |
|
1222 |
||
1223 |
if (verbose) |
|
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
1224 |
printf(_("done\n")); |
973.1.1
by Toru Maesaka
Added server shutdown and ping functionalities to the drizzle client app |
1225 |
|
1226 |
return true; |
|
1227 |
}
|
|
1228 |
||
2191.1.1
by Brian Aker
Add in KILL protocol support. |
1229 |
static bool kill_query(uint32_t query_id) |
1230 |
{
|
|
1231 |
drizzle_result_st result; |
|
1232 |
drizzle_return_t ret; |
|
1233 |
||
1234 |
if (verbose) |
|
1235 |
{
|
|
1236 |
printf(_("killing query %u"), query_id); |
|
1237 |
printf("... "); |
|
1238 |
}
|
|
1239 |
||
1240 |
if (drizzle_kill(&con, &result, query_id, |
|
1241 |
&ret) == NULL || ret != DRIZZLE_RETURN_OK) |
|
1242 |
{
|
|
1243 |
if (ret == DRIZZLE_RETURN_ERROR_CODE) |
|
1244 |
{
|
|
1245 |
fprintf(stderr, _("kill failed; error: '%s'"), |
|
1246 |
drizzle_result_error(&result)); |
|
1247 |
drizzle_result_free(&result); |
|
1248 |
}
|
|
1249 |
else
|
|
1250 |
{
|
|
1251 |
fprintf(stderr, _("kill failed; error: '%s'"), |
|
1252 |
drizzle_con_error(&con)); |
|
1253 |
}
|
|
1254 |
return false; |
|
1255 |
}
|
|
1256 |
||
1257 |
drizzle_result_free(&result); |
|
1258 |
||
1259 |
if (verbose) |
|
1260 |
printf(_("done\n")); |
|
1261 |
||
1262 |
return true; |
|
1263 |
}
|
|
1264 |
||
973.1.2
by Toru Maesaka
Cosmetic fixes pointed out by Jay and added comments for doxygen |
1265 |
/**
|
1266 |
Ping the server that we are currently connected to.
|
|
1267 |
||
1268 |
@retval
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1269 |
true success
|
973.1.2
by Toru Maesaka
Cosmetic fixes pointed out by Jay and added comments for doxygen |
1270 |
@retval
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1271 |
false failure
|
973.1.2
by Toru Maesaka
Cosmetic fixes pointed out by Jay and added comments for doxygen |
1272 |
*/
|
973.1.1
by Toru Maesaka
Added server shutdown and ping functionalities to the drizzle client app |
1273 |
static bool server_ping(void) |
1274 |
{
|
|
1275 |
drizzle_result_st result; |
|
1276 |
drizzle_return_t ret; |
|
1277 |
||
1278 |
if (drizzle_ping(&con, &result, &ret) != NULL && ret == DRIZZLE_RETURN_OK) |
|
1279 |
{
|
|
1280 |
if (opt_silent < 2) |
|
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
1281 |
printf(_("drizzled is alive\n")); |
973.1.1
by Toru Maesaka
Added server shutdown and ping functionalities to the drizzle client app |
1282 |
}
|
1283 |
else
|
|
1284 |
{
|
|
1285 |
if (ret == DRIZZLE_RETURN_ERROR_CODE) |
|
1286 |
{
|
|
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
1287 |
fprintf(stderr, _("ping failed; error: '%s'"), |
973.1.1
by Toru Maesaka
Added server shutdown and ping functionalities to the drizzle client app |
1288 |
drizzle_result_error(&result)); |
1289 |
drizzle_result_free(&result); |
|
1290 |
}
|
|
1291 |
else
|
|
1292 |
{
|
|
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
1293 |
fprintf(stderr, _("drizzled won't answer to ping, error: '%s'"), |
973.1.1
by Toru Maesaka
Added server shutdown and ping functionalities to the drizzle client app |
1294 |
drizzle_con_error(&con)); |
1295 |
}
|
|
1296 |
return false; |
|
1297 |
}
|
|
1298 |
drizzle_result_free(&result); |
|
1299 |
return true; |
|
1300 |
}
|
|
1301 |
||
973.1.2
by Toru Maesaka
Cosmetic fixes pointed out by Jay and added comments for doxygen |
1302 |
/**
|
1303 |
Execute command(s) specified by the user.
|
|
1304 |
||
1305 |
@param error error status of command execution.
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1306 |
If an error had occurred, this variable will be set
|
1307 |
to 1 whereas on success, it shall be set to 0. This
|
|
1308 |
value will be supplied to the exit() function used
|
|
1309 |
by the caller.
|
|
973.1.2
by Toru Maesaka
Cosmetic fixes pointed out by Jay and added comments for doxygen |
1310 |
|
1311 |
@retval
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1312 |
false no commands were executed
|
973.1.2
by Toru Maesaka
Cosmetic fixes pointed out by Jay and added comments for doxygen |
1313 |
@retval
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1314 |
true at least one command was executed
|
973.1.2
by Toru Maesaka
Cosmetic fixes pointed out by Jay and added comments for doxygen |
1315 |
*/
|
973.1.1
by Toru Maesaka
Added server shutdown and ping functionalities to the drizzle client app |
1316 |
static bool execute_commands(int *error) |
1317 |
{
|
|
1318 |
bool executed= false; |
|
1319 |
*error= 0; |
|
1320 |
||
1321 |
if (opt_ping) |
|
1322 |
{
|
|
973.1.2
by Toru Maesaka
Cosmetic fixes pointed out by Jay and added comments for doxygen |
1323 |
if (server_ping() == false) |
973.1.1
by Toru Maesaka
Added server shutdown and ping functionalities to the drizzle client app |
1324 |
*error= 1; |
1325 |
executed= true; |
|
1326 |
}
|
|
1327 |
||
1328 |
if (opt_shutdown) |
|
1329 |
{
|
|
973.1.2
by Toru Maesaka
Cosmetic fixes pointed out by Jay and added comments for doxygen |
1330 |
if (server_shutdown() == false) |
973.1.1
by Toru Maesaka
Added server shutdown and ping functionalities to the drizzle client app |
1331 |
*error= 1; |
1332 |
executed= true; |
|
1333 |
}
|
|
2191.1.1
by Brian Aker
Add in KILL protocol support. |
1334 |
|
1335 |
if (opt_kill) |
|
1336 |
{
|
|
1337 |
if (kill_query(opt_kill) == false) |
|
1338 |
{
|
|
1339 |
*error= 1; |
|
1340 |
}
|
|
1341 |
executed= true; |
|
1342 |
}
|
|
1343 |
||
973.1.1
by Toru Maesaka
Added server shutdown and ping functionalities to the drizzle client app |
1344 |
return executed; |
1345 |
}
|
|
1346 |
||
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1347 |
static void check_timeout_value(uint32_t in_connect_timeout) |
1348 |
{
|
|
1349 |
opt_connect_timeout= 0; |
|
1567.5.3
by Vijay Samuel
Merge patch for sql_connect() and style issue. |
1350 |
if (in_connect_timeout > 3600*12) |
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1351 |
{
|
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
1352 |
cout << _("Error: Invalid Value for connect_timeout"); |
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1353 |
exit(-1); |
1354 |
}
|
|
1355 |
opt_connect_timeout= in_connect_timeout; |
|
1356 |
}
|
|
1357 |
||
1358 |
static void check_max_input_line(uint32_t in_max_input_line) |
|
1359 |
{
|
|
1360 |
opt_max_input_line= 0; |
|
1700.1.1
by Vijay Samuel
Merge fix for block_size corrections in client applications. |
1361 |
if (in_max_input_line < 4096 || in_max_input_line > (int64_t)2*1024L*1024L*1024L) |
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1362 |
{
|
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
1363 |
cout << _("Error: Invalid Value for max_input_line"); |
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1364 |
exit(-1); |
1365 |
}
|
|
1700.1.1
by Vijay Samuel
Merge fix for block_size corrections in client applications. |
1366 |
opt_max_input_line= in_max_input_line - (in_max_input_line % 1024); |
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1367 |
}
|
1368 |
||
1
by brian
clean slate |
1369 |
int main(int argc,char *argv[]) |
1370 |
{
|
|
1567.3.5
by Vijay Samuel
Refactored client. |
1371 |
try
|
1372 |
{
|
|
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
1373 |
|
236.1.60
by Monty Taylor
Another stab at protecting NLS stuff. |
1374 |
#if defined(ENABLE_NLS)
|
1375 |
# if defined(HAVE_LOCALE_H)
|
|
202.3.2
by Monty Taylor
Added gettext calls in to my_getopt.c and drizzle.c |
1376 |
setlocale(LC_ALL, ""); |
236.1.60
by Monty Taylor
Another stab at protecting NLS stuff. |
1377 |
# endif
|
2068.4.1
by Andrew Hutchings
Fix intl domain |
1378 |
bindtextdomain("drizzle7", LOCALEDIR); |
1379 |
textdomain("drizzle7"); |
|
236.1.60
by Monty Taylor
Another stab at protecting NLS stuff. |
1380 |
#endif
|
1567.3.8
by Vijay Samuel
Refactor drizzle client. |
1381 |
|
2068.4.1
by Andrew Hutchings
Fix intl domain |
1382 |
po::options_description commandline_options(_("Options used only in command line")); |
1567.3.8
by Vijay Samuel
Refactor drizzle client. |
1383 |
commandline_options.add_options() |
2068.4.1
by Andrew Hutchings
Fix intl domain |
1384 |
("help,?",_("Displays this help and exit.")) |
1385 |
("batch,B",_("Don't use history file. Disable interactive behavior. (Enables --silent)")) |
|
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1386 |
("column-type-info", po::value<bool>(&column_types_flag)->default_value(false)->zero_tokens(), |
2068.4.1
by Andrew Hutchings
Fix intl domain |
1387 |
_("Display column type information.")) |
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1388 |
("comments,c", po::value<bool>(&preserve_comments)->default_value(false)->zero_tokens(), |
2068.4.1
by Andrew Hutchings
Fix intl domain |
1389 |
_("Preserve comments. Send comments to the server. The default is --skip-comments (discard comments), enable with --comments")) |
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1390 |
("vertical,E", po::value<bool>(&vertical)->default_value(false)->zero_tokens(), |
2068.4.1
by Andrew Hutchings
Fix intl domain |
1391 |
_("Print the output of a query (rows) vertically.")) |
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1392 |
("force,f", po::value<bool>(&ignore_errors)->default_value(false)->zero_tokens(), |
2068.4.1
by Andrew Hutchings
Fix intl domain |
1393 |
_("Continue even if we get an sql error.")) |
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1394 |
("named-commands,G", po::value<bool>(&named_cmds)->default_value(false)->zero_tokens(), |
2068.4.1
by Andrew Hutchings
Fix intl domain |
1395 |
_("Enable named commands. Named commands mean this program's internal commands; see drizzle> help . When enabled, the named commands can be used from any line of the query, otherwise only from the first line, before an enter.")) |
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1396 |
("no-beep,b", po::value<bool>(&opt_nobeep)->default_value(false)->zero_tokens(), |
2068.4.1
by Andrew Hutchings
Fix intl domain |
1397 |
_("Turn off beep on error.")) |
1398 |
("disable-line-numbers", _("Do not write line numbers for errors.")) |
|
1399 |
("disable-column-names", _("Do not write column names in results.")) |
|
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1400 |
("skip-column-names,N", |
2068.4.1
by Andrew Hutchings
Fix intl domain |
1401 |
_("Don't write column names in results. WARNING: -N is deprecated, use long version of this options instead.")) |
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1402 |
("set-variable,O", po::value<string>(), |
2068.4.1
by Andrew Hutchings
Fix intl domain |
1403 |
_("Change the value of a variable. Please note that this option is deprecated; you can set variables directly with --variable-name=value.")) |
1567.3.8
by Vijay Samuel
Refactor drizzle client. |
1404 |
("table,t", po::value<bool>(&output_tables)->default_value(false)->zero_tokens(), |
2068.4.1
by Andrew Hutchings
Fix intl domain |
1405 |
_("Output in table format.")) |
1757.5.1
by Andrew Hutchings
Rework the boolean options so that true-by-default options change to --disable-option. |
1406 |
("safe-updates,U", po::value<bool>(&safe_updates)->default_value(false)->zero_tokens(), |
2068.4.1
by Andrew Hutchings
Fix intl domain |
1407 |
_("Only allow UPDATE and DELETE that uses keys.")) |
1757.5.1
by Andrew Hutchings
Rework the boolean options so that true-by-default options change to --disable-option. |
1408 |
("i-am-a-dummy,U", po::value<bool>(&safe_updates)->default_value(false)->zero_tokens(), |
2068.4.1
by Andrew Hutchings
Fix intl domain |
1409 |
_("Synonym for option --safe-updates, -U.")) |
1923.3.4
by Andrew Hutchings
Revert -v fix |
1410 |
("verbose,v", po::value<string>(&opt_verbose)->default_value(""), |
2068.4.1
by Andrew Hutchings
Fix intl domain |
1411 |
_("-v vvv implies that verbose= 3, Used to specify verbose")) |
1412 |
("version,V", _("Output version information and exit.")) |
|
1567.3.8
by Vijay Samuel
Refactor drizzle client. |
1413 |
("secure-auth", po::value<bool>(&opt_secure_auth)->default_value(false)->zero_tokens(), |
2068.4.1
by Andrew Hutchings
Fix intl domain |
1414 |
_("Refuse client connecting to server if it uses old (pre-4.1.1) protocol")) |
1567.3.8
by Vijay Samuel
Refactor drizzle client. |
1415 |
("show-warnings", po::value<bool>(&show_warnings)->default_value(false)->zero_tokens(), |
2068.4.1
by Andrew Hutchings
Fix intl domain |
1416 |
_("Show warnings after every statement.")) |
1567.3.8
by Vijay Samuel
Refactor drizzle client. |
1417 |
("show-progress-size", po::value<uint32_t>(&show_progress_size)->default_value(0), |
2068.4.1
by Andrew Hutchings
Fix intl domain |
1418 |
_("Number of lines before each import progress report.")) |
1567.3.8
by Vijay Samuel
Refactor drizzle client. |
1419 |
("ping", po::value<bool>(&opt_ping)->default_value(false)->zero_tokens(), |
2068.4.1
by Andrew Hutchings
Fix intl domain |
1420 |
_("Ping the server to check if it's alive.")) |
1567.3.10
by Vijay Samuel
Client refactored completely using boost::program_options. |
1421 |
("no-defaults", po::value<bool>()->default_value(false)->zero_tokens(), |
2068.4.1
by Andrew Hutchings
Fix intl domain |
1422 |
_("Configuration file defaults are not used if no-defaults is set")) |
1567.3.8
by Vijay Samuel
Refactor drizzle client. |
1423 |
;
|
1424 |
||
2068.4.1
by Andrew Hutchings
Fix intl domain |
1425 |
po::options_description drizzle_options(_("Options specific to the drizzle client")); |
1567.3.8
by Vijay Samuel
Refactor drizzle client. |
1426 |
drizzle_options.add_options() |
1802.13.1
by Andrew Hutchings
Fix -A option in drizzle client |
1427 |
("disable-auto-rehash,A", |
2068.4.1
by Andrew Hutchings
Fix intl domain |
1428 |
_("Disable automatic rehashing. One doesn't need to use 'rehash' to get table and field completion, but startup and reconnecting may take a longer time.")) |
1567.3.8
by Vijay Samuel
Refactor drizzle client. |
1429 |
("auto-vertical-output", po::value<bool>(&auto_vertical_output)->default_value(false)->zero_tokens(), |
2068.4.1
by Andrew Hutchings
Fix intl domain |
1430 |
_("Automatically switch to vertical output mode if the result is wider than the terminal width.")) |
1567.3.31
by Monty Taylor
The default value for database should not be "test". |
1431 |
("database,D", po::value<string>(¤t_db)->default_value(""), |
2068.4.1
by Andrew Hutchings
Fix intl domain |
1432 |
_("Database to use.")) |
1567.3.8
by Vijay Samuel
Refactor drizzle client. |
1433 |
("default-character-set",po::value<string>(), |
2068.4.1
by Andrew Hutchings
Fix intl domain |
1434 |
_("(not used)")) |
1567.3.8
by Vijay Samuel
Refactor drizzle client. |
1435 |
("delimiter", po::value<string>(&delimiter_str)->default_value(";"), |
2068.4.1
by Andrew Hutchings
Fix intl domain |
1436 |
_("Delimiter to be used.")) |
1567.3.8
by Vijay Samuel
Refactor drizzle client. |
1437 |
("execute,e", po::value<string>(), |
2068.4.1
by Andrew Hutchings
Fix intl domain |
1438 |
_("Execute command and quit. (Disables --force and history file)")) |
1567.3.8
by Vijay Samuel
Refactor drizzle client. |
1439 |
("local-infile", po::value<bool>(&opt_local_infile)->default_value(false)->zero_tokens(), |
2068.4.1
by Andrew Hutchings
Fix intl domain |
1440 |
_("Enable LOAD DATA LOCAL INFILE.")) |
1567.3.8
by Vijay Samuel
Refactor drizzle client. |
1441 |
("unbuffered,n", po::value<bool>(&unbuffered)->default_value(false)->zero_tokens(), |
2068.4.1
by Andrew Hutchings
Fix intl domain |
1442 |
_("Flush buffer after each query.")) |
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1443 |
("sigint-ignore", po::value<bool>(&opt_sigint_ignore)->default_value(false)->zero_tokens(), |
2068.4.1
by Andrew Hutchings
Fix intl domain |
1444 |
_("Ignore SIGINT (CTRL-C)")) |
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1445 |
("one-database,o", po::value<bool>(&one_database)->default_value(false)->zero_tokens(), |
2068.4.1
by Andrew Hutchings
Fix intl domain |
1446 |
_("Only update the default database. This is useful for skipping updates to other database in the update log.")) |
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1447 |
("pager", po::value<string>(), |
2068.4.1
by Andrew Hutchings
Fix intl domain |
1448 |
_("Pager to use to display results. If you don't supply an option the default pager is taken from your ENV variable PAGER. Valid pagers are less, more, cat [> filename], etc. See interactive help (\\h) also. This option does not work in batch mode. Disable with --disable-pager. This option is disabled by default.")) |
1567.4.2
by Jay Pipes
Some style fixes and removal of deprecated stuff... |
1449 |
("disable-pager", po::value<bool>(&opt_nopager)->default_value(false)->zero_tokens(), |
2068.4.1
by Andrew Hutchings
Fix intl domain |
1450 |
_("Disable pager and print to stdout. See interactive help (\\h) also.")) |
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1451 |
("prompt", po::value<string>(¤t_prompt)->default_value(""), |
2068.4.1
by Andrew Hutchings
Fix intl domain |
1452 |
_("Set the drizzle prompt to this value.")) |
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1453 |
("quick,q", po::value<bool>(&quick)->default_value(false)->zero_tokens(), |
2068.4.1
by Andrew Hutchings
Fix intl domain |
1454 |
_("Don't cache result, print it row by row. This may slow down the server if the output is suspended. Doesn't use history file.")) |
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1455 |
("raw,r", po::value<bool>(&opt_raw_data)->default_value(false)->zero_tokens(), |
2068.4.1
by Andrew Hutchings
Fix intl domain |
1456 |
_("Write fields without conversion. Used with --batch.")) |
1457 |
("disable-reconnect", _("Do not reconnect if the connection is lost.")) |
|
1810.3.1
by Andrew Hutchings
Don't do completion hash rebuild on --shutdown |
1458 |
("shutdown", po::value<bool>()->zero_tokens(), |
2068.4.1
by Andrew Hutchings
Fix intl domain |
1459 |
_("Shutdown the server")) |
1460 |
("silent,s", _("Be more silent. Print results with a tab as separator, each row on new line.")) |
|
2191.1.1
by Brian Aker
Add in KILL protocol support. |
1461 |
("kill", po::value<uint32_t>(&opt_kill)->default_value(0), |
1462 |
_("Kill a running query.")) |
|
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1463 |
("tee", po::value<string>(), |
2068.4.1
by Andrew Hutchings
Fix intl domain |
1464 |
_("Append everything into outfile. See interactive help (\\h) also. Does not work in batch mode. Disable with --disable-tee. This option is disabled by default.")) |
1567.4.2
by Jay Pipes
Some style fixes and removal of deprecated stuff... |
1465 |
("disable-tee", po::value<bool>()->default_value(false)->zero_tokens(), |
2068.4.1
by Andrew Hutchings
Fix intl domain |
1466 |
_("Disable outfile. See interactive help (\\h) also.")) |
1921.2.1
by Andrew Hutchings
Fix some drizzle client options that were still using '_' instead of '-' |
1467 |
("connect-timeout", po::value<uint32_t>(&opt_connect_timeout)->default_value(0)->notifier(&check_timeout_value), |
2068.4.1
by Andrew Hutchings
Fix intl domain |
1468 |
_("Number of seconds before connection timeout.")) |
1921.2.1
by Andrew Hutchings
Fix some drizzle client options that were still using '_' instead of '-' |
1469 |
("max-input-line", po::value<uint32_t>(&opt_max_input_line)->default_value(16*1024L*1024L)->notifier(&check_max_input_line), |
2068.4.1
by Andrew Hutchings
Fix intl domain |
1470 |
_("Max length of input line")) |
1921.2.1
by Andrew Hutchings
Fix some drizzle client options that were still using '_' instead of '-' |
1471 |
("select-limit", po::value<uint32_t>(&select_limit)->default_value(1000L), |
2068.4.1
by Andrew Hutchings
Fix intl domain |
1472 |
_("Automatic limit for SELECT when using --safe-updates")) |
1921.2.1
by Andrew Hutchings
Fix some drizzle client options that were still using '_' instead of '-' |
1473 |
("max-join-size", po::value<uint32_t>(&max_join_size)->default_value(1000000L), |
2068.4.1
by Andrew Hutchings
Fix intl domain |
1474 |
_("Automatic limit for rows in a join when using --safe-updates")) |
1567.3.8
by Vijay Samuel
Refactor drizzle client. |
1475 |
;
|
2216.2.1
by Andrew Hutchings
Use current unix username as login by default for our client apps |
1476 |
#ifndef DRIZZLE_ADMIN_TOOL
|
1477 |
const char* unix_user= getlogin(); |
|
1478 |
#endif
|
|
2068.4.1
by Andrew Hutchings
Fix intl domain |
1479 |
po::options_description client_options(_("Options specific to the client")); |
1567.3.8
by Vijay Samuel
Refactor drizzle client. |
1480 |
client_options.add_options() |
1481 |
("host,h", po::value<string>(¤t_host)->default_value("localhost"), |
|
2068.4.1
by Andrew Hutchings
Fix intl domain |
1482 |
_("Connect to host")) |
1567.6.1
by Monty Taylor
Replaced the snowman sentinel with a series of nulls. As it is physically |
1483 |
("password,P", po::value<string>(¤t_password)->default_value(PASSWORD_SENTINEL), |
2068.4.1
by Andrew Hutchings
Fix intl domain |
1484 |
_("Password to use when connecting to server. If password is not given it's asked from the tty.")) |
1567.3.30
by Monty Taylor
Remove special behavior of 0. |
1485 |
("port,p", po::value<uint32_t>()->default_value(0), |
2068.4.1
by Andrew Hutchings
Fix intl domain |
1486 |
_("Port number to use for connection or 0 for default to, in order of preference, drizzle.cnf, $DRIZZLE_TCP_PORT, built-in default")) |
1960.2.8
by Andrew Hutchings
Modify dtr to cope with drizzleadmin and create test case |
1487 |
#ifdef DRIZZLE_ADMIN_TOOL
|
1488 |
("user,u", po::value<string>(¤t_user)->default_value("root"), |
|
1489 |
#else
|
|
2216.2.1
by Andrew Hutchings
Use current unix username as login by default for our client apps |
1490 |
("user,u", po::value<string>(¤t_user)->default_value((unix_user ? unix_user : "")), |
1960.2.8
by Andrew Hutchings
Modify dtr to cope with drizzleadmin and create test case |
1491 |
#endif
|
2068.4.1
by Andrew Hutchings
Fix intl domain |
1492 |
_("User for login if not current user.")) |
1745.2.1
by LinuxJedi
Remove the --mysql option and convert the --protocol option to do something similar. |
1493 |
("protocol",po::value<string>(&opt_protocol)->default_value("mysql"), |
2203.2.2
by Brian Aker
First pass through in going over work for MySQL AUTH PLUGIN style support. |
1494 |
_("The protocol of connection (mysql, mysql-plugin-auth, or drizzle).")) |
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1495 |
;
|
1496 |
||
2068.4.1
by Andrew Hutchings
Fix intl domain |
1497 |
po::options_description long_options(_("Allowed Options")); |
1567.3.8
by Vijay Samuel
Refactor drizzle client. |
1498 |
long_options.add(commandline_options).add(drizzle_options).add(client_options); |
1499 |
||
1500 |
std::string system_config_dir_drizzle(SYSCONFDIR); |
|
1501 |
system_config_dir_drizzle.append("/drizzle/drizzle.cnf"); |
|
1502 |
||
1503 |
std::string system_config_dir_client(SYSCONFDIR); |
|
1504 |
system_config_dir_client.append("/drizzle/client.cnf"); |
|
202.3.2
by Monty Taylor
Added gettext calls in to my_getopt.c and drizzle.c |
1505 |
|
1671.2.1
by Vijay Samuel
Merge new user config file processing system. |
1506 |
std::string user_config_dir((getenv("XDG_CONFIG_HOME")? getenv("XDG_CONFIG_HOME"):"~/.config")); |
1921.3.1
by Andrew Hutchings
Using '~' to represent home is a shell standard, POSIX functions do not understand it. So for home config file loading substitute it for env variable $HOME if possible (also a POSIX standard) |
1507 |
|
1508 |
if (user_config_dir.compare(0, 2, "~/") == 0) |
|
1509 |
{
|
|
1510 |
char *homedir; |
|
1511 |
homedir= getenv("HOME"); |
|
1512 |
if (homedir != NULL) |
|
1513 |
user_config_dir.replace(0, 1, homedir); |
|
1514 |
}
|
|
1515 |
||
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1516 |
po::variables_map vm; |
1567.3.9
by Vijay Samuel
Client refactored. |
1517 |
|
1596.1.1
by Monty Taylor
Merged in remove-internal-from-drizzle-cc |
1518 |
po::positional_options_description p; |
1608.5.1
by Vijay Samuel
Merge refactor drizzletest |
1519 |
p.add("database", 1); |
1596.1.1
by Monty Taylor
Merged in remove-internal-from-drizzle-cc |
1520 |
|
1793.3.1
by Andrew Hutchings
Disable boost:po allow_guessing which was making some wrong assumptions |
1521 |
// Disable allow_guessing
|
1522 |
int style = po::command_line_style::default_style & ~po::command_line_style::allow_guessing; |
|
1523 |
||
1596.1.1
by Monty Taylor
Merged in remove-internal-from-drizzle-cc |
1524 |
po::store(po::command_line_parser(argc, argv).options(long_options). |
1793.3.1
by Andrew Hutchings
Disable boost:po allow_guessing which was making some wrong assumptions |
1525 |
style(style).positional(p).extra_parser(parse_password_arg).run(), |
1526 |
vm); |
|
1567.3.8
by Vijay Samuel
Refactor drizzle client. |
1527 |
|
1567.5.3
by Vijay Samuel
Merge patch for sql_connect() and style issue. |
1528 |
if (! vm["no-defaults"].as<bool>()) |
1567.3.10
by Vijay Samuel
Client refactored completely using boost::program_options. |
1529 |
{
|
1671.2.1
by Vijay Samuel
Merge new user config file processing system. |
1530 |
std::string user_config_dir_drizzle(user_config_dir); |
1531 |
user_config_dir_drizzle.append("/drizzle/drizzle.cnf"); |
|
1532 |
||
1533 |
std::string user_config_dir_client(user_config_dir); |
|
1534 |
user_config_dir_client.append("/drizzle/client.cnf"); |
|
1535 |
||
1536 |
ifstream user_drizzle_ifs(user_config_dir_drizzle.c_str()); |
|
1815.1.1
by Monty Taylor
Embed a modified version of parse_config_file. There are several more bugs |
1537 |
po::store(dpo::parse_config_file(user_drizzle_ifs, drizzle_options), vm); |
1671.2.1
by Vijay Samuel
Merge new user config file processing system. |
1538 |
|
1539 |
ifstream user_client_ifs(user_config_dir_client.c_str()); |
|
1815.1.1
by Monty Taylor
Embed a modified version of parse_config_file. There are several more bugs |
1540 |
po::store(dpo::parse_config_file(user_client_ifs, client_options), vm); |
1671.2.1
by Vijay Samuel
Merge new user config file processing system. |
1541 |
|
1567.3.11
by Vijay Samuel
Client completely refactored using boost::program_options. |
1542 |
ifstream system_drizzle_ifs(system_config_dir_drizzle.c_str()); |
1815.1.1
by Monty Taylor
Embed a modified version of parse_config_file. There are several more bugs |
1543 |
store(dpo::parse_config_file(system_drizzle_ifs, drizzle_options), vm); |
1567.3.8
by Vijay Samuel
Refactor drizzle client. |
1544 |
|
1567.3.11
by Vijay Samuel
Client completely refactored using boost::program_options. |
1545 |
ifstream system_client_ifs(system_config_dir_client.c_str()); |
1815.1.1
by Monty Taylor
Embed a modified version of parse_config_file. There are several more bugs |
1546 |
po::store(dpo::parse_config_file(system_client_ifs, client_options), vm); |
1567.3.10
by Vijay Samuel
Client refactored completely using boost::program_options. |
1547 |
}
|
1567.3.8
by Vijay Samuel
Refactor drizzle client. |
1548 |
|
1567.3.5
by Vijay Samuel
Refactored client. |
1549 |
po::notify(vm); |
1567.3.8
by Vijay Samuel
Refactor drizzle client. |
1550 |
|
1960.2.7
by Andrew Hutchings
Drop the drizzleadmin client and use ifdef instead |
1551 |
#ifdef DRIZZLE_ADMIN_TOOL
|
1552 |
default_prompt= strdup(getenv("DRIZZLE_PS1") ? |
|
1553 |
getenv("DRIZZLE_PS1") : |
|
1554 |
"drizzleadmin> "); |
|
1555 |
#else
|
|
1567.5.1
by Vijay Samuel
Client drizzle final version with all changes. |
1556 |
default_prompt= strdup(getenv("DRIZZLE_PS1") ? |
1557 |
getenv("DRIZZLE_PS1") : |
|
1558 |
"drizzle> "); |
|
1960.2.7
by Andrew Hutchings
Drop the drizzleadmin client and use ifdef instead |
1559 |
#endif
|
656.1.51
by Monty Taylor
Fixed strdup return checking in client/ |
1560 |
if (default_prompt == NULL) |
1561 |
{
|
|
1562 |
fprintf(stderr, _("Memory allocation error while constructing initial " |
|
1563 |
"prompt. Aborting.\n")); |
|
1564 |
exit(ENOMEM); |
|
1565 |
}
|
|
2155.5.1
by Stewart Smith
drizzle command line client wasn't respecting --prompt cmd line parameter. |
1566 |
|
1567 |
if (current_prompt.empty()) |
|
1568 |
current_prompt= strdup(default_prompt); |
|
1569 |
||
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1570 |
if (current_prompt.empty()) |
656.1.51
by Monty Taylor
Fixed strdup return checking in client/ |
1571 |
{
|
1572 |
fprintf(stderr, _("Memory allocation error while constructing initial " |
|
1573 |
"prompt. Aborting.\n")); |
|
1574 |
exit(ENOMEM); |
|
1575 |
}
|
|
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
1576 |
processed_prompt= new string(); |
287.3.22
by Monty Taylor
Fixed typo. |
1577 |
processed_prompt->reserve(32); |
182.1.2
by Jim Winstead
Various fixes to enable compilation on Mac OS X, and remove the glib dependency. |
1578 |
|
1
by brian
clean slate |
1579 |
prompt_counter=0; |
1580 |
||
1567.3.17
by Monty Taylor
Removed more C-string strings. replaced with std::string. |
1581 |
outfile.clear(); // no (default) outfile |
1582 |
pager.assign("stdout"); // the default, if --pager wasn't given |
|
1
by brian
clean slate |
1583 |
{
|
1567.3.17
by Monty Taylor
Removed more C-string strings. replaced with std::string. |
1584 |
const char *tmp= getenv("PAGER"); |
1
by brian
clean slate |
1585 |
if (tmp && strlen(tmp)) |
1586 |
{
|
|
1587 |
default_pager_set= 1; |
|
1567.3.17
by Monty Taylor
Removed more C-string strings. replaced with std::string. |
1588 |
default_pager.assign(tmp); |
1
by brian
clean slate |
1589 |
}
|
1590 |
}
|
|
1567.4.2
by Jay Pipes
Some style fixes and removal of deprecated stuff... |
1591 |
if (! isatty(0) || ! isatty(1)) |
1
by brian
clean slate |
1592 |
{
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1593 |
status.setBatch(1); opt_silent=1; |
1
by brian
clean slate |
1594 |
}
|
1595 |
else
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1596 |
status.setAddToHistory(1); |
1597 |
status.setExitStatus(1); |
|
1
by brian
clean slate |
1598 |
|
1599 |
{
|
|
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
1600 |
/*
|
1601 |
The file descriptor-layer may be out-of-sync with the file-number layer,
|
|
1602 |
so we make sure that "stdout" is really open. If its file is closed then
|
|
1603 |
explicitly close the FD layer.
|
|
1
by brian
clean slate |
1604 |
*/
|
1605 |
int stdout_fileno_copy; |
|
1606 |
stdout_fileno_copy= dup(fileno(stdout)); /* Okay if fileno fails. */ |
|
1607 |
if (stdout_fileno_copy == -1) |
|
1608 |
fclose(stdout); |
|
1609 |
else
|
|
1610 |
close(stdout_fileno_copy); /* Clean up dup(). */ |
|
1611 |
}
|
|
1612 |
||
1757.5.1
by Andrew Hutchings
Rework the boolean options so that true-by-default options change to --disable-option. |
1613 |
/* Inverted Booleans */
|
1614 |
||
2252.1.28
by Olaf van der Spek
Refactor Program Options usage |
1615 |
line_numbers= not vm.count("disable-line-numbers"); |
1616 |
column_names= not vm.count("disable-column-names"); |
|
1617 |
opt_rehash= not vm.count("disable-auto-rehash"); |
|
1618 |
opt_reconnect= not vm.count("disable-reconnect"); |
|
1757.5.1
by Andrew Hutchings
Rework the boolean options so that true-by-default options change to --disable-option. |
1619 |
|
1810.3.1
by Andrew Hutchings
Don't do completion hash rebuild on --shutdown |
1620 |
/* Don't rehash with --shutdown */
|
1621 |
if (vm.count("shutdown")) |
|
1622 |
{
|
|
1623 |
opt_rehash= false; |
|
1624 |
opt_shutdown= true; |
|
1625 |
}
|
|
1626 |
||
1567.4.2
by Jay Pipes
Some style fixes and removal of deprecated stuff... |
1627 |
if (vm.count("delimiter")) |
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1628 |
{
|
1629 |
/* Check that delimiter does not contain a backslash */
|
|
1567.4.2
by Jay Pipes
Some style fixes and removal of deprecated stuff... |
1630 |
if (! strstr(delimiter_str.c_str(), "\\")) |
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1631 |
{
|
1632 |
delimiter= (char *)delimiter_str.c_str(); |
|
1633 |
}
|
|
1634 |
else
|
|
1635 |
{
|
|
1636 |
put_info(_("DELIMITER cannot contain a backslash character"), |
|
1637 |
INFO_ERROR,0,0); |
|
1567.3.4
by Vijay Samuel
Refactored drizzle client. |
1638 |
exit(-1); |
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1639 |
}
|
1640 |
||
1641 |
delimiter_length= (uint32_t)strlen(delimiter); |
|
1642 |
}
|
|
1567.4.2
by Jay Pipes
Some style fixes and removal of deprecated stuff... |
1643 |
if (vm.count("tee")) |
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1644 |
{
|
1645 |
if (vm["tee"].as<string>().empty()) |
|
1646 |
{
|
|
1647 |
if (opt_outfile) |
|
1648 |
end_tee(); |
|
1649 |
}
|
|
1650 |
else
|
|
1651 |
init_tee(vm["tee"].as<string>().c_str()); |
|
1652 |
}
|
|
1567.4.2
by Jay Pipes
Some style fixes and removal of deprecated stuff... |
1653 |
if (vm["disable-tee"].as<bool>() == true) |
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1654 |
{
|
1655 |
if (opt_outfile) |
|
1656 |
end_tee(); |
|
1657 |
}
|
|
1567.4.2
by Jay Pipes
Some style fixes and removal of deprecated stuff... |
1658 |
if (vm.count("pager")) |
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1659 |
{
|
1660 |
if (vm["pager"].as<string>().empty()) |
|
1661 |
opt_nopager= 1; |
|
1662 |
else
|
|
1663 |
{
|
|
1664 |
opt_nopager= 0; |
|
1665 |
if (vm[pager].as<string>().length()) |
|
1666 |
{
|
|
1667 |
default_pager_set= 1; |
|
1567.3.17
by Monty Taylor
Removed more C-string strings. replaced with std::string. |
1668 |
pager.assign(vm["pager"].as<string>()); |
1669 |
default_pager.assign(pager); |
|
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1670 |
}
|
1671 |
else if (default_pager_set) |
|
1567.3.17
by Monty Taylor
Removed more C-string strings. replaced with std::string. |
1672 |
pager.assign(default_pager); |
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1673 |
else
|
1674 |
opt_nopager= 1; |
|
1675 |
}
|
|
1676 |
}
|
|
1567.4.2
by Jay Pipes
Some style fixes and removal of deprecated stuff... |
1677 |
if (vm.count("disable-pager")) |
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1678 |
{
|
1679 |
opt_nopager= 1; |
|
1680 |
}
|
|
1681 |
||
1567.4.2
by Jay Pipes
Some style fixes and removal of deprecated stuff... |
1682 |
if (vm.count("no-auto-rehash")) |
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1683 |
opt_rehash= 0; |
1684 |
||
1567.4.2
by Jay Pipes
Some style fixes and removal of deprecated stuff... |
1685 |
if (vm.count("skip-column-names")) |
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1686 |
column_names= 0; |
1687 |
||
1567.4.2
by Jay Pipes
Some style fixes and removal of deprecated stuff... |
1688 |
if (vm.count("execute")) |
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1689 |
{
|
1690 |
status.setBatch(1); |
|
1691 |
status.setAddToHistory(1); |
|
1692 |
if (status.getLineBuff() == NULL) |
|
1693 |
status.setLineBuff(opt_max_input_line,NULL); |
|
1694 |
if (status.getLineBuff() == NULL) |
|
1695 |
{
|
|
1696 |
exit(1); |
|
1697 |
}
|
|
1698 |
status.getLineBuff()->addString(vm["execute"].as<string>().c_str()); |
|
1699 |
}
|
|
1700 |
||
1701 |
if (one_database) |
|
1702 |
skip_updates= true; |
|
1745.2.1
by LinuxJedi
Remove the --mysql option and convert the --protocol option to do something similar. |
1703 |
|
1704 |
if (vm.count("protocol")) |
|
1705 |
{
|
|
1706 |
std::transform(opt_protocol.begin(), opt_protocol.end(), |
|
1707 |
opt_protocol.begin(), ::tolower); |
|
1708 |
||
1709 |
if (not opt_protocol.compare("mysql")) |
|
2203.2.2
by Brian Aker
First pass through in going over work for MySQL AUTH PLUGIN style support. |
1710 |
{
|
1711 |
||
1712 |
global_con_options= (drizzle_con_options_t)(DRIZZLE_CON_MYSQL|DRIZZLE_CON_INTERACTIVE); |
|
1713 |
use_drizzle_protocol= false; |
|
1714 |
}
|
|
1715 |
else if (not opt_protocol.compare("mysql-plugin-auth")) |
|
1716 |
{
|
|
1717 |
global_con_options= (drizzle_con_options_t)(DRIZZLE_CON_MYSQL|DRIZZLE_CON_INTERACTIVE|DRIZZLE_CON_AUTH_PLUGIN); |
|
1718 |
use_drizzle_protocol= false; |
|
1719 |
}
|
|
1745.2.1
by LinuxJedi
Remove the --mysql option and convert the --protocol option to do something similar. |
1720 |
else if (not opt_protocol.compare("drizzle")) |
2203.2.2
by Brian Aker
First pass through in going over work for MySQL AUTH PLUGIN style support. |
1721 |
{
|
1722 |
global_con_options= (drizzle_con_options_t)(DRIZZLE_CON_EXPERIMENTAL); |
|
1723 |
use_drizzle_protocol= true; |
|
1724 |
}
|
|
1745.2.1
by LinuxJedi
Remove the --mysql option and convert the --protocol option to do something similar. |
1725 |
else
|
1726 |
{
|
|
1727 |
cout << _("Error: Unknown protocol") << " '" << opt_protocol << "'" << endl; |
|
1728 |
exit(-1); |
|
1729 |
}
|
|
1730 |
}
|
|
1731 |
||
1567.4.2
by Jay Pipes
Some style fixes and removal of deprecated stuff... |
1732 |
if (vm.count("port")) |
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1733 |
{
|
1567.4.2
by Jay Pipes
Some style fixes and removal of deprecated stuff... |
1734 |
opt_drizzle_port= vm["port"].as<uint32_t>(); |
1735 |
||
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1736 |
/* If the port number is > 65535 it is not a valid port
|
1737 |
This also helps with potential data loss casting unsigned long to a
|
|
1738 |
uint32_t. */
|
|
1567.3.30
by Monty Taylor
Remove special behavior of 0. |
1739 |
if (opt_drizzle_port > 65535) |
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1740 |
{
|
1567.4.2
by Jay Pipes
Some style fixes and removal of deprecated stuff... |
1741 |
printf(_("Error: Value of %" PRIu32 " supplied for port is not valid.\n"), opt_drizzle_port); |
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1742 |
exit(-1); |
1743 |
}
|
|
1567.4.2
by Jay Pipes
Some style fixes and removal of deprecated stuff... |
1744 |
}
|
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1745 |
|
1567.4.2
by Jay Pipes
Some style fixes and removal of deprecated stuff... |
1746 |
if (vm.count("password")) |
1747 |
{
|
|
1567.3.3
by Vijay Samuel
Client refactored. |
1748 |
if (!opt_password.empty()) |
1749 |
opt_password.erase(); |
|
1567.6.1
by Monty Taylor
Replaced the snowman sentinel with a series of nulls. As it is physically |
1750 |
if (current_password == PASSWORD_SENTINEL) |
1751 |
{
|
|
1567.3.5
by Vijay Samuel
Refactored client. |
1752 |
opt_password= ""; |
1567.6.1
by Monty Taylor
Replaced the snowman sentinel with a series of nulls. As it is physically |
1753 |
}
|
1567.3.5
by Vijay Samuel
Refactored client. |
1754 |
else
|
1567.6.1
by Monty Taylor
Replaced the snowman sentinel with a series of nulls. As it is physically |
1755 |
{
|
1567.3.5
by Vijay Samuel
Refactored client. |
1756 |
opt_password= current_password; |
1567.6.1
by Monty Taylor
Replaced the snowman sentinel with a series of nulls. As it is physically |
1757 |
tty_password= false; |
1758 |
}
|
|
1567.3.3
by Vijay Samuel
Client refactored. |
1759 |
}
|
1760 |
else
|
|
1761 |
{
|
|
1567.6.1
by Monty Taylor
Replaced the snowman sentinel with a series of nulls. As it is physically |
1762 |
tty_password= true; |
1567.3.3
by Vijay Samuel
Client refactored. |
1763 |
}
|
1764 |
||
1923.3.4
by Andrew Hutchings
Revert -v fix |
1765 |
|
1766 |
if (!opt_verbose.empty()) |
|
1767 |
{
|
|
1768 |
verbose= opt_verbose.length(); |
|
1769 |
}
|
|
1770 |
||
1567.5.3
by Vijay Samuel
Merge patch for sql_connect() and style issue. |
1771 |
if (vm.count("batch")) |
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1772 |
{
|
1773 |
status.setBatch(1); |
|
1774 |
status.setAddToHistory(0); |
|
1567.3.15
by Monty Taylor
Removed the last vestiges of my_sys from drizzle.cc. |
1775 |
if (opt_silent < 1) |
1776 |
{
|
|
1777 |
opt_silent= 1; |
|
1778 |
}
|
|
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1779 |
}
|
1567.5.3
by Vijay Samuel
Merge patch for sql_connect() and style issue. |
1780 |
if (vm.count("silent")) |
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1781 |
{
|
2053.2.3
by Andrew Hutchings
Make --silent work again |
1782 |
opt_silent= 2; |
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1783 |
}
|
1784 |
||
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
1785 |
if (vm.count("help") || vm.count("version")) |
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1786 |
{
|
1729.3.2
by LinuxJedi
Further cleanups based on Monty's comments (also revert a couple of things) |
1787 |
printf(_("Drizzle client %s build %s, for %s-%s (%s) using readline %s\n"), |
1788 |
drizzle_version(), VERSION, |
|
1789 |
HOST_VENDOR, HOST_OS, HOST_CPU, |
|
1567.3.14
by Monty Taylor
Removed the need for drizzled::internal usage in drizzle.cc. |
1790 |
rl_library_version); |
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
1791 |
if (vm.count("version")) |
1792 |
exit(0); |
|
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1793 |
printf(_("Copyright (C) 2008 Sun Microsystems\n" |
1794 |
"This software comes with ABSOLUTELY NO WARRANTY. "
|
|
1795 |
"This is free software,\n" |
|
1796 |
"and you are welcome to modify and redistribute it "
|
|
1797 |
"under the GPL license\n")); |
|
2005.2.2
by Andrew Hutchings
Change most places to use 'schema' instead of 'database' |
1798 |
printf(_("Usage: drizzle [OPTIONS] [schema]\n")); |
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
1799 |
cout << long_options; |
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1800 |
exit(0); |
1801 |
}
|
|
1802 |
||
1803 |
||
1567.5.3
by Vijay Samuel
Merge patch for sql_connect() and style issue. |
1804 |
if (process_options()) |
1
by brian
clean slate |
1805 |
{
|
1806 |
exit(1); |
|
1807 |
}
|
|
973.1.1
by Toru Maesaka
Added server shutdown and ping functionalities to the drizzle client app |
1808 |
|
212.6.10
by Mats Kindahl
Removing redundant use of casts in client/ for memcmp(), memcpy(), memset(), and memmove(). |
1809 |
memset(&drizzle, 0, sizeof(drizzle)); |
2053.2.1
by Andrew Hutchings
Fix hidden connect messages |
1810 |
if (sql_connect(current_host, current_db, current_user, opt_password)) |
1
by brian
clean slate |
1811 |
{
|
206.3.1
by Patrick Galbraith
Most everything working with client rename |
1812 |
quick= 1; // Avoid history |
1441.3.1
by Vijay Samuel
all required updations have been made |
1813 |
status.setExitStatus(1); |
206.3.1
by Patrick Galbraith
Most everything working with client rename |
1814 |
drizzle_end(-1); |
1
by brian
clean slate |
1815 |
}
|
973.1.1
by Toru Maesaka
Added server shutdown and ping functionalities to the drizzle client app |
1816 |
|
1817 |
int command_error; |
|
973.1.2
by Toru Maesaka
Cosmetic fixes pointed out by Jay and added comments for doxygen |
1818 |
if (execute_commands(&command_error) != false) |
973.1.1
by Toru Maesaka
Added server shutdown and ping functionalities to the drizzle client app |
1819 |
{
|
1820 |
/* we've executed a command so exit before we go into readline mode */
|
|
1821 |
exit(command_error); |
|
1822 |
}
|
|
1823 |
||
1441.3.1
by Vijay Samuel
all required updations have been made |
1824 |
if (status.getBatch() && !status.getLineBuff()) |
973.1.1
by Toru Maesaka
Added server shutdown and ping functionalities to the drizzle client app |
1825 |
{
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1826 |
status.setLineBuff(opt_max_input_line, stdin); |
1827 |
if (status.getLineBuff() == NULL) |
|
973.1.2
by Toru Maesaka
Cosmetic fixes pointed out by Jay and added comments for doxygen |
1828 |
{
|
1829 |
exit(1); |
|
1830 |
}
|
|
973.1.1
by Toru Maesaka
Added server shutdown and ping functionalities to the drizzle client app |
1831 |
}
|
973.1.2
by Toru Maesaka
Cosmetic fixes pointed out by Jay and added comments for doxygen |
1832 |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1833 |
if (!status.getBatch()) |
206.3.1
by Patrick Galbraith
Most everything working with client rename |
1834 |
ignore_errors=1; // Don't abort monitor |
1
by brian
clean slate |
1835 |
|
1836 |
if (opt_sigint_ignore) |
|
1837 |
signal(SIGINT, SIG_IGN); |
|
1838 |
else
|
|
1839 |
signal(SIGINT, handle_sigint); // Catch SIGINT to clean up |
|
206.3.1
by Patrick Galbraith
Most everything working with client rename |
1840 |
signal(SIGQUIT, drizzle_end); // Catch SIGQUIT to clean up |
1
by brian
clean slate |
1841 |
|
1842 |
#if defined(HAVE_TERMIOS_H) && defined(GWINSZ_IN_SYS_IOCTL)
|
|
1843 |
/* Readline will call this if it installs a handler */
|
|
1844 |
signal(SIGWINCH, window_resize); |
|
1845 |
/* call the SIGWINCH handler to get the default term width */
|
|
1846 |
window_resize(0); |
|
1847 |
#endif
|
|
1720.3.2
by LinuxJedi
Fix bug #617510: |
1848 |
std::vector<char> output_buff; |
1849 |
output_buff.resize(512); |
|
1850 |
||
1851 |
snprintf(&output_buff[0], output_buff.size(), |
|
1852 |
_("Welcome to the Drizzle client.. Commands end with %s or \\g."), |
|
1853 |
delimiter); |
|
1854 |
||
1855 |
put_info(&output_buff[0], INFO_INFO, 0, 0); |
|
182.1.2
by Jim Winstead
Various fixes to enable compilation on Mac OS X, and remove the glib dependency. |
1856 |
|
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
1857 |
glob_buffer= new string(); |
287.3.19
by Monty Taylor
Added string.reserve() calls. |
1858 |
glob_buffer->reserve(512); |
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1859 |
|
1707.1.22
by Brian Aker
Small cleanup in mysql.cc |
1860 |
snprintf(&output_buff[0], output_buff.size(), |
1745.2.1
by LinuxJedi
Remove the --mysql option and convert the --protocol option to do something similar. |
1861 |
_("Your Drizzle connection id is %u\nConnection protocol: %s\nServer version: %s\n"), |
1441.3.1
by Vijay Samuel
all required updations have been made |
1862 |
drizzle_con_thread_id(&con), |
1745.2.1
by LinuxJedi
Remove the --mysql option and convert the --protocol option to do something similar. |
1863 |
opt_protocol.c_str(), |
1441.3.1
by Vijay Samuel
all required updations have been made |
1864 |
server_version_string(&con)); |
1707.1.22
by Brian Aker
Small cleanup in mysql.cc |
1865 |
put_info(&output_buff[0], INFO_INFO, 0, 0); |
1
by brian
clean slate |
1866 |
|
1745.2.1
by LinuxJedi
Remove the --mysql option and convert the --protocol option to do something similar. |
1867 |
|
1567.5.2
by Vijay Samuel
Merge OSX fix for client drizzle. |
1868 |
initialize_readline((char *)current_prompt.c_str()); |
1441.3.1
by Vijay Samuel
all required updations have been made |
1869 |
if (!status.getBatch() && !quick) |
1
by brian
clean slate |
1870 |
{
|
206.3.1
by Patrick Galbraith
Most everything working with client rename |
1871 |
/* read-history from file, default ~/.drizzle_history*/
|
266.2.3
by Jim Winstead
Use DRIZZLE_* environment variables instead of MYSQL_* |
1872 |
if (getenv("DRIZZLE_HISTFILE")) |
1873 |
histfile= strdup(getenv("DRIZZLE_HISTFILE")); |
|
1
by brian
clean slate |
1874 |
else if (getenv("HOME")) |
1875 |
{
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1876 |
histfile=(char*) malloc(strlen(getenv("HOME")) + strlen("/.drizzle_history") + 2); |
1
by brian
clean slate |
1877 |
if (histfile) |
1441.3.1
by Vijay Samuel
all required updations have been made |
1878 |
sprintf(histfile,"%s/.drizzle_history",getenv("HOME")); |
1
by brian
clean slate |
1879 |
char link_name[FN_REFLEN]; |
1060.2.1
by Eric Lambert
-replace calls to my_readlink with readlink |
1880 |
ssize_t sym_link_size= readlink(histfile,link_name,FN_REFLEN-1); |
1881 |
if (sym_link_size >= 0) |
|
1
by brian
clean slate |
1882 |
{
|
1060.2.1
by Eric Lambert
-replace calls to my_readlink with readlink |
1883 |
link_name[sym_link_size]= '\0'; |
1884 |
if (strncmp(link_name, "/dev/null", 10) == 0) |
|
1885 |
{
|
|
1886 |
/* The .drizzle_history file is a symlink to /dev/null, don't use it */
|
|
1887 |
free(histfile); |
|
1888 |
histfile= 0; |
|
1889 |
}
|
|
1
by brian
clean slate |
1890 |
}
|
1891 |
}
|
|
1892 |
if (histfile) |
|
1893 |
{
|
|
1894 |
if (verbose) |
|
202.3.13
by Monty Taylor
Changed gettext() to _() in drizzle.c. |
1895 |
tee_fprintf(stdout, _("Reading history-file %s\n"),histfile); |
1
by brian
clean slate |
1896 |
read_history(histfile); |
1441.3.1
by Vijay Samuel
all required updations have been made |
1897 |
if (!(histfile_tmp= (char*) malloc((uint32_t) strlen(histfile) + 5))) |
1
by brian
clean slate |
1898 |
{
|
202.3.13
by Monty Taylor
Changed gettext() to _() in drizzle.c. |
1899 |
fprintf(stderr, _("Couldn't allocate memory for temp histfile!\n")); |
77.3.1
by Monty Taylor
First steps in removing sql_string and using glib instead. |
1900 |
exit(1); |
1
by brian
clean slate |
1901 |
}
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1902 |
sprintf(histfile_tmp, "%s.TMP", histfile); |
1
by brian
clean slate |
1903 |
}
|
1904 |
}
|
|
77.3.1
by Monty Taylor
First steps in removing sql_string and using glib instead. |
1905 |
|
1126.4.1
by Monty Taylor
Fixed a buffer overrun that was causing some translated message output to suck. |
1906 |
put_info(_("Type 'help;' or '\\h' for help. " |
1907 |
"Type '\\c' to clear the buffer.\n"),INFO_INFO,0,0); |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1908 |
status.setExitStatus(read_and_execute(!status.getBatch())); |
1
by brian
clean slate |
1909 |
if (opt_outfile) |
1910 |
end_tee(); |
|
206.3.1
by Patrick Galbraith
Most everything working with client rename |
1911 |
drizzle_end(0); |
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1912 |
}
|
319
by Brian Aker
Fix (yuck!) for OSX/Google bug. |
1913 |
|
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1914 |
catch(exception &err) |
1915 |
{
|
|
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
1916 |
cerr << _("Error:") << err.what() << endl; |
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1917 |
}
|
206.3.1
by Patrick Galbraith
Most everything working with client rename |
1918 |
return(0); // Keep compiler happy |
1
by brian
clean slate |
1919 |
}
|
1920 |
||
779.2.11
by Monty Taylor
General build cleanup - removed cruft, removed depreated checks. |
1921 |
void drizzle_end(int sig) |
1
by brian
clean slate |
1922 |
{
|
928.1.1
by Eric Day
Started client changes. |
1923 |
drizzle_con_free(&con); |
1924 |
drizzle_free(&drizzle); |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1925 |
if (!status.getBatch() && !quick && histfile) |
1
by brian
clean slate |
1926 |
{
|
1927 |
/* write-history */
|
|
1928 |
if (verbose) |
|
202.3.13
by Monty Taylor
Changed gettext() to _() in drizzle.c. |
1929 |
tee_fprintf(stdout, _("Writing history-file %s\n"),histfile); |
1
by brian
clean slate |
1930 |
if (!write_history(histfile_tmp)) |
1567.3.14
by Monty Taylor
Removed the need for drizzled::internal usage in drizzle.cc. |
1931 |
rename(histfile_tmp, histfile); |
1
by brian
clean slate |
1932 |
}
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1933 |
delete status.getLineBuff(); |
1934 |
status.setLineBuff(0); |
|
1
by brian
clean slate |
1935 |
|
1936 |
if (sig >= 0) |
|
202.3.13
by Monty Taylor
Changed gettext() to _() in drizzle.c. |
1937 |
put_info(sig ? _("Aborted") : _("Bye"), INFO_RESULT,0,0); |
1883.3.1
by Andrew Hutchings
Cleanup drizzledump and drizzle for cppcheck |
1938 |
delete glob_buffer; |
1939 |
delete processed_prompt; |
|
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1940 |
opt_password.erase(); |
477
by Monty Taylor
Removed my_free(). It turns out that it had been def'd to ignore the flags passed to it in the second arg anyway. Gotta love that. |
1941 |
free(histfile); |
1942 |
free(histfile_tmp); |
|
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1943 |
current_db.erase(); |
1944 |
current_host.erase(); |
|
1945 |
current_user.erase(); |
|
477
by Monty Taylor
Removed my_free(). It turns out that it had been def'd to ignore the flags passed to it in the second arg anyway. Gotta love that. |
1946 |
free(full_username); |
1947 |
free(part_username); |
|
1948 |
free(default_prompt); |
|
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
1949 |
current_prompt.erase(); |
1441.3.1
by Vijay Samuel
all required updations have been made |
1950 |
exit(status.getExitStatus()); |
1
by brian
clean slate |
1951 |
}
|
1952 |
||
1953 |
||
1954 |
/*
|
|
1955 |
This function handles sigint calls
|
|
1956 |
If query is in process, kill query
|
|
1957 |
no query in process, terminate like previous behavior
|
|
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
1958 |
*/
|
520.4.43
by mordred
A set of Solaris fixes. |
1959 |
extern "C" |
779.2.11
by Monty Taylor
General build cleanup - removed cruft, removed depreated checks. |
1960 |
void handle_sigint(int sig) |
1
by brian
clean slate |
1961 |
{
|
1962 |
char kill_buffer[40]; |
|
1929.1.40
by Monty Taylor
Replaced auto_ptr with scoped_ptr. |
1963 |
boost::scoped_ptr<drizzle_con_st> kill_drizzle(new drizzle_con_st); |
928.1.1
by Eric Day
Started client changes. |
1964 |
drizzle_result_st res; |
1965 |
drizzle_return_t ret; |
|
1
by brian
clean slate |
1966 |
|
1967 |
/* terminate if no query being executed, or we already tried interrupting */
|
|
2203.2.2
by Brian Aker
First pass through in going over work for MySQL AUTH PLUGIN style support. |
1968 |
if (!executing_query || interrupted_query) |
1969 |
{
|
|
1
by brian
clean slate |
1970 |
goto err; |
77.3.3
by Monty Taylor
Last change to migrate to glib from sql_string. |
1971 |
}
|
1
by brian
clean slate |
1972 |
|
1929.1.13
by Stewart Smith
fix large stack usage in handle_sigint in drizzle client |
1973 |
if (drizzle_con_add_tcp(&drizzle, kill_drizzle.get(), current_host.c_str(), |
1745.2.1
by LinuxJedi
Remove the --mysql option and convert the --protocol option to do something similar. |
1974 |
opt_drizzle_port, current_user.c_str(), opt_password.c_str(), NULL, |
1975 |
use_drizzle_protocol ? DRIZZLE_CON_EXPERIMENTAL : DRIZZLE_CON_MYSQL) == NULL) |
|
77.3.3
by Monty Taylor
Last change to migrate to glib from sql_string. |
1976 |
{
|
1
by brian
clean slate |
1977 |
goto err; |
77.3.3
by Monty Taylor
Last change to migrate to glib from sql_string. |
1978 |
}
|
1
by brian
clean slate |
1979 |
|
1980 |
/* kill_buffer is always big enough because max length of %lu is 15 */
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
1981 |
sprintf(kill_buffer, "KILL /*!50000 QUERY */ %u", |
1982 |
drizzle_con_thread_id(&con)); |
|
928.1.1
by Eric Day
Started client changes. |
1983 |
|
1929.1.13
by Stewart Smith
fix large stack usage in handle_sigint in drizzle client |
1984 |
if (drizzle_query_str(kill_drizzle.get(), &res, kill_buffer, &ret) != NULL) |
928.1.1
by Eric Day
Started client changes. |
1985 |
drizzle_result_free(&res); |
1986 |
||
1929.1.13
by Stewart Smith
fix large stack usage in handle_sigint in drizzle client |
1987 |
drizzle_con_free(kill_drizzle.get()); |
202.3.13
by Monty Taylor
Changed gettext() to _() in drizzle.c. |
1988 |
tee_fprintf(stdout, _("Query aborted by Ctrl+C\n")); |
1
by brian
clean slate |
1989 |
|
1990 |
interrupted_query= 1; |
|
1991 |
||
1992 |
return; |
|
1993 |
||
1994 |
err: |
|
206.3.1
by Patrick Galbraith
Most everything working with client rename |
1995 |
drizzle_end(sig); |
1
by brian
clean slate |
1996 |
}
|
1997 |
||
1998 |
||
1999 |
#if defined(HAVE_TERMIOS_H) && defined(GWINSZ_IN_SYS_IOCTL)
|
|
779.2.11
by Monty Taylor
General build cleanup - removed cruft, removed depreated checks. |
2000 |
void window_resize(int) |
1
by brian
clean slate |
2001 |
{
|
2002 |
struct winsize window_size; |
|
2003 |
||
2004 |
if (ioctl(fileno(stdin), TIOCGWINSZ, &window_size) == 0) |
|
2005 |
terminal_width= window_size.ws_col; |
|
2006 |
}
|
|
2007 |
#endif
|
|
2008 |
||
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
2009 |
|
2010 |
||
1567.5.3
by Vijay Samuel
Merge patch for sql_connect() and style issue. |
2011 |
static int process_options(void) |
1
by brian
clean slate |
2012 |
{
|
2013 |
char *tmp, *pagpoint; |
|
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
2014 |
|
1
by brian
clean slate |
2015 |
|
266.2.3
by Jim Winstead
Use DRIZZLE_* environment variables instead of MYSQL_* |
2016 |
tmp= (char *) getenv("DRIZZLE_HOST"); |
1
by brian
clean slate |
2017 |
if (tmp) |
1593.1.4
by Vijay Samuel
Merge Fixes for client drizzle. |
2018 |
current_host.assign(tmp); |
1
by brian
clean slate |
2019 |
|
2020 |
pagpoint= getenv("PAGER"); |
|
2021 |
if (!((char*) (pagpoint))) |
|
2022 |
{
|
|
1567.3.17
by Monty Taylor
Removed more C-string strings. replaced with std::string. |
2023 |
pager.assign("stdout"); |
1
by brian
clean slate |
2024 |
opt_nopager= 1; |
2025 |
}
|
|
2026 |
else
|
|
1567.3.17
by Monty Taylor
Removed more C-string strings. replaced with std::string. |
2027 |
{
|
2028 |
pager.assign(pagpoint); |
|
2029 |
}
|
|
2030 |
default_pager.assign(pager); |
|
1
by brian
clean slate |
2031 |
|
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
2032 |
//
|
1
by brian
clean slate |
2033 |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2034 |
if (status.getBatch()) /* disable pager and outfile in this case */ |
1
by brian
clean slate |
2035 |
{
|
1567.3.17
by Monty Taylor
Removed more C-string strings. replaced with std::string. |
2036 |
default_pager.assign("stdout"); |
2037 |
pager.assign("stdout"); |
|
1
by brian
clean slate |
2038 |
opt_nopager= 1; |
2039 |
default_pager_set= 0; |
|
2040 |
opt_outfile= 0; |
|
2041 |
opt_reconnect= 0; |
|
2042 |
}
|
|
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
2043 |
|
1
by brian
clean slate |
2044 |
if (tty_password) |
928.1.1
by Eric Day
Started client changes. |
2045 |
opt_password= client_get_tty_password(NULL); |
1
by brian
clean slate |
2046 |
return(0); |
2047 |
}
|
|
2048 |
||
2049 |
static int read_and_execute(bool interactive) |
|
2050 |
{
|
|
77.3.7
by Monty Taylor
Made mysql into a pure-C program. |
2051 |
char *line; |
2052 |
char in_string=0; |
|
288
by Brian Aker
ulong cleanp in client apps |
2053 |
uint32_t line_number=0; |
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
2054 |
bool ml_comment= 0; |
1441.3.1
by Vijay Samuel
all required updations have been made |
2055 |
Commands *com; |
2056 |
status.setExitStatus(1); |
|
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
2057 |
|
1
by brian
clean slate |
2058 |
for (;;) |
2059 |
{
|
|
2060 |
if (!interactive) |
|
2061 |
{
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2062 |
if (status.getLineBuff()) |
2063 |
line= status.getLineBuff()->readline(); |
|
1095.2.1
by Robert Klahn
Replace typedef struct LINE_BUFFER with class LineBuffer, encapsulating current logic |
2064 |
else
|
1095.2.4
by Robert Klahn
changes from code review feedback |
2065 |
line= 0; |
1095.2.2
by Robert Klahn
convert logic to use std::stringstream for buffer |
2066 |
|
1095.2.4
by Robert Klahn
changes from code review feedback |
2067 |
line_number++; |
2068 |
if (show_progress_size > 0) |
|
670.1.4
by Monty Taylor
Imported patch from LinuxJedi to add import status messages. |
2069 |
{
|
1095.2.4
by Robert Klahn
changes from code review feedback |
2070 |
if ((line_number % show_progress_size) == 0) |
2071 |
fprintf(stderr, _("Processing line: %"PRIu32"\n"), line_number); |
|
670.1.4
by Monty Taylor
Imported patch from LinuxJedi to add import status messages. |
2072 |
}
|
1095.2.4
by Robert Klahn
changes from code review feedback |
2073 |
if (!glob_buffer->empty()) |
1441.3.1
by Vijay Samuel
all required updations have been made |
2074 |
status.setQueryStartLine(line_number); |
1
by brian
clean slate |
2075 |
}
|
2076 |
else
|
|
2077 |
{
|
|
1596.1.1
by Monty Taylor
Merged in remove-internal-from-drizzle-cc |
2078 |
string prompt(ml_comment |
2079 |
? " /*> " |
|
2080 |
: glob_buffer->empty() |
|
2081 |
? construct_prompt() |
|
2082 |
: not in_string |
|
2083 |
? " -> " |
|
2084 |
: in_string == '\'' |
|
2085 |
? " '> " |
|
2086 |
: in_string == '`' |
|
2087 |
? " `> " |
|
2088 |
: " \"> "); |
|
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
2089 |
if (opt_outfile && glob_buffer->empty()) |
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
2090 |
fflush(OUTFILE); |
1
by brian
clean slate |
2091 |
|
2092 |
if (opt_outfile) |
|
1596.1.1
by Monty Taylor
Merged in remove-internal-from-drizzle-cc |
2093 |
fputs(prompt.c_str(), OUTFILE); |
2094 |
line= readline(prompt.c_str()); |
|
1
by brian
clean slate |
2095 |
/*
|
2096 |
When Ctrl+d or Ctrl+z is pressed, the line may be NULL on some OS
|
|
2097 |
which may cause coredump.
|
|
2098 |
*/
|
|
2099 |
if (opt_outfile && line) |
|
77.3.1
by Monty Taylor
First steps in removing sql_string and using glib instead. |
2100 |
fprintf(OUTFILE, "%s\n", line); |
1
by brian
clean slate |
2101 |
}
|
77.3.1
by Monty Taylor
First steps in removing sql_string and using glib instead. |
2102 |
// End of file
|
2103 |
if (!line) |
|
1
by brian
clean slate |
2104 |
{
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2105 |
status.setExitStatus(0); |
1
by brian
clean slate |
2106 |
break; |
2107 |
}
|
|
2108 |
||
2109 |
/*
|
|
206.3.1
by Patrick Galbraith
Most everything working with client rename |
2110 |
Check if line is a drizzle command line
|
1
by brian
clean slate |
2111 |
(We want to allow help, print and clear anywhere at line start
|
2112 |
*/
|
|
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
2113 |
if ((named_cmds || (glob_buffer->empty())) |
77.3.1
by Monty Taylor
First steps in removing sql_string and using glib instead. |
2114 |
&& !ml_comment && !in_string && (com=find_command(line,0))) |
1
by brian
clean slate |
2115 |
{
|
77.3.1
by Monty Taylor
First steps in removing sql_string and using glib instead. |
2116 |
if ((*com->func)(glob_buffer,line) > 0) |
2117 |
break; |
|
2118 |
// If buffer was emptied
|
|
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
2119 |
if (glob_buffer->empty()) |
77.3.1
by Monty Taylor
First steps in removing sql_string and using glib instead. |
2120 |
in_string=0; |
1441.3.1
by Vijay Samuel
all required updations have been made |
2121 |
if (interactive && status.getAddToHistory() && not_in_history(line)) |
77.3.1
by Monty Taylor
First steps in removing sql_string and using glib instead. |
2122 |
add_history(line); |
1
by brian
clean slate |
2123 |
continue; |
2124 |
}
|
|
77.3.4
by Monty Taylor
Removed debugging. Fixed multi-line processing error. |
2125 |
if (add_line(glob_buffer,line,&in_string,&ml_comment)) |
1
by brian
clean slate |
2126 |
break; |
2127 |
}
|
|
2128 |
/* if in batch mode, send last query even if it doesn't end with \g or go */
|
|
2129 |
||
1441.3.1
by Vijay Samuel
all required updations have been made |
2130 |
if (!interactive && !status.getExitStatus()) |
1
by brian
clean slate |
2131 |
{
|
2132 |
remove_cntrl(glob_buffer); |
|
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
2133 |
if (!glob_buffer->empty()) |
1
by brian
clean slate |
2134 |
{
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2135 |
status.setExitStatus(1); |
77.3.1
by Monty Taylor
First steps in removing sql_string and using glib instead. |
2136 |
if (com_go(glob_buffer,line) <= 0) |
1441.3.1
by Vijay Samuel
all required updations have been made |
2137 |
status.setExitStatus(0); |
1
by brian
clean slate |
2138 |
}
|
2139 |
}
|
|
2140 |
||
1441.3.1
by Vijay Samuel
all required updations have been made |
2141 |
return status.getExitStatus(); |
1
by brian
clean slate |
2142 |
}
|
2143 |
||
2144 |
||
1441.3.1
by Vijay Samuel
all required updations have been made |
2145 |
static Commands *find_command(const char *name,char cmd_char) |
1
by brian
clean slate |
2146 |
{
|
893
by Brian Aker
First pass of stripping uint |
2147 |
uint32_t len; |
266.1.19
by Monty Taylor
Fixed const thing. |
2148 |
const char *end; |
1
by brian
clean slate |
2149 |
|
2150 |
if (!name) |
|
2151 |
{
|
|
2152 |
len=0; |
|
2153 |
end=0; |
|
2154 |
}
|
|
2155 |
else
|
|
2156 |
{
|
|
1567.3.14
by Monty Taylor
Removed the need for drizzled::internal usage in drizzle.cc. |
2157 |
while (isspace(*name)) |
1
by brian
clean slate |
2158 |
name++; |
2159 |
/*
|
|
2160 |
If there is an \\g in the row or if the row has a delimiter but
|
|
2161 |
this is not a delimiter command, let add_line() take care of
|
|
2162 |
parsing the row and calling find_command()
|
|
2163 |
*/
|
|
2164 |
if (strstr(name, "\\g") || (strstr(name, delimiter) && |
|
2165 |
!(strlen(name) >= 9 && |
|
1567.3.14
by Monty Taylor
Removed the need for drizzled::internal usage in drizzle.cc. |
2166 |
!strcmp(name, "delimiter")))) |
1441.3.3
by Vijay Samuel
Changes made to the struct conversion |
2167 |
return(NULL); |
1
by brian
clean slate |
2168 |
if ((end=strcont(name," \t"))) |
2169 |
{
|
|
895
by Brian Aker
Completion (?) of uint conversion. |
2170 |
len=(uint32_t) (end - name); |
1567.3.14
by Monty Taylor
Removed the need for drizzled::internal usage in drizzle.cc. |
2171 |
while (isspace(*end)) |
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
2172 |
end++; |
1
by brian
clean slate |
2173 |
if (!*end) |
206.3.1
by Patrick Galbraith
Most everything working with client rename |
2174 |
end=0; // no arguments to function |
1
by brian
clean slate |
2175 |
}
|
2176 |
else
|
|
895
by Brian Aker
Completion (?) of uint conversion. |
2177 |
len=(uint32_t) strlen(name); |
1
by brian
clean slate |
2178 |
}
|
2179 |
||
1441.3.1
by Vijay Samuel
all required updations have been made |
2180 |
for (uint32_t i= 0; commands[i].getName(); i++) |
1
by brian
clean slate |
2181 |
{
|
2182 |
if (commands[i].func && |
|
1567.3.14
by Monty Taylor
Removed the need for drizzled::internal usage in drizzle.cc. |
2183 |
((name && !strncmp(name, commands[i].getName(), len) |
2184 |
&& !commands[i].getName()[len] && (!end || (end && commands[i].getTakesParams()))) || (!name && commands[i].getCmdChar() == cmd_char))) |
|
1
by brian
clean slate |
2185 |
{
|
142.1.2
by Patrick
All DBUG_x removed from client/ |
2186 |
return(&commands[i]); |
1
by brian
clean slate |
2187 |
}
|
2188 |
}
|
|
1441.3.3
by Vijay Samuel
Changes made to the struct conversion |
2189 |
return(NULL); |
1
by brian
clean slate |
2190 |
}
|
2191 |
||
2192 |
||
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
2193 |
static bool add_line(string *buffer, char *line, char *in_string, |
1441.3.1
by Vijay Samuel
all required updations have been made |
2194 |
bool *ml_comment) |
1
by brian
clean slate |
2195 |
{
|
481
by Brian Aker
Remove all of uchar. |
2196 |
unsigned char inchar; |
1126.4.1
by Monty Taylor
Fixed a buffer overrun that was causing some translated message output to suck. |
2197 |
char *pos, *out; |
1441.3.1
by Vijay Samuel
all required updations have been made |
2198 |
Commands *com; |
1
by brian
clean slate |
2199 |
bool need_space= 0; |
2200 |
bool ss_comment= 0; |
|
142.1.2
by Patrick
All DBUG_x removed from client/ |
2201 |
|
1
by brian
clean slate |
2202 |
|
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
2203 |
if (!line[0] && (buffer->empty())) |
142.1.2
by Patrick
All DBUG_x removed from client/ |
2204 |
return(0); |
1441.3.1
by Vijay Samuel
all required updations have been made |
2205 |
if (status.getAddToHistory() && line[0] && not_in_history(line)) |
1
by brian
clean slate |
2206 |
add_history(line); |
2207 |
||
481
by Brian Aker
Remove all of uchar. |
2208 |
for (pos=out=line ; (inchar= (unsigned char) *pos) ; pos++) |
1
by brian
clean slate |
2209 |
{
|
2210 |
if (!preserve_comments) |
|
2211 |
{
|
|
2212 |
// Skip spaces at the beggining of a statement
|
|
1567.3.14
by Monty Taylor
Removed the need for drizzled::internal usage in drizzle.cc. |
2213 |
if (isspace(inchar) && (out == line) && |
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
2214 |
(buffer->empty())) |
1
by brian
clean slate |
2215 |
continue; |
2216 |
}
|
|
77.3.1
by Monty Taylor
First steps in removing sql_string and using glib instead. |
2217 |
|
1
by brian
clean slate |
2218 |
// Accept multi-byte characters as-is
|
1567.3.20
by Monty Taylor
Removed UTF-8 lib that we don't use. |
2219 |
if (not drizzled::utf8::is_single(*pos)) |
1
by brian
clean slate |
2220 |
{
|
1567.3.16
by Monty Taylor
Added in proper check for mb quality before skipping based on mb length. |
2221 |
int length; |
1567.3.20
by Monty Taylor
Removed UTF-8 lib that we don't use. |
2222 |
if ((length= drizzled::utf8::sequence_length(*pos))) |
1
by brian
clean slate |
2223 |
{
|
1567.3.16
by Monty Taylor
Added in proper check for mb quality before skipping based on mb length. |
2224 |
if (!*ml_comment || preserve_comments) |
2225 |
{
|
|
2226 |
while (length--) |
|
2227 |
*out++ = *pos++; |
|
2228 |
pos--; |
|
2229 |
}
|
|
2230 |
else
|
|
2231 |
pos+= length - 1; |
|
2232 |
continue; |
|
1
by brian
clean slate |
2233 |
}
|
2234 |
}
|
|
1085.3.3
by Monty Taylor
Got rid of #ifdef have utf8 stuff. |
2235 |
if (!*ml_comment && inchar == '\\' && |
2236 |
!(*in_string && (drizzle_con_status(&con) & DRIZZLE_CON_STATUS_NO_BACKSLASH_ESCAPES))) |
|
1
by brian
clean slate |
2237 |
{
|
2238 |
// Found possbile one character command like \c
|
|
2239 |
||
481
by Brian Aker
Remove all of uchar. |
2240 |
if (!(inchar = (unsigned char) *++pos)) |
206.3.1
by Patrick Galbraith
Most everything working with client rename |
2241 |
break; // readline adds one '\' |
2242 |
if (*in_string || inchar == 'N') // \N is short for NULL |
|
2243 |
{ // Don't allow commands in string |
|
77.3.1
by Monty Taylor
First steps in removing sql_string and using glib instead. |
2244 |
*out++='\\'; |
2245 |
*out++= (char) inchar; |
|
2246 |
continue; |
|
1
by brian
clean slate |
2247 |
}
|
461
by Monty Taylor
Removed NullS. bu-bye. |
2248 |
if ((com=find_command(NULL,(char) inchar))) |
1
by brian
clean slate |
2249 |
{
|
2250 |
// Flush previously accepted characters
|
|
2251 |
if (out != line) |
|
2252 |
{
|
|
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
2253 |
buffer->append(line, (out-line)); |
1
by brian
clean slate |
2254 |
out= line; |
2255 |
}
|
|
77.3.1
by Monty Taylor
First steps in removing sql_string and using glib instead. |
2256 |
|
2257 |
if ((*com->func)(buffer,pos-1) > 0) |
|
142.1.2
by Patrick
All DBUG_x removed from client/ |
2258 |
return(1); // Quit |
1441.3.1
by Vijay Samuel
all required updations have been made |
2259 |
if (com->getTakesParams()) |
1
by brian
clean slate |
2260 |
{
|
2261 |
if (ss_comment) |
|
2262 |
{
|
|
2263 |
/*
|
|
2264 |
If a client-side macro appears inside a server-side comment,
|
|
2265 |
discard all characters in the comment after the macro (that is,
|
|
2266 |
until the end of the comment rather than the next delimiter)
|
|
2267 |
*/
|
|
2268 |
for (pos++; *pos && (*pos != '*' || *(pos + 1) != '/'); pos++) |
|
2269 |
;
|
|
2270 |
pos--; |
|
2271 |
}
|
|
2272 |
else
|
|
2273 |
{
|
|
2274 |
for (pos++ ; |
|
2275 |
*pos && (*pos != *delimiter || |
|
971.1.77
by Monty Taylor
Removed mysys/mystrings things from client/ progs. Still need to get rid of my_getopt, but I think that's all now. |
2276 |
strncmp(pos + 1, delimiter + 1, |
2277 |
strlen(delimiter + 1))) ; pos++) |
|
206.3.1
by Patrick Galbraith
Most everything working with client rename |
2278 |
; // Remove parameters |
1
by brian
clean slate |
2279 |
if (!*pos) |
2280 |
pos--; |
|
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
2281 |
else
|
1
by brian
clean slate |
2282 |
pos+= delimiter_length - 1; // Point at last delim char |
2283 |
}
|
|
2284 |
}
|
|
2285 |
}
|
|
2286 |
else
|
|
2287 |
{
|
|
1126.4.1
by Monty Taylor
Fixed a buffer overrun that was causing some translated message output to suck. |
2288 |
string buff(_("Unknown command: ")); |
2289 |
buff.push_back('\''); |
|
2290 |
buff.push_back(inchar); |
|
2291 |
buff.push_back('\''); |
|
2292 |
buff.push_back('.'); |
|
2293 |
if (put_info(buff.c_str(),INFO_ERROR,0,0) > 0) |
|
77.4.1
by Monty Taylor
Merged from trunk. |
2294 |
return(1); |
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
2295 |
*out++='\\'; |
2296 |
*out++=(char) inchar; |
|
2297 |
continue; |
|
1
by brian
clean slate |
2298 |
}
|
2299 |
}
|
|
971.1.77
by Monty Taylor
Removed mysys/mystrings things from client/ progs. Still need to get rid of my_getopt, but I think that's all now. |
2300 |
else if (!*ml_comment && !*in_string && !strncmp(pos, delimiter, |
2301 |
strlen(delimiter))) |
|
1
by brian
clean slate |
2302 |
{
|
2303 |
// Found a statement. Continue parsing after the delimiter
|
|
2304 |
pos+= delimiter_length; |
|
2305 |
||
2306 |
if (preserve_comments) |
|
2307 |
{
|
|
1567.3.14
by Monty Taylor
Removed the need for drizzled::internal usage in drizzle.cc. |
2308 |
while (isspace(*pos)) |
1
by brian
clean slate |
2309 |
*out++= *pos++; |
2310 |
}
|
|
2311 |
// Flush previously accepted characters
|
|
2312 |
if (out != line) |
|
2313 |
{
|
|
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
2314 |
buffer->append(line, (out-line)); |
1
by brian
clean slate |
2315 |
out= line; |
2316 |
}
|
|
2317 |
||
2318 |
if (preserve_comments && ((*pos == '#') || |
|
2319 |
((*pos == '-') && |
|
2320 |
(pos[1] == '-') && |
|
1567.3.14
by Monty Taylor
Removed the need for drizzled::internal usage in drizzle.cc. |
2321 |
isspace(pos[2])))) |
1
by brian
clean slate |
2322 |
{
|
2323 |
// Add trailing single line comments to this statement
|
|
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
2324 |
buffer->append(pos); |
1
by brian
clean slate |
2325 |
pos+= strlen(pos); |
2326 |
}
|
|
2327 |
||
2328 |
pos--; |
|
2329 |
||
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
2330 |
if ((com= find_command(buffer->c_str(), 0))) |
1
by brian
clean slate |
2331 |
{
|
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
2332 |
|
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
2333 |
if ((*com->func)(buffer, buffer->c_str()) > 0) |
77.4.1
by Monty Taylor
Merged from trunk. |
2334 |
return(1); // Quit |
1
by brian
clean slate |
2335 |
}
|
2336 |
else
|
|
2337 |
{
|
|
77.3.1
by Monty Taylor
First steps in removing sql_string and using glib instead. |
2338 |
if (com_go(buffer, 0) > 0) // < 0 is not fatal |
142.1.2
by Patrick
All DBUG_x removed from client/ |
2339 |
return(1); |
1
by brian
clean slate |
2340 |
}
|
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
2341 |
buffer->clear(); |
1
by brian
clean slate |
2342 |
}
|
77.3.1
by Monty Taylor
First steps in removing sql_string and using glib instead. |
2343 |
else if (!*ml_comment |
2344 |
&& (!*in_string |
|
2345 |
&& (inchar == '#' |
|
2346 |
|| (inchar == '-' |
|
2347 |
&& pos[1] == '-' |
|
1567.3.14
by Monty Taylor
Removed the need for drizzled::internal usage in drizzle.cc. |
2348 |
&& isspace(pos[2]))))) |
1
by brian
clean slate |
2349 |
{
|
2350 |
// Flush previously accepted characters
|
|
2351 |
if (out != line) |
|
2352 |
{
|
|
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
2353 |
buffer->append(line, (out - line)); |
1
by brian
clean slate |
2354 |
out= line; |
2355 |
}
|
|
2356 |
||
2357 |
// comment to end of line
|
|
2358 |
if (preserve_comments) |
|
2234.2.1
by Andrew Hutchings
Backport of http://bugs.mysql.com/bug.php?id=33812 to fix the use of the word "delimiter" in the middle of queries in drizzle client |
2359 |
{
|
2360 |
bool started_with_nothing= !buffer->empty(); |
|
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
2361 |
buffer->append(pos); |
1
by brian
clean slate |
2362 |
|
2234.2.1
by Andrew Hutchings
Backport of http://bugs.mysql.com/bug.php?id=33812 to fix the use of the word "delimiter" in the middle of queries in drizzle client |
2363 |
/*
|
2364 |
A single-line comment by itself gets sent immediately so that
|
|
2365 |
client commands (delimiter, status, etc) will be interpreted on
|
|
2366 |
the next line.
|
|
2367 |
*/
|
|
2368 |
if (started_with_nothing) |
|
2369 |
{
|
|
2370 |
if (com_go(buffer, 0) > 0) // < 0 is not fatal |
|
2371 |
return 1; |
|
2372 |
buffer->clear(); |
|
2373 |
}
|
|
2374 |
}
|
|
2375 |
||
1
by brian
clean slate |
2376 |
break; |
2377 |
}
|
|
2378 |
else if (!*in_string && inchar == '/' && *(pos+1) == '*' && |
|
77.3.1
by Monty Taylor
First steps in removing sql_string and using glib instead. |
2379 |
*(pos+2) != '!') |
1
by brian
clean slate |
2380 |
{
|
2381 |
if (preserve_comments) |
|
2382 |
{
|
|
2383 |
*out++= *pos++; // copy '/' |
|
2384 |
*out++= *pos; // copy '*' |
|
2385 |
}
|
|
2386 |
else
|
|
2387 |
pos++; |
|
2388 |
*ml_comment= 1; |
|
2389 |
if (out != line) |
|
2390 |
{
|
|
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
2391 |
buffer->append(line, (out-line)); |
1
by brian
clean slate |
2392 |
out=line; |
2393 |
}
|
|
2394 |
}
|
|
2395 |
else if (*ml_comment && !ss_comment && inchar == '*' && *(pos + 1) == '/') |
|
2396 |
{
|
|
2397 |
if (preserve_comments) |
|
2398 |
{
|
|
2399 |
*out++= *pos++; // copy '*' |
|
2400 |
*out++= *pos; // copy '/' |
|
2401 |
}
|
|
2402 |
else
|
|
2403 |
pos++; |
|
2404 |
*ml_comment= 0; |
|
2405 |
if (out != line) |
|
2406 |
{
|
|
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
2407 |
buffer->append(line, (out - line)); |
1
by brian
clean slate |
2408 |
out= line; |
2409 |
}
|
|
2410 |
// Consumed a 2 chars or more, and will add 1 at most,
|
|
2411 |
// so using the 'line' buffer to edit data in place is ok.
|
|
2412 |
need_space= 1; |
|
77.3.1
by Monty Taylor
First steps in removing sql_string and using glib instead. |
2413 |
}
|
1
by brian
clean slate |
2414 |
else
|
77.3.1
by Monty Taylor
First steps in removing sql_string and using glib instead. |
2415 |
{
|
2416 |
// Add found char to buffer
|
|
1
by brian
clean slate |
2417 |
if (!*in_string && inchar == '/' && *(pos + 1) == '*' && |
2418 |
*(pos + 2) == '!') |
|
2419 |
ss_comment= 1; |
|
2420 |
else if (!*in_string && ss_comment && inchar == '*' && *(pos + 1) == '/') |
|
2421 |
ss_comment= 0; |
|
2422 |
if (inchar == *in_string) |
|
77.3.1
by Monty Taylor
First steps in removing sql_string and using glib instead. |
2423 |
*in_string= 0; |
1
by brian
clean slate |
2424 |
else if (!*ml_comment && !*in_string && |
77.3.1
by Monty Taylor
First steps in removing sql_string and using glib instead. |
2425 |
(inchar == '\'' || inchar == '"' || inchar == '`')) |
2426 |
*in_string= (char) inchar; |
|
1
by brian
clean slate |
2427 |
if (!*ml_comment || preserve_comments) |
2428 |
{
|
|
1567.3.14
by Monty Taylor
Removed the need for drizzled::internal usage in drizzle.cc. |
2429 |
if (need_space && !isspace((char)inchar)) |
1
by brian
clean slate |
2430 |
*out++= ' '; |
2431 |
need_space= 0; |
|
2432 |
*out++= (char) inchar; |
|
2433 |
}
|
|
2434 |
}
|
|
2435 |
}
|
|
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
2436 |
if (out != line || (buffer->length() > 0)) |
1
by brian
clean slate |
2437 |
{
|
2438 |
*out++='\n'; |
|
895
by Brian Aker
Completion (?) of uint conversion. |
2439 |
uint32_t length=(uint32_t) (out-line); |
1909.5.1
by Andrew Hutchings
Re-write of linebuffer to stop buffer overrrun and hopefully improve performance |
2440 |
if ((buffer->length() + length) > opt_max_input_line) |
2441 |
{
|
|
2442 |
status.setExitStatus(1); |
|
2443 |
put_info(_("Not found a delimiter within max_input_line of input"), INFO_ERROR, 0, 0); |
|
2444 |
return 1; |
|
2445 |
}
|
|
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
2446 |
if ((!*ml_comment || preserve_comments)) |
2447 |
buffer->append(line, length); |
|
1
by brian
clean slate |
2448 |
}
|
142.1.2
by Patrick
All DBUG_x removed from client/ |
2449 |
return(0); |
1
by brian
clean slate |
2450 |
}
|
2451 |
||
2452 |
/*****************************************************************
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2453 |
Interface to Readline Completion
|
2454 |
******************************************************************/
|
|
1
by brian
clean slate |
2455 |
|
2456 |
||
182.1.6
by Jim Winstead
Fix declaration of no_completion, drop 'new_' prefix from a function to make |
2457 |
static char **mysql_completion (const char *text, int start, int end); |
520.4.43
by mordred
A set of Solaris fixes. |
2458 |
extern "C" char *new_command_generator(const char *text, int); |
182.1.6
by Jim Winstead
Fix declaration of no_completion, drop 'new_' prefix from a function to make |
2459 |
|
1
by brian
clean slate |
2460 |
/*
|
2461 |
Tell the GNU Readline library how to complete. We want to try to complete
|
|
2462 |
on command names if this is the first word in the line, or on filenames
|
|
2463 |
if not.
|
|
2464 |
*/
|
|
632.1.12
by Monty Taylor
Fixed more sun studio warnings. |
2465 |
static char *no_completion(const char *, int) |
1
by brian
clean slate |
2466 |
{
|
77.3.1
by Monty Taylor
First steps in removing sql_string and using glib instead. |
2467 |
/* No filename completion */
|
2468 |
return 0; |
|
1
by brian
clean slate |
2469 |
}
|
182.1.6
by Jim Winstead
Fix declaration of no_completion, drop 'new_' prefix from a function to make |
2470 |
|
1
by brian
clean slate |
2471 |
|
77.3.1
by Monty Taylor
First steps in removing sql_string and using glib instead. |
2472 |
/* glues pieces of history back together if in pieces */
|
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
2473 |
static void fix_history(string *final_command) |
1
by brian
clean slate |
2474 |
{
|
2475 |
int total_lines = 1; |
|
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
2476 |
const char *ptr = final_command->c_str(); |
182.1.2
by Jim Winstead
Various fixes to enable compilation on Mac OS X, and remove the glib dependency. |
2477 |
char str_char = '\0'; /* Character if we are in a string or not */ |
2478 |
||
77.3.1
by Monty Taylor
First steps in removing sql_string and using glib instead. |
2479 |
/* Converted buffer */
|
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
2480 |
string fixed_buffer; |
287.3.19
by Monty Taylor
Added string.reserve() calls. |
2481 |
fixed_buffer.reserve(512); |
77.3.1
by Monty Taylor
First steps in removing sql_string and using glib instead. |
2482 |
|
1
by brian
clean slate |
2483 |
/* find out how many lines we have and remove newlines */
|
77.3.1
by Monty Taylor
First steps in removing sql_string and using glib instead. |
2484 |
while (*ptr != '\0') |
1
by brian
clean slate |
2485 |
{
|
2486 |
switch (*ptr) { |
|
2487 |
/* string character */
|
|
2488 |
case '"': |
|
2489 |
case '\'': |
|
2490 |
case '`': |
|
77.3.1
by Monty Taylor
First steps in removing sql_string and using glib instead. |
2491 |
// open string
|
2492 |
if (str_char == '\0') |
|
2493 |
str_char = *ptr; |
|
1
by brian
clean slate |
2494 |
else if (str_char == *ptr) /* close string */ |
77.3.1
by Monty Taylor
First steps in removing sql_string and using glib instead. |
2495 |
str_char = '\0'; |
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
2496 |
fixed_buffer.append(ptr, 1); |
1
by brian
clean slate |
2497 |
break; |
2498 |
case '\n': |
|
77.3.1
by Monty Taylor
First steps in removing sql_string and using glib instead. |
2499 |
/*
|
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
2500 |
not in string, change to space
|
2501 |
if in string, leave it alone
|
|
1
by brian
clean slate |
2502 |
*/
|
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
2503 |
fixed_buffer.append((str_char == '\0') ? " " : "\n"); |
1
by brian
clean slate |
2504 |
total_lines++; |
2505 |
break; |
|
2506 |
case '\\': |
|
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
2507 |
fixed_buffer.append("\\"); |
1
by brian
clean slate |
2508 |
/* need to see if the backslash is escaping anything */
|
77.3.1
by Monty Taylor
First steps in removing sql_string and using glib instead. |
2509 |
if (str_char) |
1
by brian
clean slate |
2510 |
{
|
77.3.1
by Monty Taylor
First steps in removing sql_string and using glib instead. |
2511 |
ptr++; |
2512 |
/* special characters that need escaping */
|
|
2513 |
if (*ptr == '\'' || *ptr == '"' || *ptr == '\\') |
|
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
2514 |
fixed_buffer.append(ptr, 1); |
77.3.1
by Monty Taylor
First steps in removing sql_string and using glib instead. |
2515 |
else
|
2516 |
ptr--; |
|
1
by brian
clean slate |
2517 |
}
|
2518 |
break; |
|
2519 |
default: |
|
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
2520 |
fixed_buffer.append(ptr, 1); |
1
by brian
clean slate |
2521 |
}
|
2522 |
ptr++; |
|
2523 |
}
|
|
77.3.1
by Monty Taylor
First steps in removing sql_string and using glib instead. |
2524 |
if (total_lines > 1) |
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
2525 |
add_history(fixed_buffer.c_str()); |
1
by brian
clean slate |
2526 |
}
|
2527 |
||
77.3.1
by Monty Taylor
First steps in removing sql_string and using glib instead. |
2528 |
/*
|
1
by brian
clean slate |
2529 |
returns 0 if line matches the previous history entry
|
2530 |
returns 1 if the line doesn't match the previous history entry
|
|
2531 |
*/
|
|
77.3.1
by Monty Taylor
First steps in removing sql_string and using glib instead. |
2532 |
static int not_in_history(const char *line) |
1
by brian
clean slate |
2533 |
{
|
2534 |
HIST_ENTRY *oldhist = history_get(history_length); |
|
77.3.1
by Monty Taylor
First steps in removing sql_string and using glib instead. |
2535 |
|
1
by brian
clean slate |
2536 |
if (oldhist == 0) |
2537 |
return 1; |
|
2538 |
if (strcmp(oldhist->line,line) == 0) |
|
2539 |
return 0; |
|
2540 |
return 1; |
|
2541 |
}
|
|
2542 |
||
1567.5.2
by Vijay Samuel
Merge OSX fix for client drizzle. |
2543 |
static void initialize_readline (char *name) |
1
by brian
clean slate |
2544 |
{
|
2545 |
/* Allow conditional parsing of the ~/.inputrc file. */
|
|
319
by Brian Aker
Fix (yuck!) for OSX/Google bug. |
2546 |
rl_readline_name= name; |
1
by brian
clean slate |
2547 |
|
2548 |
/* Tell the completer that we want a crack first. */
|
|
236.1.15
by Monty Taylor
Fixed the previous merge. (since I suck) |
2549 |
rl_attempted_completion_function= (rl_completion_func_t*)&mysql_completion; |
1149.2.1
by Monty Taylor
Workaround for half-present new-interface on Snow Leopard, combined |
2550 |
rl_completion_entry_function= (drizzle_compentry_func_t*)&no_completion; |
1
by brian
clean slate |
2551 |
}
|
2552 |
||
182.1.6
by Jim Winstead
Fix declaration of no_completion, drop 'new_' prefix from a function to make |
2553 |
|
1
by brian
clean slate |
2554 |
/*
|
2555 |
Attempt to complete on the contents of TEXT. START and END show the
|
|
2556 |
region of TEXT that contains the word to complete. We can use the
|
|
2557 |
entire line in case we want to do some simple parsing. Return the
|
|
2558 |
array of matches, or NULL if there aren't any.
|
|
2559 |
*/
|
|
632.1.12
by Monty Taylor
Fixed more sun studio warnings. |
2560 |
char **mysql_completion (const char *text, int, int) |
1
by brian
clean slate |
2561 |
{
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2562 |
if (!status.getBatch() && !quick) |
1
by brian
clean slate |
2563 |
return rl_completion_matches(text, new_command_generator); |
2564 |
else
|
|
2565 |
return (char**) 0; |
|
2566 |
}
|
|
2567 |
||
923.2.6
by Monty Taylor
Removing hand-done completion hash functions. |
2568 |
inline string lower_string(const string &from_string) |
2569 |
{
|
|
2570 |
string to_string= from_string; |
|
2571 |
transform(to_string.begin(), to_string.end(), |
|
2572 |
to_string.begin(), ::tolower); |
|
2573 |
return to_string; |
|
2574 |
}
|
|
923.2.7
by Monty Taylor
Finished replacing custom HashMap with std::map. We use a map and not a set |
2575 |
inline string lower_string(const char * from_string) |
2576 |
{
|
|
2577 |
string to_string= from_string; |
|
2578 |
return lower_string(to_string); |
|
2579 |
}
|
|
923.2.6
by Monty Taylor
Removing hand-done completion hash functions. |
2580 |
|
923.2.7
by Monty Taylor
Finished replacing custom HashMap with std::map. We use a map and not a set |
2581 |
template <class T> |
923.2.6
by Monty Taylor
Removing hand-done completion hash functions. |
2582 |
class CompletionMatch : |
2583 |
public unary_function<const string&, bool> |
|
2584 |
{
|
|
2585 |
string match_text; |
|
923.2.7
by Monty Taylor
Finished replacing custom HashMap with std::map. We use a map and not a set |
2586 |
T match_func; |
923.2.6
by Monty Taylor
Removing hand-done completion hash functions. |
2587 |
public: |
923.2.7
by Monty Taylor
Finished replacing custom HashMap with std::map. We use a map and not a set |
2588 |
CompletionMatch(string text) : match_text(text) {} |
923.2.6
by Monty Taylor
Removing hand-done completion hash functions. |
2589 |
inline bool operator() (const pair<string,string> &match_against) const |
2590 |
{
|
|
2591 |
string sub_match= |
|
2592 |
lower_string(match_against.first.substr(0,match_text.size())); |
|
923.2.7
by Monty Taylor
Finished replacing custom HashMap with std::map. We use a map and not a set |
2593 |
return match_func(sub_match,match_text); |
923.2.6
by Monty Taylor
Removing hand-done completion hash functions. |
2594 |
}
|
2595 |
};
|
|
2596 |
||
2597 |
||
2598 |
||
520.4.43
by mordred
A set of Solaris fixes. |
2599 |
extern "C" |
923.2.6
by Monty Taylor
Removing hand-done completion hash functions. |
2600 |
char *new_command_generator(const char *text, int state) |
1
by brian
clean slate |
2601 |
{
|
2602 |
||
2603 |
if (!state) |
|
923.2.6
by Monty Taylor
Removing hand-done completion hash functions. |
2604 |
{
|
923.2.7
by Monty Taylor
Finished replacing custom HashMap with std::map. We use a map and not a set |
2605 |
completion_string= lower_string(text); |
2606 |
if (completion_string.size() == 0) |
|
923.2.6
by Monty Taylor
Removing hand-done completion hash functions. |
2607 |
{
|
2608 |
completion_iter= completion_map.begin(); |
|
923.2.7
by Monty Taylor
Finished replacing custom HashMap with std::map. We use a map and not a set |
2609 |
completion_end= completion_map.end(); |
923.2.6
by Monty Taylor
Removing hand-done completion hash functions. |
2610 |
}
|
2611 |
else
|
|
923.2.7
by Monty Taylor
Finished replacing custom HashMap with std::map. We use a map and not a set |
2612 |
{
|
923.2.6
by Monty Taylor
Removing hand-done completion hash functions. |
2613 |
completion_iter= find_if(completion_map.begin(), completion_map.end(), |
923.2.7
by Monty Taylor
Finished replacing custom HashMap with std::map. We use a map and not a set |
2614 |
CompletionMatch<equal_to<string> >(completion_string)); |
2615 |
completion_end= find_if(completion_iter, completion_map.end(), |
|
2616 |
CompletionMatch<not_equal_to<string> >(completion_string)); |
|
2617 |
}
|
|
923.2.6
by Monty Taylor
Removing hand-done completion hash functions. |
2618 |
}
|
923.2.7
by Monty Taylor
Finished replacing custom HashMap with std::map. We use a map and not a set |
2619 |
if (completion_iter == completion_end || (size_t)state > completion_map.size()) |
923.2.6
by Monty Taylor
Removing hand-done completion hash functions. |
2620 |
return NULL; |
2621 |
char *result= (char *)malloc((*completion_iter).second.size()+1); |
|
2622 |
strcpy(result, (*completion_iter).second.c_str()); |
|
2623 |
completion_iter++; |
|
2624 |
return result; |
|
1
by brian
clean slate |
2625 |
}
|
2626 |
||
2627 |
/* Build up the completion hash */
|
|
2628 |
||
2629 |
static void build_completion_hash(bool rehash, bool write_info) |
|
2630 |
{
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2631 |
Commands *cmd=commands; |
928.1.1
by Eric Day
Started client changes. |
2632 |
drizzle_return_t ret; |
2633 |
drizzle_result_st databases,tables,fields; |
|
2634 |
drizzle_row_t database_row,table_row; |
|
923.2.6
by Monty Taylor
Removing hand-done completion hash functions. |
2635 |
string tmp_str, tmp_str_lower; |
2005.2.1
by Andrew Hutchings
Move to using I_S instead of SHOW for hash lookup table. Also kill bug in fields list in the processes |
2636 |
std::string query; |
142.1.2
by Patrick
All DBUG_x removed from client/ |
2637 |
|
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
2638 |
if (status.getBatch() || quick || current_db.empty()) |
206.3.1
by Patrick Galbraith
Most everything working with client rename |
2639 |
return; // We don't need completion in batches |
1
by brian
clean slate |
2640 |
if (!rehash) |
142.1.2
by Patrick
All DBUG_x removed from client/ |
2641 |
return; |
1
by brian
clean slate |
2642 |
|
923.2.6
by Monty Taylor
Removing hand-done completion hash functions. |
2643 |
completion_map.clear(); |
1
by brian
clean slate |
2644 |
|
2645 |
/* hash this file's known subset of SQL commands */
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2646 |
while (cmd->getName()) { |
2647 |
tmp_str= cmd->getName(); |
|
923.2.6
by Monty Taylor
Removing hand-done completion hash functions. |
2648 |
tmp_str_lower= lower_string(tmp_str); |
2649 |
completion_map[tmp_str_lower]= tmp_str; |
|
1
by brian
clean slate |
2650 |
cmd++; |
2651 |
}
|
|
2652 |
||
77.1.40
by Monty Taylor
More naming changes. |
2653 |
/* hash Drizzle functions (to be implemented) */
|
1
by brian
clean slate |
2654 |
|
2655 |
/* hash all database names */
|
|
2005.2.1
by Andrew Hutchings
Move to using I_S instead of SHOW for hash lookup table. Also kill bug in fields list in the processes |
2656 |
if (drizzle_query_str(&con, &databases, "select schema_name from information_schema.schemata", &ret) != NULL) |
1
by brian
clean slate |
2657 |
{
|
928.1.4
by Eric Day
Fixed a few bugs, more progress on conversion. |
2658 |
if (ret == DRIZZLE_RETURN_OK) |
1
by brian
clean slate |
2659 |
{
|
928.1.4
by Eric Day
Fixed a few bugs, more progress on conversion. |
2660 |
if (drizzle_result_buffer(&databases) != DRIZZLE_RETURN_OK) |
2661 |
put_info(drizzle_error(&drizzle),INFO_INFO,0,0); |
|
2662 |
else
|
|
1
by brian
clean slate |
2663 |
{
|
928.1.4
by Eric Day
Fixed a few bugs, more progress on conversion. |
2664 |
while ((database_row=drizzle_row_next(&databases))) |
2665 |
{
|
|
2666 |
tmp_str= database_row[0]; |
|
2667 |
tmp_str_lower= lower_string(tmp_str); |
|
2668 |
completion_map[tmp_str_lower]= tmp_str; |
|
2669 |
}
|
|
1
by brian
clean slate |
2670 |
}
|
2671 |
}
|
|
928.1.4
by Eric Day
Fixed a few bugs, more progress on conversion. |
2672 |
|
2673 |
drizzle_result_free(&databases); |
|
1
by brian
clean slate |
2674 |
}
|
928.1.4
by Eric Day
Fixed a few bugs, more progress on conversion. |
2675 |
|
2005.2.1
by Andrew Hutchings
Move to using I_S instead of SHOW for hash lookup table. Also kill bug in fields list in the processes |
2676 |
query= "select table_name, column_name from information_schema.columns where table_schema='"; |
2677 |
query.append(current_db); |
|
2678 |
query.append("' order by table_name"); |
|
2679 |
||
2680 |
if (drizzle_query(&con, &fields, query.c_str(), query.length(), |
|
2681 |
&ret) != NULL) |
|
1
by brian
clean slate |
2682 |
{
|
2005.2.1
by Andrew Hutchings
Move to using I_S instead of SHOW for hash lookup table. Also kill bug in fields list in the processes |
2683 |
if (ret == DRIZZLE_RETURN_OK && |
2684 |
drizzle_result_buffer(&fields) == DRIZZLE_RETURN_OK) |
|
1
by brian
clean slate |
2685 |
{
|
928.1.1
by Eric Day
Started client changes. |
2686 |
if (drizzle_result_row_count(&tables) > 0 && !opt_silent && write_info) |
1
by brian
clean slate |
2687 |
{
|
1491.5.1
by Monty Taylor
Removed bad spacing discovered while looking at translations. |
2688 |
tee_fprintf(stdout, |
2689 |
_("Reading table information for completion of " |
|
2690 |
"table and column names\n" |
|
2691 |
"You can turn off this feature to get a quicker "
|
|
2692 |
"startup with -A\n\n")); |
|
1
by brian
clean slate |
2693 |
}
|
2005.2.1
by Andrew Hutchings
Move to using I_S instead of SHOW for hash lookup table. Also kill bug in fields list in the processes |
2694 |
|
2695 |
std::string table_name; |
|
2696 |
while ((table_row=drizzle_row_next(&fields))) |
|
1
by brian
clean slate |
2697 |
{
|
2005.2.1
by Andrew Hutchings
Move to using I_S instead of SHOW for hash lookup table. Also kill bug in fields list in the processes |
2698 |
if (table_name.compare(table_row[0]) != 0) |
2699 |
{
|
|
2700 |
tmp_str= table_row[0]; |
|
2701 |
tmp_str_lower= lower_string(tmp_str); |
|
2702 |
completion_map[tmp_str_lower]= tmp_str; |
|
2703 |
table_name= table_row[0]; |
|
2704 |
}
|
|
928.1.4
by Eric Day
Fixed a few bugs, more progress on conversion. |
2705 |
tmp_str= table_row[0]; |
2005.2.1
by Andrew Hutchings
Move to using I_S instead of SHOW for hash lookup table. Also kill bug in fields list in the processes |
2706 |
tmp_str.append("."); |
2707 |
tmp_str.append(table_row[1]); |
|
2708 |
tmp_str_lower= lower_string(tmp_str); |
|
2709 |
completion_map[tmp_str_lower]= tmp_str; |
|
2710 |
||
2711 |
tmp_str= table_row[1]; |
|
2712 |
tmp_str_lower= lower_string(tmp_str); |
|
2713 |
completion_map[tmp_str_lower]= tmp_str; |
|
2714 |
}
|
|
2715 |
}
|
|
2716 |
}
|
|
2717 |
drizzle_result_free(&fields); |
|
923.2.6
by Monty Taylor
Removing hand-done completion hash functions. |
2718 |
completion_iter= completion_map.begin(); |
1
by brian
clean slate |
2719 |
}
|
2720 |
||
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
2721 |
/* for gnu readline */
|
1
by brian
clean slate |
2722 |
|
2723 |
||
2724 |
static int reconnect(void) |
|
2725 |
{
|
|
2726 |
if (opt_reconnect) |
|
2727 |
{
|
|
202.3.13
by Monty Taylor
Changed gettext() to _() in drizzle.c. |
2728 |
put_info(_("No connection. Trying to reconnect..."),INFO_INFO,0,0); |
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
2729 |
(void) com_connect((string *)0, 0); |
1124.2.8
by Diego Medina
Fixes lp bug#432210 |
2730 |
if (opt_rehash && connected) |
1
by brian
clean slate |
2731 |
com_rehash(NULL, NULL); |
2732 |
}
|
|
1136
by Brian Aker
Merge for bug fixes. |
2733 |
if (! connected) |
202.3.13
by Monty Taylor
Changed gettext() to _() in drizzle.c. |
2734 |
return put_info(_("Can't connect to the server\n"),INFO_ERROR,0,0); |
1
by brian
clean slate |
2735 |
return 0; |
2736 |
}
|
|
2737 |
||
77.3.7
by Monty Taylor
Made mysql into a pure-C program. |
2738 |
static void get_current_db(void) |
1
by brian
clean slate |
2739 |
{
|
928.1.1
by Eric Day
Started client changes. |
2740 |
drizzle_return_t ret; |
2741 |
drizzle_result_st res; |
|
1
by brian
clean slate |
2742 |
|
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
2743 |
current_db.erase(); |
2744 |
current_db= ""; |
|
1
by brian
clean slate |
2745 |
/* In case of error below current_db will be NULL */
|
928.1.4
by Eric Day
Fixed a few bugs, more progress on conversion. |
2746 |
if (drizzle_query_str(&con, &res, "SELECT DATABASE()", &ret) != NULL) |
1
by brian
clean slate |
2747 |
{
|
928.1.4
by Eric Day
Fixed a few bugs, more progress on conversion. |
2748 |
if (ret == DRIZZLE_RETURN_OK && |
2749 |
drizzle_result_buffer(&res) == DRIZZLE_RETURN_OK) |
|
2750 |
{
|
|
2751 |
drizzle_row_t row= drizzle_row_next(&res); |
|
2752 |
if (row[0]) |
|
1593.1.4
by Vijay Samuel
Merge Fixes for client drizzle. |
2753 |
current_db.assign(row[0]); |
1124.2.9
by Diego Medina
Fixed a crash that came after fixing lp bug#432210 if you call use <db_name> twice on a |
2754 |
drizzle_result_free(&res); |
928.1.4
by Eric Day
Fixed a few bugs, more progress on conversion. |
2755 |
}
|
1
by brian
clean slate |
2756 |
}
|
2757 |
}
|
|
2758 |
||
2759 |
/***************************************************************************
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2760 |
The different commands
|
2761 |
***************************************************************************/
|
|
1
by brian
clean slate |
2762 |
|
1877.1.1
by Andrew Hutchings
Use size_t for command in drizzle.cc |
2763 |
int drizzleclient_real_query_for_lazy(const char *buf, size_t length, |
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
2764 |
drizzle_result_st *result, |
2765 |
uint32_t *error_code) |
|
1
by brian
clean slate |
2766 |
{
|
928.1.1
by Eric Day
Started client changes. |
2767 |
drizzle_return_t ret; |
2768 |
||
893
by Brian Aker
First pass of stripping uint |
2769 |
for (uint32_t retry=0;; retry++) |
1
by brian
clean slate |
2770 |
{
|
2771 |
int error; |
|
928.1.1
by Eric Day
Started client changes. |
2772 |
if (drizzle_query(&con,result,buf,length,&ret) != NULL && |
2773 |
ret == DRIZZLE_RETURN_OK) |
|
2774 |
{
|
|
1
by brian
clean slate |
2775 |
return 0; |
928.1.1
by Eric Day
Started client changes. |
2776 |
}
|
2777 |
error= put_error(&con, result); |
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
2778 |
|
2779 |
if (ret == DRIZZLE_RETURN_ERROR_CODE) |
|
2780 |
{
|
|
2781 |
*error_code= drizzle_result_error_code(result); |
|
2782 |
drizzle_result_free(result); |
|
2783 |
}
|
|
2784 |
||
2785 |
if (ret != DRIZZLE_RETURN_SERVER_GONE || retry > 1 || |
|
1
by brian
clean slate |
2786 |
!opt_reconnect) |
928.1.1
by Eric Day
Started client changes. |
2787 |
{
|
1
by brian
clean slate |
2788 |
return error; |
928.1.1
by Eric Day
Started client changes. |
2789 |
}
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
2790 |
|
1
by brian
clean slate |
2791 |
if (reconnect()) |
2792 |
return error; |
|
2793 |
}
|
|
2794 |
}
|
|
2795 |
||
928.1.1
by Eric Day
Started client changes. |
2796 |
int drizzleclient_store_result_for_lazy(drizzle_result_st *result) |
1
by brian
clean slate |
2797 |
{
|
928.1.1
by Eric Day
Started client changes. |
2798 |
if (drizzle_result_buffer(result) == DRIZZLE_RETURN_OK) |
1
by brian
clean slate |
2799 |
return 0; |
2800 |
||
928.1.1
by Eric Day
Started client changes. |
2801 |
if (drizzle_con_error(&con)[0]) |
1746.4.1
by Andrew Hutchings
An error whilst getting results instead of query meant results were not freed causing segfault on exit cleanup |
2802 |
{
|
2803 |
int ret= put_error(&con, result); |
|
2804 |
drizzle_result_free(result); |
|
2805 |
return ret; |
|
2806 |
}
|
|
1
by brian
clean slate |
2807 |
return 0; |
2808 |
}
|
|
2809 |
||
2810 |
static int |
|
820.2.1
by Toru Maesaka
Killed dead code and removed a reference to a non-existent help option |
2811 |
com_help(string *buffer, const char *) |
1
by brian
clean slate |
2812 |
{
|
2187.4.1
by Olaf van der Spek
Remove register keyword |
2813 |
int i, j; |
520.4.43
by mordred
A set of Solaris fixes. |
2814 |
char buff[32], *end; |
1720.3.2
by LinuxJedi
Fix bug #617510: |
2815 |
std::vector<char> output_buff; |
2816 |
output_buff.resize(512); |
|
1
by brian
clean slate |
2817 |
|
202.3.13
by Monty Taylor
Changed gettext() to _() in drizzle.c. |
2818 |
put_info(_("List of all Drizzle commands:"), INFO_INFO,0,0); |
1
by brian
clean slate |
2819 |
if (!named_cmds) |
1720.3.2
by LinuxJedi
Fix bug #617510: |
2820 |
{
|
2821 |
snprintf(&output_buff[0], output_buff.size(), |
|
2822 |
_("Note that all text commands must be first on line and end with '%s' or \\g"), |
|
2823 |
delimiter); |
|
2824 |
put_info(&output_buff[0], INFO_INFO, 0, 0); |
|
2825 |
}
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2826 |
for (i = 0; commands[i].getName(); i++) |
1
by brian
clean slate |
2827 |
{
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2828 |
end= strcpy(buff, commands[i].getName()); |
2829 |
end+= strlen(commands[i].getName()); |
|
2830 |
for (j= (int)strlen(commands[i].getName()); j < 10; j++) |
|
641.4.1
by Toru Maesaka
First pass of replacing MySQL's my_stpcpy() with appropriate libc calls |
2831 |
end= strcpy(end, " ")+1; |
1
by brian
clean slate |
2832 |
if (commands[i].func) |
2833 |
tee_fprintf(stdout, "%s(\\%c) %s\n", buff, |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2834 |
commands[i].getCmdChar(), _(commands[i].getDoc())); |
1
by brian
clean slate |
2835 |
}
|
820.2.1
by Toru Maesaka
Killed dead code and removed a reference to a non-existent help option |
2836 |
tee_fprintf(stdout, "\n"); |
2837 |
buffer->clear(); |
|
1
by brian
clean slate |
2838 |
return 0; |
2839 |
}
|
|
2840 |
||
2841 |
||
2842 |
static int |
|
632.1.12
by Monty Taylor
Fixed more sun studio warnings. |
2843 |
com_clear(string *buffer, const char *) |
1
by brian
clean slate |
2844 |
{
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2845 |
if (status.getAddToHistory()) |
1
by brian
clean slate |
2846 |
fix_history(buffer); |
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
2847 |
buffer->clear(); |
1
by brian
clean slate |
2848 |
return 0; |
2849 |
}
|
|
2850 |
||
2851 |
||
2852 |
/*
|
|
2853 |
Execute command
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2854 |
Returns: 0 if ok
|
2855 |
-1 if not fatal error
|
|
2856 |
1 if fatal error
|
|
1
by brian
clean slate |
2857 |
*/
|
2858 |
static int |
|
632.1.12
by Monty Taylor
Fixed more sun studio warnings. |
2859 |
com_go(string *buffer, const char *) |
1
by brian
clean slate |
2860 |
{
|
77.3.1
by Monty Taylor
First steps in removing sql_string and using glib instead. |
2861 |
char buff[200]; /* about 110 chars used so far */ |
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
2862 |
drizzle_result_st result; |
2863 |
drizzle_return_t ret; |
|
2148.6.1
by Stewart Smith
use a higher precision timer in the drizzle command line client. switch to using struct timeval for it, use 6 digit precision. |
2864 |
uint32_t warnings= 0; |
2148.6.2
by Stewart Smith
use boost::posix_time::ptime instead of gettimeofday() to be a bit more portable |
2865 |
boost::posix_time::ptime timer; |
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
2866 |
uint32_t error= 0; |
2867 |
uint32_t error_code= 0; |
|
1
by brian
clean slate |
2868 |
int err= 0; |
2869 |
||
2870 |
interrupted_query= 0; |
|
2871 |
||
2872 |
/* Remove garbage for nicer messages */
|
|
77.3.1
by Monty Taylor
First steps in removing sql_string and using glib instead. |
2873 |
remove_cntrl(buffer); |
1
by brian
clean slate |
2874 |
|
287.3.17
by Monty Taylor
Fixed null-query problem. |
2875 |
if (buffer->empty()) |
1
by brian
clean slate |
2876 |
{
|
77.3.1
by Monty Taylor
First steps in removing sql_string and using glib instead. |
2877 |
// Ignore empty quries
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2878 |
if (status.getBatch()) |
1
by brian
clean slate |
2879 |
return 0; |
202.3.13
by Monty Taylor
Changed gettext() to _() in drizzle.c. |
2880 |
return put_info(_("No query specified\n"),INFO_ERROR,0,0); |
1
by brian
clean slate |
2881 |
|
2882 |
}
|
|
2883 |
if (!connected && reconnect()) |
|
2884 |
{
|
|
77.3.1
by Monty Taylor
First steps in removing sql_string and using glib instead. |
2885 |
// Remove query on error
|
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
2886 |
buffer->clear(); |
1
by brian
clean slate |
2887 |
return opt_reconnect ? -1 : 1; // Fatal error |
2888 |
}
|
|
2889 |
if (verbose) |
|
77.3.1
by Monty Taylor
First steps in removing sql_string and using glib instead. |
2890 |
(void) com_print(buffer, 0); |
1
by brian
clean slate |
2891 |
|
2892 |
if (skip_updates && |
|
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
2893 |
((buffer->length() < 4) || (buffer->find( "SET ") != 0))) |
1
by brian
clean slate |
2894 |
{
|
202.3.13
by Monty Taylor
Changed gettext() to _() in drizzle.c. |
2895 |
(void) put_info(_("Ignoring query to other database"),INFO_INFO,0,0); |
1
by brian
clean slate |
2896 |
return 0; |
2897 |
}
|
|
2898 |
||
2899 |
timer=start_timer(); |
|
2900 |
executing_query= 1; |
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
2901 |
error= drizzleclient_real_query_for_lazy(buffer->c_str(),buffer->length(),&result, &error_code); |
1
by brian
clean slate |
2902 |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2903 |
if (status.getAddToHistory()) |
77.3.1
by Monty Taylor
First steps in removing sql_string and using glib instead. |
2904 |
{
|
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
2905 |
buffer->append(vertical ? "\\G" : delimiter); |
1
by brian
clean slate |
2906 |
/* Append final command onto history */
|
2907 |
fix_history(buffer); |
|
2908 |
}
|
|
2909 |
||
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
2910 |
buffer->clear(); |
1
by brian
clean slate |
2911 |
|
2912 |
if (error) |
|
2913 |
goto end; |
|
2914 |
||
2915 |
do
|
|
2916 |
{
|
|
2917 |
char *pos; |
|
2918 |
||
2919 |
if (quick) |
|
2920 |
{
|
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
2921 |
if (drizzle_column_buffer(&result) != DRIZZLE_RETURN_OK) |
1
by brian
clean slate |
2922 |
{
|
928.1.1
by Eric Day
Started client changes. |
2923 |
error= put_error(&con, &result); |
1
by brian
clean slate |
2924 |
goto end; |
2925 |
}
|
|
2926 |
}
|
|
2927 |
else
|
|
2928 |
{
|
|
840.1.21
by Monty Taylor
ZOMG. Renamed all the rest of the stuff in libdrizzleclient to be drizzleclient_*. I love commandline perl. |
2929 |
error= drizzleclient_store_result_for_lazy(&result); |
1
by brian
clean slate |
2930 |
if (error) |
2931 |
goto end; |
|
2932 |
}
|
|
2933 |
||
2148.6.1
by Stewart Smith
use a higher precision timer in the drizzle command line client. switch to using struct timeval for it, use 6 digit precision. |
2934 |
string time_buff(""); |
1
by brian
clean slate |
2935 |
if (verbose >= 3 || !opt_silent) |
206.3.1
by Patrick Galbraith
Most everything working with client rename |
2936 |
drizzle_end_timer(timer,time_buff); |
1
by brian
clean slate |
2937 |
|
2938 |
/* Every branch must truncate buff . */
|
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
2939 |
if (drizzle_result_column_count(&result) > 0) |
1
by brian
clean slate |
2940 |
{
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
2941 |
if (!quick && drizzle_result_row_count(&result) == 0 && |
2942 |
!column_types_flag) |
|
1
by brian
clean slate |
2943 |
{
|
641.4.1
by Toru Maesaka
First pass of replacing MySQL's my_stpcpy() with appropriate libc calls |
2944 |
strcpy(buff, _("Empty set")); |
1
by brian
clean slate |
2945 |
}
|
2946 |
else
|
|
2947 |
{
|
|
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
2948 |
init_pager(); |
266.2.1
by Jim Winstead
Remove HTML and XML output support from drizzle client |
2949 |
if (vertical || (auto_vertical_output && |
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
2950 |
(terminal_width < get_result_width(&result)))) |
2951 |
print_table_data_vertically(&result); |
|
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
2952 |
else if (opt_silent && verbose <= 2 && !output_tables) |
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
2953 |
print_tab_data(&result); |
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
2954 |
else
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
2955 |
print_table_data(&result); |
1441.3.1
by Vijay Samuel
all required updations have been made |
2956 |
sprintf(buff, |
2957 |
ngettext("%ld row in set","%ld rows in set", |
|
2958 |
(long) drizzle_result_row_count(&result)), |
|
2959 |
(long) drizzle_result_row_count(&result)); |
|
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
2960 |
end_pager(); |
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
2961 |
if (drizzle_result_error_code(&result)) |
2962 |
error= put_error(&con, &result); |
|
1
by brian
clean slate |
2963 |
}
|
2964 |
}
|
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
2965 |
else if (drizzle_result_affected_rows(&result) == ~(uint64_t) 0) |
641.4.1
by Toru Maesaka
First pass of replacing MySQL's my_stpcpy() with appropriate libc calls |
2966 |
strcpy(buff,_("Query OK")); |
1
by brian
clean slate |
2967 |
else
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2968 |
sprintf(buff, ngettext("Query OK, %ld row affected", |
2969 |
"Query OK, %ld rows affected", |
|
2970 |
(long) drizzle_result_affected_rows(&result)), |
|
2971 |
(long) drizzle_result_affected_rows(&result)); |
|
1
by brian
clean slate |
2972 |
|
376
by Brian Aker
strend remove |
2973 |
pos= strchr(buff, '\0'); |
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
2974 |
if ((warnings= drizzle_result_warning_count(&result))) |
1
by brian
clean slate |
2975 |
{
|
2976 |
*pos++= ','; |
|
2977 |
*pos++= ' '; |
|
971.1.77
by Monty Taylor
Removed mysys/mystrings things from client/ progs. Still need to get rid of my_getopt, but I think that's all now. |
2978 |
char warnings_buff[20]; |
2979 |
memset(warnings_buff,0,20); |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
2980 |
sprintf(warnings_buff, "%d", warnings); |
971.1.77
by Monty Taylor
Removed mysys/mystrings things from client/ progs. Still need to get rid of my_getopt, but I think that's all now. |
2981 |
strcpy(pos, warnings_buff); |
2982 |
pos+= strlen(warnings_buff); |
|
641.4.1
by Toru Maesaka
First pass of replacing MySQL's my_stpcpy() with appropriate libc calls |
2983 |
pos= strcpy(pos, " warning")+8; |
1
by brian
clean slate |
2984 |
if (warnings != 1) |
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
2985 |
*pos++= 's'; |
1
by brian
clean slate |
2986 |
}
|
2148.6.1
by Stewart Smith
use a higher precision timer in the drizzle command line client. switch to using struct timeval for it, use 6 digit precision. |
2987 |
strcpy(pos, time_buff.c_str()); |
77.3.7
by Monty Taylor
Made mysql into a pure-C program. |
2988 |
put_info(buff,INFO_RESULT,0,0); |
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
2989 |
if (strcmp(drizzle_result_info(&result), "")) |
2990 |
put_info(drizzle_result_info(&result),INFO_RESULT,0,0); |
|
206.3.1
by Patrick Galbraith
Most everything working with client rename |
2991 |
put_info("",INFO_RESULT,0,0); // Empty row |
1
by brian
clean slate |
2992 |
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
2993 |
if (unbuffered) |
1
by brian
clean slate |
2994 |
fflush(stdout); |
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
2995 |
drizzle_result_free(&result); |
2996 |
||
2997 |
if (drizzle_con_status(&con) & DRIZZLE_CON_STATUS_MORE_RESULTS_EXISTS) |
|
2998 |
{
|
|
2999 |
if (drizzle_result_read(&con, &result, &ret) == NULL || |
|
3000 |
ret != DRIZZLE_RETURN_OK) |
|
3001 |
{
|
|
3002 |
if (ret == DRIZZLE_RETURN_ERROR_CODE) |
|
3003 |
{
|
|
3004 |
error_code= drizzle_result_error_code(&result); |
|
3005 |
drizzle_result_free(&result); |
|
3006 |
}
|
|
3007 |
||
3008 |
error= put_error(&con, NULL); |
|
3009 |
goto end; |
|
3010 |
}
|
|
3011 |
}
|
|
3012 |
||
3013 |
} while (drizzle_con_status(&con) & DRIZZLE_CON_STATUS_MORE_RESULTS_EXISTS); |
|
1
by brian
clean slate |
3014 |
if (err >= 1) |
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3015 |
error= put_error(&con, NULL); |
1
by brian
clean slate |
3016 |
|
3017 |
end: |
|
3018 |
||
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
3019 |
/* Show warnings if any or error occured */
|
1
by brian
clean slate |
3020 |
if (show_warnings == 1 && (warnings >= 1 || error)) |
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3021 |
print_warnings(error_code); |
1
by brian
clean slate |
3022 |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
3023 |
if (!error && !status.getBatch() && |
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3024 |
drizzle_con_status(&con) & DRIZZLE_CON_STATUS_DB_DROPPED) |
3025 |
{
|
|
1
by brian
clean slate |
3026 |
get_current_db(); |
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3027 |
}
|
1
by brian
clean slate |
3028 |
|
3029 |
executing_query= 0; |
|
206.3.1
by Patrick Galbraith
Most everything working with client rename |
3030 |
return error; /* New command follows */ |
1
by brian
clean slate |
3031 |
}
|
3032 |
||
3033 |
||
3034 |
static void init_pager() |
|
3035 |
{
|
|
3036 |
if (!opt_nopager) |
|
3037 |
{
|
|
1567.3.17
by Monty Taylor
Removed more C-string strings. replaced with std::string. |
3038 |
if (!(PAGER= popen(pager.c_str(), "w"))) |
1
by brian
clean slate |
3039 |
{
|
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
3040 |
tee_fprintf(stdout,_( "popen() failed! defaulting PAGER to stdout!\n")); |
1
by brian
clean slate |
3041 |
PAGER= stdout; |
3042 |
}
|
|
3043 |
}
|
|
3044 |
else
|
|
3045 |
PAGER= stdout; |
|
3046 |
}
|
|
3047 |
||
3048 |
static void end_pager() |
|
3049 |
{
|
|
3050 |
if (!opt_nopager) |
|
3051 |
pclose(PAGER); |
|
3052 |
}
|
|
3053 |
||
3054 |
||
3055 |
static void init_tee(const char *file_name) |
|
3056 |
{
|
|
3057 |
FILE* new_outfile; |
|
3058 |
if (opt_outfile) |
|
3059 |
end_tee(); |
|
910.1.3
by Brian Aker
Remove my_fopen() and key_map.cc file (thanks to Jay's lcov) |
3060 |
if (!(new_outfile= fopen(file_name, "a"))) |
1
by brian
clean slate |
3061 |
{
|
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
3062 |
tee_fprintf(stdout, _("Error logging to file '%s'\n"), file_name); |
1
by brian
clean slate |
3063 |
return; |
3064 |
}
|
|
3065 |
OUTFILE = new_outfile; |
|
1567.3.17
by Monty Taylor
Removed more C-string strings. replaced with std::string. |
3066 |
outfile.assign(file_name); |
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
3067 |
tee_fprintf(stdout, _("Logging to file '%s'\n"), file_name); |
1
by brian
clean slate |
3068 |
opt_outfile= 1; |
910.1.3
by Brian Aker
Remove my_fopen() and key_map.cc file (thanks to Jay's lcov) |
3069 |
|
1
by brian
clean slate |
3070 |
return; |
3071 |
}
|
|
3072 |
||
3073 |
||
3074 |
static void end_tee() |
|
3075 |
{
|
|
910.1.3
by Brian Aker
Remove my_fopen() and key_map.cc file (thanks to Jay's lcov) |
3076 |
fclose(OUTFILE); |
1
by brian
clean slate |
3077 |
OUTFILE= 0; |
3078 |
opt_outfile= 0; |
|
3079 |
return; |
|
3080 |
}
|
|
3081 |
||
3082 |
||
3083 |
static int |
|
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
3084 |
com_ego(string *buffer,const char *line) |
1
by brian
clean slate |
3085 |
{
|
3086 |
int result; |
|
3087 |
bool oldvertical=vertical; |
|
3088 |
vertical=1; |
|
3089 |
result=com_go(buffer,line); |
|
3090 |
vertical=oldvertical; |
|
3091 |
return result; |
|
3092 |
}
|
|
3093 |
||
3094 |
||
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3095 |
static const char *fieldtype2str(drizzle_column_type_t type) |
1
by brian
clean slate |
3096 |
{
|
3097 |
switch (type) { |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
3098 |
case DRIZZLE_COLUMN_TYPE_BLOB: return "BLOB"; |
3099 |
case DRIZZLE_COLUMN_TYPE_DATE: return "DATE"; |
|
3100 |
case DRIZZLE_COLUMN_TYPE_DATETIME: return "DATETIME"; |
|
3101 |
case DRIZZLE_COLUMN_TYPE_NEWDECIMAL: return "DECIMAL"; |
|
3102 |
case DRIZZLE_COLUMN_TYPE_DOUBLE: return "DOUBLE"; |
|
3103 |
case DRIZZLE_COLUMN_TYPE_ENUM: return "ENUM"; |
|
3104 |
case DRIZZLE_COLUMN_TYPE_LONG: return "LONG"; |
|
3105 |
case DRIZZLE_COLUMN_TYPE_LONGLONG: return "LONGLONG"; |
|
3106 |
case DRIZZLE_COLUMN_TYPE_NULL: return "NULL"; |
|
3107 |
case DRIZZLE_COLUMN_TYPE_TIMESTAMP: return "TIMESTAMP"; |
|
3108 |
default: return "?-unknown-?"; |
|
1
by brian
clean slate |
3109 |
}
|
3110 |
}
|
|
3111 |
||
893
by Brian Aker
First pass of stripping uint |
3112 |
static char *fieldflags2str(uint32_t f) { |
1
by brian
clean slate |
3113 |
static char buf[1024]; |
3114 |
char *s=buf; |
|
3115 |
*s=0; |
|
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
3116 |
#define ff2s_check_flag(X) \
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3117 |
if (f & DRIZZLE_COLUMN_FLAGS_ ## X) { s=strcpy(s, # X " ")+strlen(# X " "); \
|
1441.3.1
by Vijay Samuel
all required updations have been made |
3118 |
f &= ~ DRIZZLE_COLUMN_FLAGS_ ## X; }
|
1
by brian
clean slate |
3119 |
ff2s_check_flag(NOT_NULL); |
3120 |
ff2s_check_flag(PRI_KEY); |
|
3121 |
ff2s_check_flag(UNIQUE_KEY); |
|
3122 |
ff2s_check_flag(MULTIPLE_KEY); |
|
3123 |
ff2s_check_flag(BLOB); |
|
3124 |
ff2s_check_flag(UNSIGNED); |
|
3125 |
ff2s_check_flag(BINARY); |
|
3126 |
ff2s_check_flag(ENUM); |
|
3127 |
ff2s_check_flag(AUTO_INCREMENT); |
|
3128 |
ff2s_check_flag(TIMESTAMP); |
|
3129 |
ff2s_check_flag(SET); |
|
3130 |
ff2s_check_flag(NO_DEFAULT_VALUE); |
|
3131 |
ff2s_check_flag(NUM); |
|
3132 |
ff2s_check_flag(PART_KEY); |
|
3133 |
ff2s_check_flag(GROUP); |
|
3134 |
ff2s_check_flag(UNIQUE); |
|
3135 |
ff2s_check_flag(BINCMP); |
|
3136 |
ff2s_check_flag(ON_UPDATE_NOW); |
|
3137 |
#undef ff2s_check_flag
|
|
3138 |
if (f) |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
3139 |
sprintf(s, " unknows=0x%04x", f); |
1
by brian
clean slate |
3140 |
return buf; |
3141 |
}
|
|
3142 |
||
3143 |
static void |
|
928.1.1
by Eric Day
Started client changes. |
3144 |
print_field_types(drizzle_result_st *result) |
1
by brian
clean slate |
3145 |
{
|
928.1.1
by Eric Day
Started client changes. |
3146 |
drizzle_column_st *field; |
893
by Brian Aker
First pass of stripping uint |
3147 |
uint32_t i=0; |
1
by brian
clean slate |
3148 |
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3149 |
while ((field = drizzle_column_next(result))) |
1
by brian
clean slate |
3150 |
{
|
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
3151 |
tee_fprintf(PAGER, _("Field %3u: `%s`\n" |
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
3152 |
"Catalog: `%s`\n" |
2005.2.2
by Andrew Hutchings
Change most places to use 'schema' instead of 'database' |
3153 |
"Schema: `%s`\n" |
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
3154 |
"Table: `%s`\n" |
3155 |
"Org_table: `%s`\n" |
|
1567.3.14
by Monty Taylor
Removed the need for drizzled::internal usage in drizzle.cc. |
3156 |
"Type: UTF-8\n" |
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
3157 |
"Collation: %s (%u)\n" |
3158 |
"Length: %lu\n" |
|
3159 |
"Max_length: %lu\n" |
|
3160 |
"Decimals: %u\n" |
|
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
3161 |
"Flags: %s\n\n"), |
1
by brian
clean slate |
3162 |
++i, |
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3163 |
drizzle_column_name(field), drizzle_column_catalog(field), |
3164 |
drizzle_column_db(field), drizzle_column_table(field), |
|
3165 |
drizzle_column_orig_table(field), |
|
3166 |
fieldtype2str(drizzle_column_type(field)), |
|
3167 |
drizzle_column_charset(field), drizzle_column_size(field), |
|
3168 |
drizzle_column_max_size(field), drizzle_column_decimals(field), |
|
3169 |
fieldflags2str(drizzle_column_flags(field))); |
|
1
by brian
clean slate |
3170 |
}
|
3171 |
tee_puts("", PAGER); |
|
3172 |
}
|
|
3173 |
||
3174 |
static void |
|
928.1.1
by Eric Day
Started client changes. |
3175 |
print_table_data(drizzle_result_st *result) |
1
by brian
clean slate |
3176 |
{
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3177 |
drizzle_row_t cur; |
3178 |
drizzle_return_t ret; |
|
3179 |
drizzle_column_st *field; |
|
1707.1.22
by Brian Aker
Small cleanup in mysql.cc |
3180 |
std::vector<bool> num_flag; |
2187.3.2
by Andrew Hutchings
Separate the server detection functions into a .h file |
3181 |
std::vector<bool> boolean_flag; |
2187.3.6
by Monty Taylor
Actually differentiate with the flag and fix up client output properly. |
3182 |
std::vector<bool> ansi_boolean_flag; |
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
3183 |
string separator; |
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
3184 |
|
287.3.19
by Monty Taylor
Added string.reserve() calls. |
3185 |
separator.reserve(256); |
1
by brian
clean slate |
3186 |
|
1707.1.22
by Brian Aker
Small cleanup in mysql.cc |
3187 |
num_flag.resize(drizzle_result_column_count(result)); |
2187.3.2
by Andrew Hutchings
Separate the server detection functions into a .h file |
3188 |
boolean_flag.resize(drizzle_result_column_count(result)); |
2187.3.6
by Monty Taylor
Actually differentiate with the flag and fix up client output properly. |
3189 |
ansi_boolean_flag.resize(drizzle_result_column_count(result)); |
1
by brian
clean slate |
3190 |
if (column_types_flag) |
3191 |
{
|
|
3192 |
print_field_types(result); |
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3193 |
if (!drizzle_result_row_count(result)) |
1
by brian
clean slate |
3194 |
return; |
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3195 |
drizzle_column_seek(result,0); |
1
by brian
clean slate |
3196 |
}
|
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
3197 |
separator.append("+"); |
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3198 |
while ((field = drizzle_column_next(result))) |
1
by brian
clean slate |
3199 |
{
|
840.3.1
by Toru Maesaka
Fixed the issue of seeing an oversized separator when rendering a multibyte string to console. |
3200 |
uint32_t x, length= 0; |
3201 |
||
3202 |
if (column_names) |
|
3203 |
{
|
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3204 |
uint32_t name_length= strlen(drizzle_column_name(field)); |
3205 |
||
840.3.1
by Toru Maesaka
Fixed the issue of seeing an oversized separator when rendering a multibyte string to console. |
3206 |
/* Check if the max_byte value is really the maximum in terms
|
1441.3.1
by Vijay Samuel
all required updations have been made |
3207 |
of visual length since multibyte characters can affect the
|
3208 |
length of the separator. */
|
|
1567.3.21
by Monty Taylor
Moved function from drizzle client to the utf8 header where it belongs. |
3209 |
length= drizzled::utf8::char_length(drizzle_column_name(field)); |
840.3.1
by Toru Maesaka
Fixed the issue of seeing an oversized separator when rendering a multibyte string to console. |
3210 |
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3211 |
if (name_length == drizzle_column_max_size(field)) |
840.1.15
by Monty Taylor
Merged from Toru. |
3212 |
{
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3213 |
if (length < drizzle_column_max_size(field)) |
3214 |
drizzle_column_set_max_size(field, length); |
|
840.1.15
by Monty Taylor
Merged from Toru. |
3215 |
}
|
840.3.1
by Toru Maesaka
Fixed the issue of seeing an oversized separator when rendering a multibyte string to console. |
3216 |
else
|
840.1.15
by Monty Taylor
Merged from Toru. |
3217 |
{
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3218 |
length= name_length; |
840.1.15
by Monty Taylor
Merged from Toru. |
3219 |
}
|
840.3.1
by Toru Maesaka
Fixed the issue of seeing an oversized separator when rendering a multibyte string to console. |
3220 |
}
|
1441.3.1
by Vijay Samuel
all required updations have been made |
3221 |
|
1
by brian
clean slate |
3222 |
if (quick) |
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3223 |
length=max(length,drizzle_column_size(field)); |
1
by brian
clean slate |
3224 |
else
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3225 |
length=max(length,(uint32_t)drizzle_column_max_size(field)); |
3226 |
if (length < 4 && |
|
3227 |
!(drizzle_column_flags(field) & DRIZZLE_COLUMN_FLAGS_NOT_NULL)) |
|
3228 |
{
|
|
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
3229 |
// Room for "NULL"
|
3230 |
length=4; |
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3231 |
}
|
2187.3.2
by Andrew Hutchings
Separate the server detection functions into a .h file |
3232 |
if ((length < 5) and |
3233 |
(server_type == ServerDetect::SERVER_DRIZZLE_FOUND) and |
|
2187.3.6
by Monty Taylor
Actually differentiate with the flag and fix up client output properly. |
3234 |
(drizzle_column_type(field) == DRIZZLE_COLUMN_TYPE_TINY) and |
3235 |
(drizzle_column_type(field) & DRIZZLE_COLUMN_FLAGS_UNSIGNED)) |
|
2187.3.2
by Andrew Hutchings
Separate the server detection functions into a .h file |
3236 |
{
|
3237 |
// Room for "FALSE"
|
|
3238 |
length= 5; |
|
3239 |
}
|
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3240 |
drizzle_column_set_max_size(field, length); |
840.3.1
by Toru Maesaka
Fixed the issue of seeing an oversized separator when rendering a multibyte string to console. |
3241 |
|
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
3242 |
for (x=0; x< (length+2); x++) |
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
3243 |
separator.append("-"); |
3244 |
separator.append("+"); |
|
1
by brian
clean slate |
3245 |
}
|
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
3246 |
|
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
3247 |
tee_puts((char*) separator.c_str(), PAGER); |
1
by brian
clean slate |
3248 |
if (column_names) |
3249 |
{
|
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3250 |
drizzle_column_seek(result,0); |
1
by brian
clean slate |
3251 |
(void) tee_fputs("|", PAGER); |
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3252 |
for (uint32_t off=0; (field = drizzle_column_next(result)) ; off++) |
1
by brian
clean slate |
3253 |
{
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3254 |
uint32_t name_length= (uint32_t) strlen(drizzle_column_name(field)); |
1567.3.21
by Monty Taylor
Moved function from drizzle client to the utf8 header where it belongs. |
3255 |
uint32_t numcells= drizzled::utf8::char_length(drizzle_column_name(field)); |
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3256 |
uint32_t display_length= drizzle_column_max_size(field) + name_length - |
1441.3.1
by Vijay Samuel
all required updations have been made |
3257 |
numcells; |
1
by brian
clean slate |
3258 |
tee_fprintf(PAGER, " %-*s |",(int) min(display_length, |
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
3259 |
MAX_COLUMN_LENGTH), |
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3260 |
drizzle_column_name(field)); |
3261 |
num_flag[off]= ((drizzle_column_type(field) <= DRIZZLE_COLUMN_TYPE_LONGLONG) || |
|
3262 |
(drizzle_column_type(field) == DRIZZLE_COLUMN_TYPE_NEWDECIMAL)); |
|
2187.3.2
by Andrew Hutchings
Separate the server detection functions into a .h file |
3263 |
if ((server_type == ServerDetect::SERVER_DRIZZLE_FOUND) and |
3264 |
(drizzle_column_type(field) == DRIZZLE_COLUMN_TYPE_TINY)) |
|
3265 |
{
|
|
2187.3.6
by Monty Taylor
Actually differentiate with the flag and fix up client output properly. |
3266 |
if ((drizzle_column_flags(field) & DRIZZLE_COLUMN_FLAGS_UNSIGNED)) |
3267 |
{
|
|
3268 |
ansi_boolean_flag[off]= true; |
|
3269 |
}
|
|
3270 |
else
|
|
3271 |
{
|
|
3272 |
ansi_boolean_flag[off]= false; |
|
3273 |
}
|
|
2187.3.2
by Andrew Hutchings
Separate the server detection functions into a .h file |
3274 |
boolean_flag[off]= true; |
3275 |
num_flag[off]= false; |
|
3276 |
}
|
|
3277 |
else
|
|
3278 |
{
|
|
3279 |
boolean_flag[off]= false; |
|
3280 |
}
|
|
1
by brian
clean slate |
3281 |
}
|
3282 |
(void) tee_fputs("\n", PAGER); |
|
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
3283 |
tee_puts((char*) separator.c_str(), PAGER); |
1
by brian
clean slate |
3284 |
}
|
3285 |
||
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3286 |
while (1) |
1
by brian
clean slate |
3287 |
{
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3288 |
if (quick) |
3289 |
{
|
|
3290 |
cur= drizzle_row_buffer(result, &ret); |
|
3291 |
if (ret != DRIZZLE_RETURN_OK) |
|
3292 |
{
|
|
3293 |
(void)put_error(&con, result); |
|
3294 |
break; |
|
3295 |
}
|
|
3296 |
}
|
|
3297 |
else
|
|
3298 |
cur= drizzle_row_next(result); |
|
3299 |
||
3300 |
if (cur == NULL || interrupted_query) |
|
1
by brian
clean slate |
3301 |
break; |
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3302 |
|
3303 |
size_t *lengths= drizzle_row_field_sizes(result); |
|
1
by brian
clean slate |
3304 |
(void) tee_fputs("| ", PAGER); |
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3305 |
drizzle_column_seek(result, 0); |
3306 |
for (uint32_t off= 0; off < drizzle_result_column_count(result); off++) |
|
1
by brian
clean slate |
3307 |
{
|
3308 |
const char *buffer; |
|
893
by Brian Aker
First pass of stripping uint |
3309 |
uint32_t data_length; |
3310 |
uint32_t field_max_length; |
|
3311 |
uint32_t visible_length; |
|
3312 |
uint32_t extra_padding; |
|
1
by brian
clean slate |
3313 |
|
3314 |
if (cur[off] == NULL) |
|
3315 |
{
|
|
3316 |
buffer= "NULL"; |
|
3317 |
data_length= 4; |
|
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
3318 |
}
|
2187.3.2
by Andrew Hutchings
Separate the server detection functions into a .h file |
3319 |
else if (boolean_flag[off]) |
3320 |
{
|
|
3321 |
if (strncmp(cur[off],"1", 1) == 0) |
|
3322 |
{
|
|
2187.3.6
by Monty Taylor
Actually differentiate with the flag and fix up client output properly. |
3323 |
if (ansi_boolean_flag[off]) |
3324 |
{
|
|
3325 |
buffer= "YES"; |
|
3326 |
data_length= 3; |
|
3327 |
}
|
|
3328 |
else
|
|
3329 |
{
|
|
3330 |
buffer= "TRUE"; |
|
3331 |
data_length= 4; |
|
3332 |
}
|
|
2187.3.2
by Andrew Hutchings
Separate the server detection functions into a .h file |
3333 |
}
|
3334 |
else
|
|
3335 |
{
|
|
2187.3.6
by Monty Taylor
Actually differentiate with the flag and fix up client output properly. |
3336 |
if (ansi_boolean_flag[off]) |
3337 |
{
|
|
3338 |
buffer= "NO"; |
|
3339 |
data_length= 2; |
|
3340 |
}
|
|
3341 |
else
|
|
3342 |
{
|
|
3343 |
buffer= "FALSE"; |
|
3344 |
data_length= 5; |
|
3345 |
}
|
|
2187.3.2
by Andrew Hutchings
Separate the server detection functions into a .h file |
3346 |
}
|
3347 |
}
|
|
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
3348 |
else
|
1
by brian
clean slate |
3349 |
{
|
928.1.4
by Eric Day
Fixed a few bugs, more progress on conversion. |
3350 |
buffer= cur[off]; |
895
by Brian Aker
Completion (?) of uint conversion. |
3351 |
data_length= (uint32_t) lengths[off]; |
1
by brian
clean slate |
3352 |
}
|
3353 |
||
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3354 |
field= drizzle_column_next(result); |
3355 |
field_max_length= drizzle_column_max_size(field); |
|
1
by brian
clean slate |
3356 |
|
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
3357 |
/*
|
3358 |
How many text cells on the screen will this string span? If it contains
|
|
3359 |
multibyte characters, then the number of characters we occupy on screen
|
|
3360 |
will be fewer than the number of bytes we occupy in memory.
|
|
1
by brian
clean slate |
3361 |
|
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
3362 |
We need to find how much screen real-estate we will occupy to know how
|
3363 |
many extra padding-characters we should send with the printing function.
|
|
1
by brian
clean slate |
3364 |
*/
|
1567.3.21
by Monty Taylor
Moved function from drizzle client to the utf8 header where it belongs. |
3365 |
visible_length= drizzled::utf8::char_length(buffer); |
1
by brian
clean slate |
3366 |
extra_padding= data_length - visible_length; |
3367 |
||
3368 |
if (field_max_length > MAX_COLUMN_LENGTH) |
|
1075
by Brian Aker
Fix for CentOS |
3369 |
tee_print_sized_data(buffer, data_length, MAX_COLUMN_LENGTH+extra_padding, false); |
1
by brian
clean slate |
3370 |
else
|
3371 |
{
|
|
3372 |
if (num_flag[off] != 0) /* if it is numeric, we right-justify it */ |
|
1075
by Brian Aker
Fix for CentOS |
3373 |
tee_print_sized_data(buffer, data_length, field_max_length+extra_padding, true); |
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
3374 |
else
|
77.3.1
by Monty Taylor
First steps in removing sql_string and using glib instead. |
3375 |
tee_print_sized_data(buffer, data_length, |
1075
by Brian Aker
Fix for CentOS |
3376 |
field_max_length+extra_padding, false); |
1
by brian
clean slate |
3377 |
}
|
3378 |
tee_fputs(" | ", PAGER); |
|
3379 |
}
|
|
3380 |
(void) tee_fputs("\n", PAGER); |
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3381 |
if (quick) |
3382 |
drizzle_row_free(result, cur); |
|
1
by brian
clean slate |
3383 |
}
|
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
3384 |
tee_puts(separator.c_str(), PAGER); |
1
by brian
clean slate |
3385 |
}
|
3386 |
||
3387 |
/**
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
3388 |
Return the length of a field after it would be rendered into text.
|
3389 |
||
3390 |
This doesn't know or care about multibyte characters. Assume we're
|
|
3391 |
using such a charset. We can't know that all of the upcoming rows
|
|
3392 |
for this column will have bytes that each render into some fraction
|
|
3393 |
of a character. It's at least possible that a row has bytes that
|
|
3394 |
all render into one character each, and so the maximum length is
|
|
3395 |
still the number of bytes. (Assumption 1: This can't be better
|
|
3396 |
because we can never know the number of characters that the DB is
|
|
3397 |
going to send -- only the number of bytes. 2: Chars <= Bytes.)
|
|
3398 |
||
3399 |
@param field Pointer to a field to be inspected
|
|
3400 |
||
3401 |
@returns number of character positions to be used, at most
|
|
1
by brian
clean slate |
3402 |
*/
|
928.1.1
by Eric Day
Started client changes. |
3403 |
static int get_field_disp_length(drizzle_column_st *field) |
1
by brian
clean slate |
3404 |
{
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3405 |
uint32_t length= column_names ? strlen(drizzle_column_name(field)) : 0; |
1
by brian
clean slate |
3406 |
|
3407 |
if (quick) |
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3408 |
length= max(length, drizzle_column_size(field)); |
1
by brian
clean slate |
3409 |
else
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3410 |
length= max(length, (uint32_t)drizzle_column_max_size(field)); |
1
by brian
clean slate |
3411 |
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3412 |
if (length < 4 && |
1441.3.1
by Vijay Samuel
all required updations have been made |
3413 |
!(drizzle_column_flags(field) & DRIZZLE_COLUMN_FLAGS_NOT_NULL)) |
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3414 |
{
|
206.3.1
by Patrick Galbraith
Most everything working with client rename |
3415 |
length= 4; /* Room for "NULL" */ |
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3416 |
}
|
1
by brian
clean slate |
3417 |
|
3418 |
return length; |
|
3419 |
}
|
|
3420 |
||
3421 |
/**
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
3422 |
For a new result, return the max number of characters that any
|
3423 |
upcoming row may return.
|
|
3424 |
||
3425 |
@param result Pointer to the result to judge
|
|
3426 |
||
3427 |
@returns The max number of characters in any row of this result
|
|
1
by brian
clean slate |
3428 |
*/
|
928.1.1
by Eric Day
Started client changes. |
3429 |
static int get_result_width(drizzle_result_st *result) |
1
by brian
clean slate |
3430 |
{
|
3431 |
unsigned int len= 0; |
|
928.1.1
by Eric Day
Started client changes. |
3432 |
drizzle_column_st *field; |
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3433 |
uint16_t offset; |
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
3434 |
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3435 |
offset= drizzle_column_current(result); |
142.1.2
by Patrick
All DBUG_x removed from client/ |
3436 |
assert(offset == 0); |
1
by brian
clean slate |
3437 |
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3438 |
while ((field= drizzle_column_next(result)) != NULL) |
1
by brian
clean slate |
3439 |
len+= get_field_disp_length(field) + 3; /* plus bar, space, & final space */ |
3440 |
||
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3441 |
(void) drizzle_column_seek(result, offset); |
1
by brian
clean slate |
3442 |
|
3443 |
return len + 1; /* plus final bar. */ |
|
3444 |
}
|
|
3445 |
||
3446 |
static void |
|
3447 |
tee_print_sized_data(const char *data, unsigned int data_length, unsigned int total_bytes_to_send, bool right_justified) |
|
3448 |
{
|
|
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
3449 |
/*
|
1
by brian
clean slate |
3450 |
For '\0's print ASCII spaces instead, as '\0' is eaten by (at
|
3451 |
least my) console driver, and that messes up the pretty table
|
|
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
3452 |
grid. (The \0 is also the reason we can't use fprintf() .)
|
1
by brian
clean slate |
3453 |
*/
|
3454 |
unsigned int i; |
|
3455 |
const char *p; |
|
3456 |
||
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
3457 |
if (right_justified) |
1
by brian
clean slate |
3458 |
for (i= data_length; i < total_bytes_to_send; i++) |
3459 |
tee_putc((int)' ', PAGER); |
|
3460 |
||
3461 |
for (i= 0, p= data; i < data_length; i+= 1, p+= 1) |
|
3462 |
{
|
|
3463 |
if (*p == '\0') |
|
3464 |
tee_putc((int)' ', PAGER); |
|
3465 |
else
|
|
3466 |
tee_putc((int)*p, PAGER); |
|
3467 |
}
|
|
3468 |
||
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
3469 |
if (! right_justified) |
1
by brian
clean slate |
3470 |
for (i= data_length; i < total_bytes_to_send; i++) |
3471 |
tee_putc((int)' ', PAGER); |
|
3472 |
}
|
|
3473 |
||
3474 |
||
3475 |
||
3476 |
static void |
|
928.1.1
by Eric Day
Started client changes. |
3477 |
print_table_data_vertically(drizzle_result_st *result) |
1
by brian
clean slate |
3478 |
{
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3479 |
drizzle_row_t cur; |
3480 |
drizzle_return_t ret; |
|
3481 |
uint32_t max_length=0; |
|
3482 |
drizzle_column_st *field; |
|
1
by brian
clean slate |
3483 |
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3484 |
while ((field = drizzle_column_next(result))) |
1
by brian
clean slate |
3485 |
{
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3486 |
uint32_t length= strlen(drizzle_column_name(field)); |
1
by brian
clean slate |
3487 |
if (length > max_length) |
3488 |
max_length= length; |
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3489 |
drizzle_column_set_max_size(field, length); |
1
by brian
clean slate |
3490 |
}
|
3491 |
||
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3492 |
for (uint32_t row_count=1;; row_count++) |
1
by brian
clean slate |
3493 |
{
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3494 |
if (quick) |
3495 |
{
|
|
3496 |
cur= drizzle_row_buffer(result, &ret); |
|
3497 |
if (ret != DRIZZLE_RETURN_OK) |
|
3498 |
{
|
|
3499 |
(void)put_error(&con, result); |
|
3500 |
break; |
|
3501 |
}
|
|
3502 |
}
|
|
3503 |
else
|
|
3504 |
cur= drizzle_row_next(result); |
|
3505 |
||
3506 |
if (cur == NULL || interrupted_query) |
|
1
by brian
clean slate |
3507 |
break; |
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3508 |
drizzle_column_seek(result,0); |
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
3509 |
tee_fprintf(PAGER, |
3510 |
"*************************** %d. row ***************************\n", row_count); |
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3511 |
for (uint32_t off=0; off < drizzle_result_column_count(result); off++) |
1
by brian
clean slate |
3512 |
{
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3513 |
field= drizzle_column_next(result); |
3514 |
tee_fprintf(PAGER, "%*s: ",(int) max_length,drizzle_column_name(field)); |
|
1
by brian
clean slate |
3515 |
tee_fprintf(PAGER, "%s\n",cur[off] ? (char*) cur[off] : "NULL"); |
3516 |
}
|
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3517 |
if (quick) |
3518 |
drizzle_row_free(result, cur); |
|
1
by brian
clean slate |
3519 |
}
|
3520 |
}
|
|
3521 |
||
3522 |
||
3523 |
/* print_warnings should be called right after executing a statement */
|
|
3524 |
||
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3525 |
static void print_warnings(uint32_t error_code) |
1
by brian
clean slate |
3526 |
{
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3527 |
const char *query; |
3528 |
drizzle_result_st result; |
|
3529 |
drizzle_row_t cur; |
|
157
by Brian Aker
Second pass cleanup on removal of my_uint types |
3530 |
uint64_t num_rows; |
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3531 |
uint32_t new_code= 0; |
1548.1.1
by Hartmut Holzgraefe
do not enable PAGER in print_warnings() when in batch mode (mysql bug #44732) |
3532 |
FILE *out; |
1
by brian
clean slate |
3533 |
|
3534 |
/* Get the warnings */
|
|
3535 |
query= "show warnings"; |
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3536 |
drizzleclient_real_query_for_lazy(query, strlen(query),&result,&new_code); |
840.1.21
by Monty Taylor
ZOMG. Renamed all the rest of the stuff in libdrizzleclient to be drizzleclient_*. I love commandline perl. |
3537 |
drizzleclient_store_result_for_lazy(&result); |
1
by brian
clean slate |
3538 |
|
3539 |
/* Bail out when no warnings */
|
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3540 |
if (!(num_rows= drizzle_result_row_count(&result))) |
1
by brian
clean slate |
3541 |
goto end; |
3542 |
||
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3543 |
cur= drizzle_row_next(&result); |
1
by brian
clean slate |
3544 |
|
3545 |
/*
|
|
3546 |
Don't print a duplicate of the current error. It is possible for SHOW
|
|
3547 |
WARNINGS to return multiple errors with the same code, but different
|
|
3548 |
messages. To be safe, skip printing the duplicate only if it is the only
|
|
3549 |
warning.
|
|
3550 |
*/
|
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3551 |
if (!cur || (num_rows == 1 && |
1441.3.1
by Vijay Samuel
all required updations have been made |
3552 |
error_code == (uint32_t) strtoul(cur[1], NULL, 10))) |
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3553 |
{
|
1
by brian
clean slate |
3554 |
goto end; |
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3555 |
}
|
1
by brian
clean slate |
3556 |
|
3557 |
/* Print the warnings */
|
|
1548.1.1
by Hartmut Holzgraefe
do not enable PAGER in print_warnings() when in batch mode (mysql bug #44732) |
3558 |
if (status.getBatch()) |
3559 |
{
|
|
1563
by Brian Aker
Merge Hartmut |
3560 |
out= stderr; |
1548.1.1
by Hartmut Holzgraefe
do not enable PAGER in print_warnings() when in batch mode (mysql bug #44732) |
3561 |
}
|
3562 |
else
|
|
3563 |
{
|
|
3564 |
init_pager(); |
|
1563
by Brian Aker
Merge Hartmut |
3565 |
out= PAGER; |
1548.1.1
by Hartmut Holzgraefe
do not enable PAGER in print_warnings() when in batch mode (mysql bug #44732) |
3566 |
}
|
1
by brian
clean slate |
3567 |
do
|
3568 |
{
|
|
1548.1.1
by Hartmut Holzgraefe
do not enable PAGER in print_warnings() when in batch mode (mysql bug #44732) |
3569 |
tee_fprintf(out, "%s (Code %s): %s\n", cur[0], cur[1], cur[2]); |
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3570 |
} while ((cur= drizzle_row_next(&result))); |
1563
by Brian Aker
Merge Hartmut |
3571 |
|
3572 |
if (not status.getBatch()) |
|
1548.1.1
by Hartmut Holzgraefe
do not enable PAGER in print_warnings() when in batch mode (mysql bug #44732) |
3573 |
end_pager(); |
1
by brian
clean slate |
3574 |
|
3575 |
end: |
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3576 |
drizzle_result_free(&result); |
1
by brian
clean slate |
3577 |
}
|
3578 |
||
3579 |
||
3580 |
static void |
|
288
by Brian Aker
ulong cleanp in client apps |
3581 |
safe_put_field(const char *pos,uint32_t length) |
1
by brian
clean slate |
3582 |
{
|
3583 |
if (!pos) |
|
3584 |
tee_fputs("NULL", PAGER); |
|
3585 |
else
|
|
3586 |
{
|
|
3587 |
if (opt_raw_data) |
|
3588 |
tee_fputs(pos, PAGER); |
|
3589 |
else for (const char *end=pos+length ; pos != end ; pos++) |
|
1085.3.3
by Monty Taylor
Got rid of #ifdef have utf8 stuff. |
3590 |
{
|
3591 |
int l; |
|
1567.3.20
by Monty Taylor
Removed UTF-8 lib that we don't use. |
3592 |
if ((l = drizzled::utf8::sequence_length(*pos))) |
1085.3.3
by Monty Taylor
Got rid of #ifdef have utf8 stuff. |
3593 |
{
|
3594 |
while (l--) |
|
3595 |
tee_putc(*pos++, PAGER); |
|
3596 |
pos--; |
|
3597 |
continue; |
|
3598 |
}
|
|
3599 |
if (!*pos) |
|
3600 |
tee_fputs("\\0", PAGER); // This makes everything hard |
|
3601 |
else if (*pos == '\t') |
|
3602 |
tee_fputs("\\t", PAGER); // This would destroy tab format |
|
3603 |
else if (*pos == '\n') |
|
3604 |
tee_fputs("\\n", PAGER); // This too |
|
3605 |
else if (*pos == '\\') |
|
3606 |
tee_fputs("\\\\", PAGER); |
|
3607 |
else
|
|
3608 |
tee_putc(*pos, PAGER); |
|
3609 |
}
|
|
1
by brian
clean slate |
3610 |
}
|
3611 |
}
|
|
3612 |
||
3613 |
||
3614 |
static void |
|
928.1.1
by Eric Day
Started client changes. |
3615 |
print_tab_data(drizzle_result_st *result) |
1
by brian
clean slate |
3616 |
{
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3617 |
drizzle_row_t cur; |
3618 |
drizzle_return_t ret; |
|
3619 |
drizzle_column_st *field; |
|
3620 |
size_t *lengths; |
|
2187.3.4
by Andrew Hutchings
Fix BOOLEAN type for batch mode |
3621 |
std::vector<bool> boolean_flag; |
2187.3.6
by Monty Taylor
Actually differentiate with the flag and fix up client output properly. |
3622 |
std::vector<bool> ansi_boolean_flag; |
2187.3.4
by Andrew Hutchings
Fix BOOLEAN type for batch mode |
3623 |
|
3624 |
boolean_flag.resize(drizzle_result_column_count(result)); |
|
2187.3.6
by Monty Taylor
Actually differentiate with the flag and fix up client output properly. |
3625 |
ansi_boolean_flag.resize(drizzle_result_column_count(result)); |
2187.3.4
by Andrew Hutchings
Fix BOOLEAN type for batch mode |
3626 |
|
3627 |
int first=0; |
|
3628 |
for (uint32_t off= 0; (field = drizzle_column_next(result)); off++) |
|
1
by brian
clean slate |
3629 |
{
|
2187.3.4
by Andrew Hutchings
Fix BOOLEAN type for batch mode |
3630 |
if (opt_silent < 2 && column_names) |
1
by brian
clean slate |
3631 |
{
|
3632 |
if (first++) |
|
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
3633 |
(void) tee_fputs("\t", PAGER); |
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3634 |
(void) tee_fputs(drizzle_column_name(field), PAGER); |
1
by brian
clean slate |
3635 |
}
|
2187.3.4
by Andrew Hutchings
Fix BOOLEAN type for batch mode |
3636 |
if ((server_type == ServerDetect::SERVER_DRIZZLE_FOUND) and |
3637 |
(drizzle_column_type(field) == DRIZZLE_COLUMN_TYPE_TINY)) |
|
3638 |
{
|
|
2187.3.6
by Monty Taylor
Actually differentiate with the flag and fix up client output properly. |
3639 |
if ((drizzle_column_flags(field) & DRIZZLE_COLUMN_FLAGS_UNSIGNED)) |
3640 |
{
|
|
3641 |
ansi_boolean_flag[off]= true; |
|
3642 |
}
|
|
3643 |
else
|
|
3644 |
{
|
|
3645 |
ansi_boolean_flag[off]= false; |
|
3646 |
}
|
|
2187.3.4
by Andrew Hutchings
Fix BOOLEAN type for batch mode |
3647 |
boolean_flag[off]= true; |
3648 |
}
|
|
3649 |
else
|
|
3650 |
{
|
|
3651 |
boolean_flag[off]= false; |
|
3652 |
}
|
|
3653 |
}
|
|
3654 |
if (opt_silent < 2 && column_names) |
|
3655 |
{
|
|
1
by brian
clean slate |
3656 |
(void) tee_fputs("\n", PAGER); |
3657 |
}
|
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3658 |
while (1) |
1
by brian
clean slate |
3659 |
{
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3660 |
if (quick) |
3661 |
{
|
|
3662 |
cur= drizzle_row_buffer(result, &ret); |
|
3663 |
if (ret != DRIZZLE_RETURN_OK) |
|
3664 |
{
|
|
3665 |
(void)put_error(&con, result); |
|
3666 |
break; |
|
3667 |
}
|
|
3668 |
}
|
|
3669 |
else
|
|
3670 |
cur= drizzle_row_next(result); |
|
3671 |
||
3672 |
if (cur == NULL) |
|
3673 |
break; |
|
3674 |
||
3675 |
lengths= drizzle_row_field_sizes(result); |
|
2187.3.4
by Andrew Hutchings
Fix BOOLEAN type for batch mode |
3676 |
drizzle_column_seek(result, 0); |
3677 |
for (uint32_t off=0 ; off < drizzle_result_column_count(result); off++) |
|
1
by brian
clean slate |
3678 |
{
|
2187.3.4
by Andrew Hutchings
Fix BOOLEAN type for batch mode |
3679 |
if (off != 0) |
3680 |
(void) tee_fputs("\t", PAGER); |
|
3681 |
if (boolean_flag[off]) |
|
3682 |
{
|
|
3683 |
if (strncmp(cur[off],"1", 1) == 0) |
|
2187.3.6
by Monty Taylor
Actually differentiate with the flag and fix up client output properly. |
3684 |
{
|
3685 |
if (ansi_boolean_flag[off]) |
|
3686 |
{
|
|
3687 |
safe_put_field("YES", 3); |
|
3688 |
}
|
|
3689 |
else
|
|
3690 |
{
|
|
3691 |
safe_put_field("TRUE", 4); |
|
3692 |
}
|
|
3693 |
}
|
|
2187.3.4
by Andrew Hutchings
Fix BOOLEAN type for batch mode |
3694 |
else
|
2187.3.6
by Monty Taylor
Actually differentiate with the flag and fix up client output properly. |
3695 |
{
|
3696 |
if (ansi_boolean_flag[off]) |
|
3697 |
{
|
|
3698 |
safe_put_field("NO", 2); |
|
3699 |
}
|
|
3700 |
else
|
|
3701 |
{
|
|
3702 |
safe_put_field("FALSE", 5); |
|
3703 |
}
|
|
3704 |
}
|
|
2187.3.4
by Andrew Hutchings
Fix BOOLEAN type for batch mode |
3705 |
}
|
3706 |
else
|
|
3707 |
{
|
|
3708 |
safe_put_field(cur[off], lengths[off]); |
|
3709 |
}
|
|
1
by brian
clean slate |
3710 |
}
|
3711 |
(void) tee_fputs("\n", PAGER); |
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
3712 |
if (quick) |
3713 |
drizzle_row_free(result, cur); |
|
1
by brian
clean slate |
3714 |
}
|
3715 |
}
|
|
3716 |
||
3717 |
static int |
|
632.1.12
by Monty Taylor
Fixed more sun studio warnings. |
3718 |
com_tee(string *, const char *line ) |
1
by brian
clean slate |
3719 |
{
|
520.4.43
by mordred
A set of Solaris fixes. |
3720 |
char file_name[FN_REFLEN], *end; |
3721 |
const char *param; |
|
1
by brian
clean slate |
3722 |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
3723 |
if (status.getBatch()) |
1
by brian
clean slate |
3724 |
return 0; |
1567.3.14
by Monty Taylor
Removed the need for drizzled::internal usage in drizzle.cc. |
3725 |
while (isspace(*line)) |
1
by brian
clean slate |
3726 |
line++; |
1567.3.17
by Monty Taylor
Removed more C-string strings. replaced with std::string. |
3727 |
if (!(param =strchr(line, ' '))) // if outfile wasn't given, use the default |
1
by brian
clean slate |
3728 |
{
|
1567.3.17
by Monty Taylor
Removed more C-string strings. replaced with std::string. |
3729 |
if (outfile.empty()) |
1
by brian
clean slate |
3730 |
{
|
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
3731 |
printf(_("No previous outfile available, you must give a filename!\n")); |
1
by brian
clean slate |
3732 |
return 0; |
3733 |
}
|
|
3734 |
else if (opt_outfile) |
|
3735 |
{
|
|
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
3736 |
tee_fprintf(stdout, _("Currently logging to file '%s'\n"), outfile.c_str()); |
1
by brian
clean slate |
3737 |
return 0; |
3738 |
}
|
|
3739 |
else
|
|
1567.3.17
by Monty Taylor
Removed more C-string strings. replaced with std::string. |
3740 |
param= outfile.c_str(); //resume using the old outfile |
1
by brian
clean slate |
3741 |
}
|
3742 |
||
1567.3.17
by Monty Taylor
Removed more C-string strings. replaced with std::string. |
3743 |
/* @TODO: Replace this with string methods */
|
1
by brian
clean slate |
3744 |
/* eliminate the spaces before the parameters */
|
1567.3.14
by Monty Taylor
Removed the need for drizzled::internal usage in drizzle.cc. |
3745 |
while (isspace(*param)) |
1
by brian
clean slate |
3746 |
param++; |
629.5.3
by Toru Maesaka
Third pass of replacing MySQL's strmake() with libc calls |
3747 |
strncpy(file_name, param, sizeof(file_name) - 1); |
3748 |
end= file_name + strlen(file_name); |
|
1
by brian
clean slate |
3749 |
/* remove end space from command line */
|
1567.3.14
by Monty Taylor
Removed the need for drizzled::internal usage in drizzle.cc. |
3750 |
while (end > file_name && (isspace(end[-1]) || |
3751 |
iscntrl(end[-1]))) |
|
1
by brian
clean slate |
3752 |
end--; |
3753 |
end[0]= 0; |
|
3754 |
if (end == file_name) |
|
3755 |
{
|
|
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
3756 |
printf(_("No outfile specified!\n")); |
1
by brian
clean slate |
3757 |
return 0; |
3758 |
}
|
|
3759 |
init_tee(file_name); |
|
3760 |
return 0; |
|
3761 |
}
|
|
3762 |
||
3763 |
||
3764 |
static int |
|
632.1.12
by Monty Taylor
Fixed more sun studio warnings. |
3765 |
com_notee(string *, const char *) |
1
by brian
clean slate |
3766 |
{
|
3767 |
if (opt_outfile) |
|
3768 |
end_tee(); |
|
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
3769 |
tee_fprintf(stdout, _("Outfile disabled.\n")); |
1
by brian
clean slate |
3770 |
return 0; |
3771 |
}
|
|
3772 |
||
3773 |
/*
|
|
3774 |
Sorry, this command is not available in Windows.
|
|
3775 |
*/
|
|
3776 |
||
3777 |
static int |
|
632.1.12
by Monty Taylor
Fixed more sun studio warnings. |
3778 |
com_pager(string *, const char *line) |
1
by brian
clean slate |
3779 |
{
|
520.4.43
by mordred
A set of Solaris fixes. |
3780 |
const char *param; |
1
by brian
clean slate |
3781 |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
3782 |
if (status.getBatch()) |
1
by brian
clean slate |
3783 |
return 0; |
3784 |
/* Skip spaces in front of the pager command */
|
|
1567.3.14
by Monty Taylor
Removed the need for drizzled::internal usage in drizzle.cc. |
3785 |
while (isspace(*line)) |
1
by brian
clean slate |
3786 |
line++; |
3787 |
/* Skip the pager command */
|
|
3788 |
param= strchr(line, ' '); |
|
3789 |
/* Skip the spaces between the command and the argument */
|
|
1567.3.14
by Monty Taylor
Removed the need for drizzled::internal usage in drizzle.cc. |
3790 |
while (param && isspace(*param)) |
1
by brian
clean slate |
3791 |
param++; |
1883.3.1
by Andrew Hutchings
Cleanup drizzledump and drizzle for cppcheck |
3792 |
if (!param || (*param == '\0')) // if pager was not given, use the default |
1
by brian
clean slate |
3793 |
{
|
3794 |
if (!default_pager_set) |
|
3795 |
{
|
|
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
3796 |
tee_fprintf(stdout, _("Default pager wasn't set, using stdout.\n")); |
1
by brian
clean slate |
3797 |
opt_nopager=1; |
1567.3.17
by Monty Taylor
Removed more C-string strings. replaced with std::string. |
3798 |
pager.assign("stdout"); |
1
by brian
clean slate |
3799 |
PAGER= stdout; |
3800 |
return 0; |
|
3801 |
}
|
|
1567.3.17
by Monty Taylor
Removed more C-string strings. replaced with std::string. |
3802 |
pager.assign(default_pager); |
1
by brian
clean slate |
3803 |
}
|
3804 |
else
|
|
3805 |
{
|
|
1567.3.17
by Monty Taylor
Removed more C-string strings. replaced with std::string. |
3806 |
string pager_name(param); |
3807 |
string::iterator end= pager_name.end(); |
|
3808 |
while (end > pager_name.begin() && |
|
3809 |
(isspace(*(end-1)) || iscntrl(*(end-1)))) |
|
3810 |
--end; |
|
3811 |
pager_name.erase(end, pager_name.end()); |
|
3812 |
pager.assign(pager_name); |
|
3813 |
default_pager.assign(pager_name); |
|
1
by brian
clean slate |
3814 |
}
|
3815 |
opt_nopager=0; |
|
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
3816 |
tee_fprintf(stdout, _("PAGER set to '%s'\n"), pager.c_str()); |
1
by brian
clean slate |
3817 |
return 0; |
3818 |
}
|
|
3819 |
||
3820 |
||
3821 |
static int |
|
632.1.12
by Monty Taylor
Fixed more sun studio warnings. |
3822 |
com_nopager(string *, const char *) |
1
by brian
clean slate |
3823 |
{
|
1567.3.17
by Monty Taylor
Removed more C-string strings. replaced with std::string. |
3824 |
pager.assign("stdout"); |
1
by brian
clean slate |
3825 |
opt_nopager=1; |
3826 |
PAGER= stdout; |
|
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
3827 |
tee_fprintf(stdout, _("PAGER set to stdout\n")); |
1
by brian
clean slate |
3828 |
return 0; |
3829 |
}
|
|
3830 |
||
3831 |
/* If arg is given, exit without errors. This happens on command 'quit' */
|
|
3832 |
||
3833 |
static int |
|
632.1.12
by Monty Taylor
Fixed more sun studio warnings. |
3834 |
com_quit(string *, const char *) |
1
by brian
clean slate |
3835 |
{
|
3836 |
/* let the screen auto close on a normal shutdown */
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
3837 |
status.setExitStatus(0); |
1
by brian
clean slate |
3838 |
return 1; |
3839 |
}
|
|
3840 |
||
3841 |
static int |
|
632.1.12
by Monty Taylor
Fixed more sun studio warnings. |
3842 |
com_rehash(string *, const char *) |
1
by brian
clean slate |
3843 |
{
|
3844 |
build_completion_hash(1, 0); |
|
3845 |
return 0; |
|
3846 |
}
|
|
3847 |
||
3848 |
||
3849 |
||
3850 |
static int |
|
632.1.12
by Monty Taylor
Fixed more sun studio warnings. |
3851 |
com_print(string *buffer,const char *) |
1
by brian
clean slate |
3852 |
{
|
3853 |
tee_puts("--------------", stdout); |
|
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
3854 |
(void) tee_fputs(buffer->c_str(), stdout); |
3855 |
if ( (buffer->length() == 0) |
|
3856 |
|| (buffer->c_str())[(buffer->length())-1] != '\n') |
|
1
by brian
clean slate |
3857 |
tee_putc('\n', stdout); |
3858 |
tee_puts("--------------\n", stdout); |
|
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
3859 |
/* If empty buffer */
|
3860 |
return 0; |
|
1
by brian
clean slate |
3861 |
}
|
3862 |
||
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
3863 |
/* ARGSUSED */
|
1
by brian
clean slate |
3864 |
static int |
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
3865 |
com_connect(string *buffer, const char *line) |
1
by brian
clean slate |
3866 |
{
|
3867 |
char *tmp, buff[256]; |
|
3868 |
bool save_rehash= opt_rehash; |
|
3869 |
int error; |
|
3870 |
||
212.6.1
by Mats Kindahl
Replacing all bzero() calls with memset() calls and removing the bzero.c file. |
3871 |
memset(buff, 0, sizeof(buff)); |
1
by brian
clean slate |
3872 |
if (buffer) |
3873 |
{
|
|
3874 |
/*
|
|
3875 |
Two null bytes are needed in the end of buff to allow
|
|
3876 |
get_arg to find end of string the second time it's called.
|
|
3877 |
*/
|
|
629.5.3
by Toru Maesaka
Third pass of replacing MySQL's strmake() with libc calls |
3878 |
tmp= strncpy(buff, line, sizeof(buff)-2); |
1
by brian
clean slate |
3879 |
#ifdef EXTRA_DEBUG
|
3880 |
tmp[1]= 0; |
|
3881 |
#endif
|
|
3882 |
tmp= get_arg(buff, 0); |
|
3883 |
if (tmp && *tmp) |
|
3884 |
{
|
|
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
3885 |
current_db.erase(); |
1593.1.4
by Vijay Samuel
Merge Fixes for client drizzle. |
3886 |
current_db.assign(tmp); |
1
by brian
clean slate |
3887 |
tmp= get_arg(buff, 1); |
3888 |
if (tmp) |
|
3889 |
{
|
|
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
3890 |
current_host.erase(); |
182.1.2
by Jim Winstead
Various fixes to enable compilation on Mac OS X, and remove the glib dependency. |
3891 |
current_host=strdup(tmp); |
1
by brian
clean slate |
3892 |
}
|
3893 |
}
|
|
3894 |
else
|
|
3895 |
{
|
|
3896 |
/* Quick re-connect */
|
|
971.6.11
by Eric Day
Removed purecov messages. |
3897 |
opt_rehash= 0; |
1
by brian
clean slate |
3898 |
}
|
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
3899 |
// command used
|
77.3.3
by Monty Taylor
Last change to migrate to glib from sql_string. |
3900 |
assert(buffer!=NULL); |
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
3901 |
buffer->clear(); |
1
by brian
clean slate |
3902 |
}
|
3903 |
else
|
|
3904 |
opt_rehash= 0; |
|
2053.2.1
by Andrew Hutchings
Fix hidden connect messages |
3905 |
error=sql_connect(current_host, current_db, current_user, opt_password); |
1
by brian
clean slate |
3906 |
opt_rehash= save_rehash; |
3907 |
||
3908 |
if (connected) |
|
3909 |
{
|
|
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
3910 |
sprintf(buff, _("Connection id: %u"), drizzle_con_thread_id(&con)); |
77.3.7
by Monty Taylor
Made mysql into a pure-C program. |
3911 |
put_info(buff,INFO_INFO,0,0); |
2005.2.2
by Andrew Hutchings
Change most places to use 'schema' instead of 'database' |
3912 |
sprintf(buff, _("Current schema: %.128s\n"), |
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
3913 |
!current_db.empty() ? current_db.c_str() : _("*** NONE ***")); |
77.3.7
by Monty Taylor
Made mysql into a pure-C program. |
3914 |
put_info(buff,INFO_INFO,0,0); |
1
by brian
clean slate |
3915 |
}
|
3916 |
return error; |
|
3917 |
}
|
|
3918 |
||
3919 |
||
632.1.12
by Monty Taylor
Fixed more sun studio warnings. |
3920 |
static int com_source(string *, const char *line) |
1
by brian
clean slate |
3921 |
{
|
520.4.43
by mordred
A set of Solaris fixes. |
3922 |
char source_name[FN_REFLEN], *end; |
3923 |
const char *param; |
|
1095.2.1
by Robert Klahn
Replace typedef struct LINE_BUFFER with class LineBuffer, encapsulating current logic |
3924 |
LineBuffer *line_buff; |
1
by brian
clean slate |
3925 |
int error; |
1441.3.1
by Vijay Samuel
all required updations have been made |
3926 |
Status old_status; |
1
by brian
clean slate |
3927 |
FILE *sql_file; |
3928 |
||
3929 |
/* Skip space from file name */
|
|
1567.3.14
by Monty Taylor
Removed the need for drizzled::internal usage in drizzle.cc. |
3930 |
while (isspace(*line)) |
1
by brian
clean slate |
3931 |
line++; |
206.3.1
by Patrick Galbraith
Most everything working with client rename |
3932 |
if (!(param = strchr(line, ' '))) // Skip command name |
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
3933 |
return put_info(_("Usage: \\. <filename> | source <filename>"), |
77.3.7
by Monty Taylor
Made mysql into a pure-C program. |
3934 |
INFO_ERROR, 0,0); |
1567.3.14
by Monty Taylor
Removed the need for drizzled::internal usage in drizzle.cc. |
3935 |
while (isspace(*param)) |
1
by brian
clean slate |
3936 |
param++; |
629.5.3
by Toru Maesaka
Third pass of replacing MySQL's strmake() with libc calls |
3937 |
end= strncpy(source_name,param,sizeof(source_name)-1); |
3938 |
end+= strlen(source_name); |
|
1567.3.14
by Monty Taylor
Removed the need for drizzled::internal usage in drizzle.cc. |
3939 |
while (end > source_name && (isspace(end[-1]) || |
3940 |
iscntrl(end[-1]))) |
|
1
by brian
clean slate |
3941 |
end--; |
3942 |
end[0]=0; |
|
1567.3.14
by Monty Taylor
Removed the need for drizzled::internal usage in drizzle.cc. |
3943 |
|
1
by brian
clean slate |
3944 |
/* open file name */
|
910.1.3
by Brian Aker
Remove my_fopen() and key_map.cc file (thanks to Jay's lcov) |
3945 |
if (!(sql_file = fopen(source_name, "r"))) |
1
by brian
clean slate |
3946 |
{
|
3947 |
char buff[FN_REFLEN+60]; |
|
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
3948 |
sprintf(buff, _("Failed to open file '%s', error: %d"), source_name,errno); |
77.3.7
by Monty Taylor
Made mysql into a pure-C program. |
3949 |
return put_info(buff, INFO_ERROR, 0 ,0); |
1
by brian
clean slate |
3950 |
}
|
3951 |
||
2246.3.1
by Olaf van der Spek
Remove std::nothrow from new() |
3952 |
line_buff= new LineBuffer(opt_max_input_line,sql_file); |
1
by brian
clean slate |
3953 |
|
3954 |
/* Save old status */
|
|
3955 |
old_status=status; |
|
212.6.10
by Mats Kindahl
Removing redundant use of casts in client/ for memcmp(), memcpy(), memset(), and memmove(). |
3956 |
memset(&status, 0, sizeof(status)); |
1
by brian
clean slate |
3957 |
|
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
3958 |
// Run in batch mode
|
1441.3.1
by Vijay Samuel
all required updations have been made |
3959 |
status.setBatch(old_status.getBatch()); |
3960 |
status.setLineBuff(line_buff); |
|
3961 |
status.setFileName(source_name); |
|
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
3962 |
// Empty command buffer
|
77.3.3
by Monty Taylor
Last change to migrate to glib from sql_string. |
3963 |
assert(glob_buffer!=NULL); |
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
3964 |
glob_buffer->clear(); |
1
by brian
clean slate |
3965 |
error= read_and_execute(false); |
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
3966 |
// Continue as before
|
3967 |
status=old_status; |
|
910.1.3
by Brian Aker
Remove my_fopen() and key_map.cc file (thanks to Jay's lcov) |
3968 |
fclose(sql_file); |
1441.3.1
by Vijay Samuel
all required updations have been made |
3969 |
delete status.getLineBuff(); |
3970 |
line_buff=0; |
|
3971 |
status.setLineBuff(0); |
|
1
by brian
clean slate |
3972 |
return error; |
3973 |
}
|
|
3974 |
||
3975 |
||
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
3976 |
/* ARGSUSED */
|
1
by brian
clean slate |
3977 |
static int |
632.1.12
by Monty Taylor
Fixed more sun studio warnings. |
3978 |
com_delimiter(string *, const char *line) |
1
by brian
clean slate |
3979 |
{
|
3980 |
char buff[256], *tmp; |
|
3981 |
||
629.5.1
by Toru Maesaka
First pass of replacing MySQL's strmake() with libc calls |
3982 |
strncpy(buff, line, sizeof(buff) - 1); |
1
by brian
clean slate |
3983 |
tmp= get_arg(buff, 0); |
3984 |
||
3985 |
if (!tmp || !*tmp) |
|
3986 |
{
|
|
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
3987 |
put_info(_("DELIMITER must be followed by a 'delimiter' character or string"), |
77.3.7
by Monty Taylor
Made mysql into a pure-C program. |
3988 |
INFO_ERROR, 0, 0); |
1
by brian
clean slate |
3989 |
return 0; |
3990 |
}
|
|
3991 |
else
|
|
3992 |
{
|
|
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
3993 |
if (strstr(tmp, "\\")) |
1
by brian
clean slate |
3994 |
{
|
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
3995 |
put_info(_("DELIMITER cannot contain a backslash character"), |
77.3.7
by Monty Taylor
Made mysql into a pure-C program. |
3996 |
INFO_ERROR, 0, 0); |
1
by brian
clean slate |
3997 |
return 0; |
3998 |
}
|
|
3999 |
}
|
|
629.5.1
by Toru Maesaka
First pass of replacing MySQL's strmake() with libc calls |
4000 |
strncpy(delimiter, tmp, sizeof(delimiter) - 1); |
1
by brian
clean slate |
4001 |
delimiter_length= (int)strlen(delimiter); |
4002 |
delimiter_str= delimiter; |
|
4003 |
return 0; |
|
4004 |
}
|
|
4005 |
||
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
4006 |
/* ARGSUSED */
|
1
by brian
clean slate |
4007 |
static int |
632.1.12
by Monty Taylor
Fixed more sun studio warnings. |
4008 |
com_use(string *, const char *line) |
1
by brian
clean slate |
4009 |
{
|
4010 |
char *tmp, buff[FN_REFLEN + 1]; |
|
4011 |
int select_db; |
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
4012 |
drizzle_result_st result; |
4013 |
drizzle_return_t ret; |
|
1
by brian
clean slate |
4014 |
|
212.6.1
by Mats Kindahl
Replacing all bzero() calls with memset() calls and removing the bzero.c file. |
4015 |
memset(buff, 0, sizeof(buff)); |
629.5.1
by Toru Maesaka
First pass of replacing MySQL's strmake() with libc calls |
4016 |
strncpy(buff, line, sizeof(buff) - 1); |
1
by brian
clean slate |
4017 |
tmp= get_arg(buff, 0); |
4018 |
if (!tmp || !*tmp) |
|
4019 |
{
|
|
2005.2.2
by Andrew Hutchings
Change most places to use 'schema' instead of 'database' |
4020 |
put_info(_("USE must be followed by a schema name"), INFO_ERROR, 0, 0); |
1
by brian
clean slate |
4021 |
return 0; |
4022 |
}
|
|
4023 |
/*
|
|
4024 |
We need to recheck the current database, because it may change
|
|
4025 |
under our feet, for example if DROP DATABASE or RENAME DATABASE
|
|
4026 |
(latter one not yet available by the time the comment was written)
|
|
4027 |
*/
|
|
4028 |
get_current_db(); |
|
4029 |
||
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
4030 |
if (current_db.empty() || strcmp(current_db.c_str(),tmp)) |
1
by brian
clean slate |
4031 |
{
|
4032 |
if (one_database) |
|
4033 |
{
|
|
4034 |
skip_updates= 1; |
|
840.1.21
by Monty Taylor
ZOMG. Renamed all the rest of the stuff in libdrizzleclient to be drizzleclient_*. I love commandline perl. |
4035 |
select_db= 0; // don't do drizzleclient_select_db() |
1
by brian
clean slate |
4036 |
}
|
4037 |
else
|
|
840.1.21
by Monty Taylor
ZOMG. Renamed all the rest of the stuff in libdrizzleclient to be drizzleclient_*. I love commandline perl. |
4038 |
select_db= 2; // do drizzleclient_select_db() and build_completion_hash() |
1
by brian
clean slate |
4039 |
}
|
4040 |
else
|
|
4041 |
{
|
|
4042 |
/*
|
|
4043 |
USE to the current db specified.
|
|
840.1.21
by Monty Taylor
ZOMG. Renamed all the rest of the stuff in libdrizzleclient to be drizzleclient_*. I love commandline perl. |
4044 |
We do need to send drizzleclient_select_db() to make server
|
1
by brian
clean slate |
4045 |
update database level privileges, which might
|
4046 |
change since last USE (see bug#10979).
|
|
4047 |
For performance purposes, we'll skip rebuilding of completion hash.
|
|
4048 |
*/
|
|
4049 |
skip_updates= 0; |
|
840.1.21
by Monty Taylor
ZOMG. Renamed all the rest of the stuff in libdrizzleclient to be drizzleclient_*. I love commandline perl. |
4050 |
select_db= 1; // do only drizzleclient_select_db(), without completion |
1
by brian
clean slate |
4051 |
}
|
4052 |
||
4053 |
if (select_db) |
|
4054 |
{
|
|
4055 |
/*
|
|
4056 |
reconnect once if connection is down or if connection was found to
|
|
4057 |
be down during query
|
|
4058 |
*/
|
|
4059 |
if (!connected && reconnect()) |
|
4060 |
return opt_reconnect ? -1 : 1; // Fatal error |
|
928.1.4
by Eric Day
Fixed a few bugs, more progress on conversion. |
4061 |
for (bool try_again= true; try_again; try_again= false) |
1
by brian
clean slate |
4062 |
{
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
4063 |
if (drizzle_select_db(&con,&result,tmp,&ret) == NULL || |
4064 |
ret != DRIZZLE_RETURN_OK) |
|
4065 |
{
|
|
4066 |
if (ret == DRIZZLE_RETURN_ERROR_CODE) |
|
4067 |
{
|
|
4068 |
int error= put_error(&con, &result); |
|
4069 |
drizzle_result_free(&result); |
|
4070 |
return error; |
|
4071 |
}
|
|
4072 |
||
4073 |
if (ret != DRIZZLE_RETURN_SERVER_GONE || !try_again) |
|
4074 |
return put_error(&con, NULL); |
|
4075 |
||
4076 |
if (reconnect()) |
|
4077 |
return opt_reconnect ? -1 : 1; // Fatal error |
|
4078 |
}
|
|
928.1.4
by Eric Day
Fixed a few bugs, more progress on conversion. |
4079 |
else
|
4080 |
drizzle_result_free(&result); |
|
1
by brian
clean slate |
4081 |
}
|
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
4082 |
current_db.erase(); |
1593.1.4
by Vijay Samuel
Merge Fixes for client drizzle. |
4083 |
current_db.assign(tmp); |
1
by brian
clean slate |
4084 |
if (select_db > 1) |
4085 |
build_completion_hash(opt_rehash, 1); |
|
4086 |
}
|
|
4087 |
||
2005.2.2
by Andrew Hutchings
Change most places to use 'schema' instead of 'database' |
4088 |
put_info(_("Schema changed"),INFO_INFO, 0, 0); |
1
by brian
clean slate |
4089 |
return 0; |
4090 |
}
|
|
4091 |
||
1954
by Brian Aker
This adds the command "shutdown" to the command line client. It does require |
4092 |
static int com_shutdown(string *, const char *) |
4093 |
{
|
|
4094 |
drizzle_result_st result; |
|
4095 |
drizzle_return_t ret; |
|
4096 |
||
4097 |
if (verbose) |
|
4098 |
{
|
|
4099 |
printf(_("shutting down drizzled")); |
|
4100 |
if (opt_drizzle_port > 0) |
|
4101 |
printf(_(" on port %d"), opt_drizzle_port); |
|
4102 |
printf("... "); |
|
4103 |
}
|
|
4104 |
||
4105 |
if (drizzle_shutdown(&con, &result, DRIZZLE_SHUTDOWN_DEFAULT, |
|
4106 |
&ret) == NULL || ret != DRIZZLE_RETURN_OK) |
|
4107 |
{
|
|
4108 |
if (ret == DRIZZLE_RETURN_ERROR_CODE) |
|
4109 |
{
|
|
4110 |
fprintf(stderr, _("shutdown failed; error: '%s'"), |
|
4111 |
drizzle_result_error(&result)); |
|
4112 |
drizzle_result_free(&result); |
|
4113 |
}
|
|
4114 |
else
|
|
4115 |
{
|
|
4116 |
fprintf(stderr, _("shutdown failed; error: '%s'"), |
|
4117 |
drizzle_con_error(&con)); |
|
4118 |
}
|
|
4119 |
return false; |
|
4120 |
}
|
|
4121 |
||
4122 |
drizzle_result_free(&result); |
|
4123 |
||
4124 |
if (verbose) |
|
4125 |
printf(_("done\n")); |
|
4126 |
||
4127 |
return false; |
|
4128 |
}
|
|
4129 |
||
1
by brian
clean slate |
4130 |
static int |
632.1.12
by Monty Taylor
Fixed more sun studio warnings. |
4131 |
com_warnings(string *, const char *) |
1
by brian
clean slate |
4132 |
{
|
4133 |
show_warnings = 1; |
|
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
4134 |
put_info(_("Show warnings enabled."),INFO_INFO, 0, 0); |
1
by brian
clean slate |
4135 |
return 0; |
4136 |
}
|
|
4137 |
||
4138 |
static int |
|
632.1.12
by Monty Taylor
Fixed more sun studio warnings. |
4139 |
com_nowarnings(string *, const char *) |
1
by brian
clean slate |
4140 |
{
|
4141 |
show_warnings = 0; |
|
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
4142 |
put_info(_("Show warnings disabled."),INFO_INFO, 0, 0); |
1
by brian
clean slate |
4143 |
return 0; |
4144 |
}
|
|
4145 |
||
4146 |
/*
|
|
4147 |
Gets argument from a command on the command line. If get_next_arg is
|
|
4148 |
not defined, skips the command and returns the first argument. The
|
|
4149 |
line is modified by adding zero to the end of the argument. If
|
|
4150 |
get_next_arg is defined, then the function searches for end of string
|
|
4151 |
first, after found, returns the next argument and adds zero to the
|
|
4152 |
end. If you ever wish to use this feature, remember to initialize all
|
|
4153 |
items in the array to zero first.
|
|
4154 |
*/
|
|
4155 |
||
143
by Brian Aker
Bool cleanup. |
4156 |
char *get_arg(char *line, bool get_next_arg) |
1
by brian
clean slate |
4157 |
{
|
4158 |
char *ptr, *start; |
|
143
by Brian Aker
Bool cleanup. |
4159 |
bool quoted= 0, valid_arg= 0; |
1
by brian
clean slate |
4160 |
char qtype= 0; |
4161 |
||
4162 |
ptr= line; |
|
4163 |
if (get_next_arg) |
|
4164 |
{
|
|
4165 |
for (; *ptr; ptr++) ; |
|
4166 |
if (*(ptr + 1)) |
|
4167 |
ptr++; |
|
4168 |
}
|
|
4169 |
else
|
|
4170 |
{
|
|
4171 |
/* skip leading white spaces */
|
|
1567.3.14
by Monty Taylor
Removed the need for drizzled::internal usage in drizzle.cc. |
4172 |
while (isspace(*ptr)) |
1
by brian
clean slate |
4173 |
ptr++; |
4174 |
if (*ptr == '\\') // short command was used |
|
4175 |
ptr+= 2; |
|
4176 |
else
|
|
1567.3.14
by Monty Taylor
Removed the need for drizzled::internal usage in drizzle.cc. |
4177 |
while (*ptr &&!isspace(*ptr)) // skip command |
1
by brian
clean slate |
4178 |
ptr++; |
4179 |
}
|
|
4180 |
if (!*ptr) |
|
461
by Monty Taylor
Removed NullS. bu-bye. |
4181 |
return NULL; |
1567.3.14
by Monty Taylor
Removed the need for drizzled::internal usage in drizzle.cc. |
4182 |
while (isspace(*ptr)) |
1
by brian
clean slate |
4183 |
ptr++; |
4184 |
if (*ptr == '\'' || *ptr == '\"' || *ptr == '`') |
|
4185 |
{
|
|
4186 |
qtype= *ptr; |
|
4187 |
quoted= 1; |
|
4188 |
ptr++; |
|
4189 |
}
|
|
4190 |
for (start=ptr ; *ptr; ptr++) |
|
4191 |
{
|
|
4192 |
if (*ptr == '\\' && ptr[1]) // escaped character |
|
4193 |
{
|
|
4194 |
// Remove the backslash
|
|
641.4.1
by Toru Maesaka
First pass of replacing MySQL's my_stpcpy() with appropriate libc calls |
4195 |
strcpy(ptr, ptr+1); |
1
by brian
clean slate |
4196 |
}
|
4197 |
else if ((!quoted && *ptr == ' ') || (quoted && *ptr == qtype)) |
|
4198 |
{
|
|
4199 |
*ptr= 0; |
|
4200 |
break; |
|
4201 |
}
|
|
4202 |
}
|
|
4203 |
valid_arg= ptr != start; |
|
461
by Monty Taylor
Removed NullS. bu-bye. |
4204 |
return valid_arg ? start : NULL; |
1
by brian
clean slate |
4205 |
}
|
4206 |
||
4207 |
||
4208 |
static int |
|
2053.2.1
by Andrew Hutchings
Fix hidden connect messages |
4209 |
sql_connect(const string &host, const string &database, const string &user, const string &password) |
1
by brian
clean slate |
4210 |
{
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
4211 |
drizzle_return_t ret; |
1
by brian
clean slate |
4212 |
if (connected) |
4213 |
{
|
|
4214 |
connected= 0; |
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
4215 |
drizzle_con_free(&con); |
4216 |
drizzle_free(&drizzle); |
|
4217 |
}
|
|
4218 |
drizzle_create(&drizzle); |
|
1960.2.7
by Andrew Hutchings
Drop the drizzleadmin client and use ifdef instead |
4219 |
|
4220 |
#ifdef DRIZZLE_ADMIN_TOOL
|
|
2203.2.2
by Brian Aker
First pass through in going over work for MySQL AUTH PLUGIN style support. |
4221 |
global_con_options= (drizzle_con_options_t) (DRIZZLE_CON_ADMIN | global_con_options); |
1960.2.7
by Andrew Hutchings
Drop the drizzleadmin client and use ifdef instead |
4222 |
#endif
|
4223 |
||
1745.2.1
by LinuxJedi
Remove the --mysql option and convert the --protocol option to do something similar. |
4224 |
if (drizzle_con_add_tcp(&drizzle, &con, (char *)host.c_str(), |
2191.1.3
by Brian Aker
Cleanup for interactive |
4225 |
opt_drizzle_port, (char *)user.c_str(), |
4226 |
(char *)password.c_str(), (char *)database.c_str(), |
|
2203.2.2
by Brian Aker
First pass through in going over work for MySQL AUTH PLUGIN style support. |
4227 |
global_con_options) == NULL) |
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
4228 |
{
|
4229 |
(void) put_error(&con, NULL); |
|
4230 |
(void) fflush(stdout); |
|
4231 |
return 1; |
|
4232 |
}
|
|
4233 |
||
4234 |
if ((ret= drizzle_con_connect(&con)) != DRIZZLE_RETURN_OK) |
|
1
by brian
clean slate |
4235 |
{
|
2053.2.1
by Andrew Hutchings
Fix hidden connect messages |
4236 |
|
2053.2.3
by Andrew Hutchings
Make --silent work again |
4237 |
if (opt_silent < 2) |
1
by brian
clean slate |
4238 |
{
|
2053.2.3
by Andrew Hutchings
Make --silent work again |
4239 |
(void) put_error(&con, NULL); |
4240 |
(void) fflush(stdout); |
|
206.3.1
by Patrick Galbraith
Most everything working with client rename |
4241 |
return ignore_errors ? -1 : 1; // Abort |
1
by brian
clean slate |
4242 |
}
|
206.3.1
by Patrick Galbraith
Most everything working with client rename |
4243 |
return -1; // Retryable |
1
by brian
clean slate |
4244 |
}
|
2191.1.3
by Brian Aker
Cleanup for interactive |
4245 |
connected= 1; |
1235.3.13
by Stewart Smith
remove MY_GIVE_INFO parameter to my_end() that really just gave us the output of time(1). Use UNIX, don't re-implement the kitchen sink. This also removes --debug-info from most command line utilities. |
4246 |
|
2187.3.2
by Andrew Hutchings
Separate the server detection functions into a .h file |
4247 |
ServerDetect server_detect(&con); |
4248 |
server_type= server_detect.getServerType(); |
|
4249 |
||
1
by brian
clean slate |
4250 |
build_completion_hash(opt_rehash, 1); |
4251 |
return 0; |
|
4252 |
}
|
|
4253 |
||
4254 |
||
4255 |
static int |
|
632.1.12
by Monty Taylor
Fixed more sun studio warnings. |
4256 |
com_status(string *, const char *) |
1
by brian
clean slate |
4257 |
{
|
1441.3.1
by Vijay Samuel
all required updations have been made |
4258 |
/*
|
4259 |
char buff[40];
|
|
4260 |
uint64_t id;
|
|
4261 |
*/
|
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
4262 |
drizzle_result_st result; |
4263 |
drizzle_return_t ret; |
|
1
by brian
clean slate |
4264 |
|
4265 |
tee_puts("--------------", stdout); |
|
1729.3.2
by LinuxJedi
Further cleanups based on Monty's comments (also revert a couple of things) |
4266 |
printf(_("Drizzle client %s build %s, for %s-%s (%s) using readline %s\n"), |
4267 |
drizzle_version(), VERSION, |
|
1745.2.1
by LinuxJedi
Remove the --mysql option and convert the --protocol option to do something similar. |
4268 |
HOST_VENDOR, HOST_OS, HOST_CPU, |
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
4269 |
rl_library_version); |
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
4270 |
|
1
by brian
clean slate |
4271 |
if (connected) |
4272 |
{
|
|
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
4273 |
tee_fprintf(stdout, _("\nConnection id:\t\t%lu\n"),drizzle_con_thread_id(&con)); |
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
4274 |
/*
|
4275 |
Don't remove "limit 1",
|
|
1
by brian
clean slate |
4276 |
it is protection againts SQL_SELECT_LIMIT=0
|
4277 |
*/
|
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
4278 |
if (drizzle_query_str(&con,&result,"select DATABASE(), USER() limit 1", |
4279 |
&ret) != NULL && ret == DRIZZLE_RETURN_OK && |
|
4280 |
drizzle_result_buffer(&result) == DRIZZLE_RETURN_OK) |
|
1
by brian
clean slate |
4281 |
{
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
4282 |
drizzle_row_t cur=drizzle_row_next(&result); |
1
by brian
clean slate |
4283 |
if (cur) |
4284 |
{
|
|
2005.2.2
by Andrew Hutchings
Change most places to use 'schema' instead of 'database' |
4285 |
tee_fprintf(stdout, _("Current schema:\t%s\n"), cur[0] ? cur[0] : ""); |
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
4286 |
tee_fprintf(stdout, _("Current user:\t\t%s\n"), cur[1]); |
1
by brian
clean slate |
4287 |
}
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
4288 |
drizzle_result_free(&result); |
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
4289 |
}
|
928.1.4
by Eric Day
Fixed a few bugs, more progress on conversion. |
4290 |
else if (ret == DRIZZLE_RETURN_ERROR_CODE) |
4291 |
drizzle_result_free(&result); |
|
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
4292 |
tee_puts(_("SSL:\t\t\tNot in use"), stdout); |
1
by brian
clean slate |
4293 |
}
|
4294 |
else
|
|
4295 |
{
|
|
4296 |
vidattr(A_BOLD); |
|
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
4297 |
tee_fprintf(stdout, _("\nNo connection\n")); |
1
by brian
clean slate |
4298 |
vidattr(A_NORMAL); |
4299 |
return 0; |
|
4300 |
}
|
|
4301 |
if (skip_updates) |
|
4302 |
{
|
|
4303 |
vidattr(A_BOLD); |
|
2005.2.2
by Andrew Hutchings
Change most places to use 'schema' instead of 'database' |
4304 |
tee_fprintf(stdout, _("\nAll updates ignored to this schema\n")); |
1
by brian
clean slate |
4305 |
vidattr(A_NORMAL); |
4306 |
}
|
|
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
4307 |
tee_fprintf(stdout, _("Current pager:\t\t%s\n"), pager.c_str()); |
4308 |
tee_fprintf(stdout, _("Using outfile:\t\t'%s'\n"), opt_outfile ? outfile.c_str() : ""); |
|
4309 |
tee_fprintf(stdout, _("Using delimiter:\t%s\n"), delimiter); |
|
4310 |
tee_fprintf(stdout, _("Server version:\t\t%s\n"), server_version_string(&con)); |
|
1745.2.1
by LinuxJedi
Remove the --mysql option and convert the --protocol option to do something similar. |
4311 |
tee_fprintf(stdout, _("Protocol:\t\t%s\n"), opt_protocol.c_str()); |
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
4312 |
tee_fprintf(stdout, _("Protocol version:\t%d\n"), drizzle_con_protocol_version(&con)); |
4313 |
tee_fprintf(stdout, _("Connection:\t\t%s\n"), drizzle_con_host(&con)); |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
4314 |
/* XXX need to save this from result
|
4315 |
if ((id= drizzleclient_insert_id(&drizzle)))
|
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
4316 |
tee_fprintf(stdout, "Insert id:\t\t%s\n", internal::llstr(id, buff));
|
1441.3.1
by Vijay Samuel
all required updations have been made |
4317 |
*/
|
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
4318 |
|
1377.2.2
by Zimin
bug fix: ./bin/drizzle with \s would segfault. |
4319 |
if (drizzle_con_uds(&con)) |
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
4320 |
tee_fprintf(stdout, _("UNIX socket:\t\t%s\n"), drizzle_con_uds(&con)); |
1
by brian
clean slate |
4321 |
else
|
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
4322 |
tee_fprintf(stdout, _("TCP port:\t\t%d\n"), drizzle_con_port(&con)); |
1
by brian
clean slate |
4323 |
|
4324 |
if (safe_updates) |
|
4325 |
{
|
|
4326 |
vidattr(A_BOLD); |
|
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
4327 |
tee_fprintf(stdout, _("\nNote that you are running in safe_update_mode:\n")); |
1
by brian
clean slate |
4328 |
vidattr(A_NORMAL); |
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
4329 |
tee_fprintf(stdout, _("\ |
1441.3.1
by Vijay Samuel
all required updations have been made |
4330 |
UPDATEs and DELETEs that don't use a key in the WHERE clause are not allowed.\n\ |
4331 |
(One can force an UPDATE/DELETE by adding LIMIT # at the end of the command.)\n \ |
|
4332 |
SELECT has an automatic 'LIMIT %lu' if LIMIT is not used.\n \ |
|
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
4333 |
Max number of examined row combination in a join is set to: %lu\n\n"), |
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
4334 |
select_limit, max_join_size); |
1
by brian
clean slate |
4335 |
}
|
4336 |
tee_puts("--------------\n", stdout); |
|
4337 |
return 0; |
|
4338 |
}
|
|
4339 |
||
4340 |
static const char * |
|
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
4341 |
server_version_string(drizzle_con_st *local_con) |
1
by brian
clean slate |
4342 |
{
|
534
by Monty Taylor
Removed stxnmov. Also deleted strstr which had already been removed. |
4343 |
static string buf(""); |
4344 |
static bool server_version_string_reserved= false; |
|
1
by brian
clean slate |
4345 |
|
534
by Monty Taylor
Removed stxnmov. Also deleted strstr which had already been removed. |
4346 |
if (!server_version_string_reserved) |
4347 |
{
|
|
4348 |
buf.reserve(MAX_SERVER_VERSION_LENGTH); |
|
4349 |
server_version_string_reserved= true; |
|
4350 |
}
|
|
1
by brian
clean slate |
4351 |
/* Only one thread calls this, so no synchronization is needed */
|
4352 |
if (buf[0] == '\0') |
|
4353 |
{
|
|
928.1.1
by Eric Day
Started client changes. |
4354 |
drizzle_result_st result; |
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
4355 |
drizzle_return_t ret; |
1
by brian
clean slate |
4356 |
|
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
4357 |
buf.append(drizzle_con_server_version(local_con)); |
1
by brian
clean slate |
4358 |
|
4359 |
/* "limit 1" is protection against SQL_SELECT_LIMIT=0 */
|
|
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
4360 |
(void)drizzle_query_str(local_con, &result, |
4361 |
"select @@version_comment limit 1", &ret); |
|
928.1.1
by Eric Day
Started client changes. |
4362 |
if (ret == DRIZZLE_RETURN_OK && |
4363 |
drizzle_result_buffer(&result) == DRIZZLE_RETURN_OK) |
|
1
by brian
clean slate |
4364 |
{
|
928.1.1
by Eric Day
Started client changes. |
4365 |
drizzle_row_t cur = drizzle_row_next(&result); |
1
by brian
clean slate |
4366 |
if (cur && cur[0]) |
4367 |
{
|
|
534
by Monty Taylor
Removed stxnmov. Also deleted strstr which had already been removed. |
4368 |
buf.append(" "); |
928.1.4
by Eric Day
Fixed a few bugs, more progress on conversion. |
4369 |
buf.append(cur[0]); |
1
by brian
clean slate |
4370 |
}
|
928.1.1
by Eric Day
Started client changes. |
4371 |
drizzle_result_free(&result); |
1
by brian
clean slate |
4372 |
}
|
928.1.4
by Eric Day
Fixed a few bugs, more progress on conversion. |
4373 |
else if (ret == DRIZZLE_RETURN_ERROR_CODE) |
4374 |
drizzle_result_free(&result); |
|
1
by brian
clean slate |
4375 |
}
|
4376 |
||
534
by Monty Taylor
Removed stxnmov. Also deleted strstr which had already been removed. |
4377 |
return buf.c_str(); |
1
by brian
clean slate |
4378 |
}
|
4379 |
||
4380 |
static int |
|
893
by Brian Aker
First pass of stripping uint |
4381 |
put_info(const char *str,INFO_TYPE info_type, uint32_t error, const char *sqlstate) |
1
by brian
clean slate |
4382 |
{
|
4383 |
FILE *file= (info_type == INFO_ERROR ? stderr : stdout); |
|
4384 |
static int inited=0; |
|
4385 |
||
1441.3.1
by Vijay Samuel
all required updations have been made |
4386 |
if (status.getBatch()) |
1
by brian
clean slate |
4387 |
{
|
4388 |
if (info_type == INFO_ERROR) |
|
4389 |
{
|
|
4390 |
(void) fflush(file); |
|
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
4391 |
fprintf(file,_("ERROR")); |
1
by brian
clean slate |
4392 |
if (error) |
4393 |
{
|
|
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
4394 |
if (sqlstate) |
4395 |
(void) fprintf(file," %d (%s)",error, sqlstate); |
|
1
by brian
clean slate |
4396 |
else
|
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
4397 |
(void) fprintf(file," %d",error); |
1
by brian
clean slate |
4398 |
}
|
1441.3.1
by Vijay Samuel
all required updations have been made |
4399 |
if (status.getQueryStartLine() && line_numbers) |
1
by brian
clean slate |
4400 |
{
|
1441.3.1
by Vijay Samuel
all required updations have been made |
4401 |
(void) fprintf(file," at line %"PRIu32,status.getQueryStartLine()); |
4402 |
if (status.getFileName()) |
|
4403 |
(void) fprintf(file," in file: '%s'", status.getFileName()); |
|
1
by brian
clean slate |
4404 |
}
|
4405 |
(void) fprintf(file,": %s\n",str); |
|
4406 |
(void) fflush(file); |
|
4407 |
if (!ignore_errors) |
|
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
4408 |
return 1; |
1
by brian
clean slate |
4409 |
}
|
4410 |
else if (info_type == INFO_RESULT && verbose > 1) |
|
4411 |
tee_puts(str, file); |
|
4412 |
if (unbuffered) |
|
4413 |
fflush(file); |
|
4414 |
return info_type == INFO_ERROR ? -1 : 0; |
|
4415 |
}
|
|
4416 |
if (!opt_silent || info_type == INFO_ERROR) |
|
4417 |
{
|
|
4418 |
if (!inited) |
|
4419 |
{
|
|
4420 |
inited=1; |
|
4421 |
#ifdef HAVE_SETUPTERM
|
|
4422 |
(void) setupterm((char *)0, 1, (int *) 0); |
|
4423 |
#endif
|
|
4424 |
}
|
|
4425 |
if (info_type == INFO_ERROR) |
|
4426 |
{
|
|
4427 |
if (!opt_nobeep) |
|
77.3.7
by Monty Taylor
Made mysql into a pure-C program. |
4428 |
/* This should make a bell */
|
4429 |
putchar('\a'); |
|
1
by brian
clean slate |
4430 |
vidattr(A_STANDOUT); |
4431 |
if (error) |
|
4432 |
{
|
|
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
4433 |
if (sqlstate) |
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
4434 |
(void) tee_fprintf(file, _("ERROR %d (%s): "), error, sqlstate); |
1
by brian
clean slate |
4435 |
else
|
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
4436 |
(void) tee_fprintf(file, _("ERROR %d: "), error); |
1
by brian
clean slate |
4437 |
}
|
4438 |
else
|
|
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
4439 |
tee_puts(_("ERROR: "), file); |
1
by brian
clean slate |
4440 |
}
|
4441 |
else
|
|
4442 |
vidattr(A_BOLD); |
|
4443 |
(void) tee_puts(str, file); |
|
4444 |
vidattr(A_NORMAL); |
|
4445 |
}
|
|
4446 |
if (unbuffered) |
|
4447 |
fflush(file); |
|
4448 |
return info_type == INFO_ERROR ? -1 : 0; |
|
4449 |
}
|
|
4450 |
||
4451 |
||
4452 |
static int |
|
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
4453 |
put_error(drizzle_con_st *local_con, drizzle_result_st *res) |
1
by brian
clean slate |
4454 |
{
|
928.1.4
by Eric Day
Fixed a few bugs, more progress on conversion. |
4455 |
const char *error; |
4456 |
||
4457 |
if (res != NULL) |
|
4458 |
{
|
|
4459 |
error= drizzle_result_error(res); |
|
4460 |
if (!strcmp(error, "")) |
|
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
4461 |
error= drizzle_con_error(local_con); |
928.1.4
by Eric Day
Fixed a few bugs, more progress on conversion. |
4462 |
}
|
4463 |
else
|
|
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
4464 |
error= drizzle_con_error(local_con); |
928.1.4
by Eric Day
Fixed a few bugs, more progress on conversion. |
4465 |
|
928.1.7
by Eric Day
Tools mostly converted, still fixing bugs from test suite. |
4466 |
return put_info(error, INFO_ERROR, |
928.1.8
by Eric Day
All tests now passing now, fixed a few more client utility bugs. |
4467 |
res == NULL ? drizzle_con_error_code(local_con) : |
1441.3.1
by Vijay Samuel
all required updations have been made |
4468 |
drizzle_result_error_code(res), |
928.1.8
by Eric Day
All tests now passing now, fixed a few more client utility bugs. |
4469 |
res == NULL ? drizzle_con_sqlstate(local_con) : |
1441.3.1
by Vijay Samuel
all required updations have been made |
4470 |
drizzle_result_sqlstate(res)); |
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
4471 |
}
|
1
by brian
clean slate |
4472 |
|
4473 |
||
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
4474 |
static void remove_cntrl(string *buffer) |
1
by brian
clean slate |
4475 |
{
|
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
4476 |
const char *start= buffer->c_str(); |
4477 |
const char *end= start + (buffer->length()); |
|
1567.3.14
by Monty Taylor
Removed the need for drizzled::internal usage in drizzle.cc. |
4478 |
while (start < end && !isgraph(end[-1])) |
1
by brian
clean slate |
4479 |
end--; |
893
by Brian Aker
First pass of stripping uint |
4480 |
uint32_t pos_to_truncate= (end-start); |
287.3.17
by Monty Taylor
Fixed null-query problem. |
4481 |
if (buffer->length() > pos_to_truncate) |
4482 |
buffer->erase(pos_to_truncate); |
|
1
by brian
clean slate |
4483 |
}
|
4484 |
||
4485 |
||
4486 |
void tee_fprintf(FILE *file, const char *fmt, ...) |
|
4487 |
{
|
|
4488 |
va_list args; |
|
4489 |
||
4490 |
va_start(args, fmt); |
|
4491 |
(void) vfprintf(file, fmt, args); |
|
4492 |
va_end(args); |
|
4493 |
||
4494 |
if (opt_outfile) |
|
4495 |
{
|
|
4496 |
va_start(args, fmt); |
|
4497 |
(void) vfprintf(OUTFILE, fmt, args); |
|
4498 |
va_end(args); |
|
4499 |
}
|
|
4500 |
}
|
|
4501 |
||
4502 |
||
4503 |
void tee_fputs(const char *s, FILE *file) |
|
4504 |
{
|
|
4505 |
fputs(s, file); |
|
4506 |
if (opt_outfile) |
|
4507 |
fputs(s, OUTFILE); |
|
4508 |
}
|
|
4509 |
||
4510 |
||
4511 |
void tee_puts(const char *s, FILE *file) |
|
4512 |
{
|
|
4513 |
fputs(s, file); |
|
4514 |
fputc('\n', file); |
|
4515 |
if (opt_outfile) |
|
4516 |
{
|
|
4517 |
fputs(s, OUTFILE); |
|
4518 |
fputc('\n', OUTFILE); |
|
4519 |
}
|
|
4520 |
}
|
|
4521 |
||
4522 |
void tee_putc(int c, FILE *file) |
|
4523 |
{
|
|
4524 |
putc(c, file); |
|
4525 |
if (opt_outfile) |
|
4526 |
putc(c, OUTFILE); |
|
4527 |
}
|
|
4528 |
||
4529 |
#include <sys/times.h> |
|
4530 |
||
2148.6.2
by Stewart Smith
use boost::posix_time::ptime instead of gettimeofday() to be a bit more portable |
4531 |
static boost::posix_time::ptime start_timer(void) |
1
by brian
clean slate |
4532 |
{
|
2148.6.2
by Stewart Smith
use boost::posix_time::ptime instead of gettimeofday() to be a bit more portable |
4533 |
return boost::posix_time::microsec_clock::universal_time(); |
1
by brian
clean slate |
4534 |
}
|
4535 |
||
2148.6.3
by Stewart Smith
use boost time_duration to generate our nice query duration stsring instead of math on a double |
4536 |
static void nice_time(boost::posix_time::time_duration duration, string &buff) |
1
by brian
clean slate |
4537 |
{
|
971.1.77
by Monty Taylor
Removed mysys/mystrings things from client/ progs. Still need to get rid of my_getopt, but I think that's all now. |
4538 |
ostringstream tmp_buff_str; |
4539 |
||
2148.6.3
by Stewart Smith
use boost time_duration to generate our nice query duration stsring instead of math on a double |
4540 |
if (duration.hours() > 0) |
4541 |
{
|
|
4542 |
tmp_buff_str << duration.hours(); |
|
4543 |
if (duration.hours() > 1) |
|
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
4544 |
tmp_buff_str << _(" hours "); |
641.4.1
by Toru Maesaka
First pass of replacing MySQL's my_stpcpy() with appropriate libc calls |
4545 |
else
|
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
4546 |
tmp_buff_str << _(" hour "); |
1
by brian
clean slate |
4547 |
}
|
2148.6.3
by Stewart Smith
use boost time_duration to generate our nice query duration stsring instead of math on a double |
4548 |
if (duration.hours() > 0 || duration.minutes() > 0) |
1
by brian
clean slate |
4549 |
{
|
2148.6.3
by Stewart Smith
use boost time_duration to generate our nice query duration stsring instead of math on a double |
4550 |
tmp_buff_str << duration.minutes() << _(" min "); |
1
by brian
clean slate |
4551 |
}
|
2148.6.3
by Stewart Smith
use boost time_duration to generate our nice query duration stsring instead of math on a double |
4552 |
|
4553 |
tmp_buff_str.precision(duration.num_fractional_digits()); |
|
4554 |
||
4555 |
double seconds= duration.fractional_seconds(); |
|
4556 |
||
4557 |
seconds/= pow(10.0,duration.num_fractional_digits()); |
|
4558 |
||
4559 |
seconds+= duration.seconds(); |
|
4560 |
tmp_buff_str << seconds << _(" sec"); |
|
4561 |
||
2148.6.1
by Stewart Smith
use a higher precision timer in the drizzle command line client. switch to using struct timeval for it, use 6 digit precision. |
4562 |
buff.append(tmp_buff_str.str()); |
4563 |
}
|
|
4564 |
||
2148.6.2
by Stewart Smith
use boost::posix_time::ptime instead of gettimeofday() to be a bit more portable |
4565 |
static void end_timer(boost::posix_time::ptime start_time, string &buff) |
4566 |
{
|
|
4567 |
boost::posix_time::ptime end_time= start_timer(); |
|
4568 |
boost::posix_time::time_period duration(start_time, end_time); |
|
4569 |
||
2148.6.3
by Stewart Smith
use boost time_duration to generate our nice query duration stsring instead of math on a double |
4570 |
nice_time(duration.length(), buff); |
2148.6.2
by Stewart Smith
use boost::posix_time::ptime instead of gettimeofday() to be a bit more portable |
4571 |
}
|
4572 |
||
4573 |
||
4574 |
static void drizzle_end_timer(boost::posix_time::ptime start_time, string &buff) |
|
2148.6.1
by Stewart Smith
use a higher precision timer in the drizzle command line client. switch to using struct timeval for it, use 6 digit precision. |
4575 |
{
|
4576 |
buff.append(" ("); |
|
4577 |
end_timer(start_time,buff); |
|
4578 |
buff.append(")"); |
|
1
by brian
clean slate |
4579 |
}
|
4580 |
||
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
4581 |
static const char * construct_prompt() |
1
by brian
clean slate |
4582 |
{
|
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
4583 |
// Erase the old prompt
|
77.3.3
by Monty Taylor
Last change to migrate to glib from sql_string. |
4584 |
assert(processed_prompt!=NULL); |
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
4585 |
processed_prompt->clear(); |
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
4586 |
|
4587 |
// Get the date struct
|
|
4588 |
time_t lclock = time(NULL); |
|
1
by brian
clean slate |
4589 |
struct tm *t = localtime(&lclock); |
4590 |
||
4591 |
/* parse thru the settings for the prompt */
|
|
1596.1.1
by Monty Taylor
Merged in remove-internal-from-drizzle-cc |
4592 |
string::iterator c= current_prompt.begin(); |
4593 |
while (c != current_prompt.end()) |
|
1
by brian
clean slate |
4594 |
{
|
4595 |
if (*c != PROMPT_CHAR) |
|
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
4596 |
{
|
1596.1.1
by Monty Taylor
Merged in remove-internal-from-drizzle-cc |
4597 |
processed_prompt->push_back(*c); |
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
4598 |
}
|
1
by brian
clean slate |
4599 |
else
|
4600 |
{
|
|
77.3.7
by Monty Taylor
Made mysql into a pure-C program. |
4601 |
int getHour; |
4602 |
int getYear; |
|
971.4.1
by Monty Taylor
GCC on Solaris build fixes. |
4603 |
/* Room for Dow MMM DD HH:MM:SS YYYY */
|
4604 |
char dateTime[32]; |
|
1
by brian
clean slate |
4605 |
switch (*++c) { |
4606 |
case '\0': |
|
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
4607 |
// stop it from going beyond if ends with %
|
1596.1.1
by Monty Taylor
Merged in remove-internal-from-drizzle-cc |
4608 |
--c; |
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
4609 |
break; |
1
by brian
clean slate |
4610 |
case 'c': |
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
4611 |
add_int_to_prompt(++prompt_counter); |
4612 |
break; |
|
1
by brian
clean slate |
4613 |
case 'v': |
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
4614 |
if (connected) |
928.1.3
by Eric Day
More changes towards getting the client utilities converted. |
4615 |
processed_prompt->append(drizzle_con_server_version(&con)); |
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
4616 |
else
|
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
4617 |
processed_prompt->append("not_connected"); |
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
4618 |
break; |
1
by brian
clean slate |
4619 |
case 'd': |
1596.1.1
by Monty Taylor
Merged in remove-internal-from-drizzle-cc |
4620 |
processed_prompt->append(not current_db.empty() ? current_db : "(none)"); |
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
4621 |
break; |
1
by brian
clean slate |
4622 |
case 'h': |
1441.3.1
by Vijay Samuel
all required updations have been made |
4623 |
{
|
1596.1.1
by Monty Taylor
Merged in remove-internal-from-drizzle-cc |
4624 |
const char *prompt= connected ? drizzle_con_host(&con) : "not_connected"; |
1441.3.1
by Vijay Samuel
all required updations have been made |
4625 |
if (strstr(prompt, "Localhost")) |
4626 |
processed_prompt->append("localhost"); |
|
4627 |
else
|
|
4628 |
{
|
|
4629 |
const char *end=strrchr(prompt,' '); |
|
4630 |
if (end != NULL) |
|
4631 |
processed_prompt->append(prompt, (end-prompt)); |
|
4632 |
}
|
|
4633 |
break; |
|
4634 |
}
|
|
4635 |
case 'p': |
|
4636 |
{
|
|
4637 |
if (!connected) |
|
4638 |
{
|
|
4639 |
processed_prompt->append("not_connected"); |
|
1407
by Brian Aker
Merge Siddharth, ran formatting across it. |
4640 |
break; |
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
4641 |
}
|
1441.3.1
by Vijay Samuel
all required updations have been made |
4642 |
|
4643 |
if (drizzle_con_uds(&con)) |
|
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
4644 |
{
|
1441.3.1
by Vijay Samuel
all required updations have been made |
4645 |
const char *pos=strrchr(drizzle_con_uds(&con),'/'); |
4646 |
processed_prompt->append(pos ? pos+1 : drizzle_con_uds(&con)); |
|
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
4647 |
}
|
1441.3.1
by Vijay Samuel
all required updations have been made |
4648 |
else
|
4649 |
add_int_to_prompt(drizzle_con_port(&con)); |
|
4650 |
}
|
|
4651 |
break; |
|
1
by brian
clean slate |
4652 |
case 'U': |
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
4653 |
if (!full_username) |
4654 |
init_username(); |
|
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
4655 |
processed_prompt->append(full_username ? full_username : |
1596.1.1
by Monty Taylor
Merged in remove-internal-from-drizzle-cc |
4656 |
(!current_user.empty() ? current_user : "(unknown)")); |
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
4657 |
break; |
1
by brian
clean slate |
4658 |
case 'u': |
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
4659 |
if (!full_username) |
4660 |
init_username(); |
|
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
4661 |
processed_prompt->append(part_username ? part_username : |
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
4662 |
(!current_user.empty() ? current_user : _("(unknown)"))); |
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
4663 |
break; |
1
by brian
clean slate |
4664 |
case PROMPT_CHAR: |
182.1.2
by Jim Winstead
Various fixes to enable compilation on Mac OS X, and remove the glib dependency. |
4665 |
{
|
632.1.12
by Monty Taylor
Fixed more sun studio warnings. |
4666 |
processed_prompt->append(PROMPT_CHAR, 1); |
182.1.2
by Jim Winstead
Various fixes to enable compilation on Mac OS X, and remove the glib dependency. |
4667 |
}
|
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
4668 |
break; |
1
by brian
clean slate |
4669 |
case 'n': |
182.1.2
by Jim Winstead
Various fixes to enable compilation on Mac OS X, and remove the glib dependency. |
4670 |
{
|
632.1.12
by Monty Taylor
Fixed more sun studio warnings. |
4671 |
processed_prompt->append('\n', 1); |
182.1.2
by Jim Winstead
Various fixes to enable compilation on Mac OS X, and remove the glib dependency. |
4672 |
}
|
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
4673 |
break; |
1
by brian
clean slate |
4674 |
case ' ': |
4675 |
case '_': |
|
182.1.2
by Jim Winstead
Various fixes to enable compilation on Mac OS X, and remove the glib dependency. |
4676 |
{
|
632.1.12
by Monty Taylor
Fixed more sun studio warnings. |
4677 |
processed_prompt->append(' ', 1); |
182.1.2
by Jim Winstead
Various fixes to enable compilation on Mac OS X, and remove the glib dependency. |
4678 |
}
|
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
4679 |
break; |
1
by brian
clean slate |
4680 |
case 'R': |
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
4681 |
if (t->tm_hour < 10) |
182.1.2
by Jim Winstead
Various fixes to enable compilation on Mac OS X, and remove the glib dependency. |
4682 |
add_int_to_prompt(0); |
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
4683 |
add_int_to_prompt(t->tm_hour); |
4684 |
break; |
|
1
by brian
clean slate |
4685 |
case 'r': |
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
4686 |
getHour = t->tm_hour % 12; |
4687 |
if (getHour == 0) |
|
4688 |
getHour=12; |
|
4689 |
if (getHour < 10) |
|
182.1.2
by Jim Winstead
Various fixes to enable compilation on Mac OS X, and remove the glib dependency. |
4690 |
add_int_to_prompt(0); |
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
4691 |
add_int_to_prompt(getHour); |
4692 |
break; |
|
1
by brian
clean slate |
4693 |
case 'm': |
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
4694 |
if (t->tm_min < 10) |
182.1.2
by Jim Winstead
Various fixes to enable compilation on Mac OS X, and remove the glib dependency. |
4695 |
add_int_to_prompt(0); |
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
4696 |
add_int_to_prompt(t->tm_min); |
4697 |
break; |
|
1
by brian
clean slate |
4698 |
case 'y': |
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
4699 |
getYear = t->tm_year % 100; |
4700 |
if (getYear < 10) |
|
182.1.2
by Jim Winstead
Various fixes to enable compilation on Mac OS X, and remove the glib dependency. |
4701 |
add_int_to_prompt(0); |
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
4702 |
add_int_to_prompt(getYear); |
4703 |
break; |
|
1
by brian
clean slate |
4704 |
case 'Y': |
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
4705 |
add_int_to_prompt(t->tm_year+1900); |
4706 |
break; |
|
1
by brian
clean slate |
4707 |
case 'D': |
971.4.1
by Monty Taylor
GCC on Solaris build fixes. |
4708 |
strftime(dateTime, 32, "%a %b %d %H:%M:%S %Y", localtime(&lclock)); |
4709 |
processed_prompt->append(dateTime); |
|
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
4710 |
break; |
1
by brian
clean slate |
4711 |
case 's': |
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
4712 |
if (t->tm_sec < 10) |
182.1.2
by Jim Winstead
Various fixes to enable compilation on Mac OS X, and remove the glib dependency. |
4713 |
add_int_to_prompt(0); |
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
4714 |
add_int_to_prompt(t->tm_sec); |
4715 |
break; |
|
1
by brian
clean slate |
4716 |
case 'w': |
2155.4.1
by Stewart Smith
make day names and month names in drizzle client (for prompt) internationalizable |
4717 |
processed_prompt->append(get_day_name(t->tm_wday)); |
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
4718 |
break; |
1
by brian
clean slate |
4719 |
case 'P': |
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
4720 |
processed_prompt->append(t->tm_hour < 12 ? "am" : "pm"); |
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
4721 |
break; |
1
by brian
clean slate |
4722 |
case 'o': |
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
4723 |
add_int_to_prompt(t->tm_mon+1); |
4724 |
break; |
|
1
by brian
clean slate |
4725 |
case 'O': |
2155.4.1
by Stewart Smith
make day names and month names in drizzle client (for prompt) internationalizable |
4726 |
processed_prompt->append(get_month_name(t->tm_mon)); |
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
4727 |
break; |
1
by brian
clean slate |
4728 |
case '\'': |
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
4729 |
processed_prompt->append("'"); |
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
4730 |
break; |
1
by brian
clean slate |
4731 |
case '"': |
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
4732 |
processed_prompt->append("\""); |
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
4733 |
break; |
1
by brian
clean slate |
4734 |
case 'S': |
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
4735 |
processed_prompt->append(";"); |
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
4736 |
break; |
1
by brian
clean slate |
4737 |
case 't': |
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
4738 |
processed_prompt->append("\t"); |
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
4739 |
break; |
1
by brian
clean slate |
4740 |
case 'l': |
1596.1.1
by Monty Taylor
Merged in remove-internal-from-drizzle-cc |
4741 |
processed_prompt->append(delimiter_str); |
77.3.2
by Monty Taylor
Got it compiling... now, too bad it doesn't work. |
4742 |
break; |
1
by brian
clean slate |
4743 |
default: |
1596.1.1
by Monty Taylor
Merged in remove-internal-from-drizzle-cc |
4744 |
processed_prompt->push_back(*c); |
1
by brian
clean slate |
4745 |
}
|
4746 |
}
|
|
1596.1.1
by Monty Taylor
Merged in remove-internal-from-drizzle-cc |
4747 |
++c; |
1
by brian
clean slate |
4748 |
}
|
279.2.2
by Monty Taylor
Replaced DYNAMIC_STRING with C++ string in drizzle command line client. |
4749 |
return processed_prompt->c_str(); |
1
by brian
clean slate |
4750 |
}
|
4751 |
||
4752 |
||
4753 |
static void add_int_to_prompt(int toadd) |
|
4754 |
{
|
|
971.1.77
by Monty Taylor
Removed mysys/mystrings things from client/ progs. Still need to get rid of my_getopt, but I think that's all now. |
4755 |
ostringstream buffer; |
4756 |
buffer << toadd; |
|
4757 |
processed_prompt->append(buffer.str().c_str()); |
|
1
by brian
clean slate |
4758 |
}
|
4759 |
||
4760 |
static void init_username() |
|
4761 |
{
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
4762 |
/* XXX need this?
|
4763 |
free(full_username);
|
|
4764 |
free(part_username);
|
|
1
by brian
clean slate |
4765 |
|
1441.3.1
by Vijay Samuel
all required updations have been made |
4766 |
drizzle_result_st *result;
|
4767 |
if (!drizzleclient_query(&drizzle,"select USER()") &&
|
|
4768 |
(result=drizzleclient_use_result(&drizzle)))
|
|
4769 |
{
|
|
928.1.1
by Eric Day
Started client changes. |
4770 |
drizzle_row_t cur=drizzleclient_fetch_row(result);
|
182.1.2
by Jim Winstead
Various fixes to enable compilation on Mac OS X, and remove the glib dependency. |
4771 |
full_username= strdup(cur[0]);
|
4772 |
part_username= strdup(strtok(cur[0],"@"));
|
|
840.1.21
by Monty Taylor
ZOMG. Renamed all the rest of the stuff in libdrizzleclient to be drizzleclient_*. I love commandline perl. |
4773 |
(void) drizzleclient_fetch_row(result); // Read eof
|
1441.3.1
by Vijay Samuel
all required updations have been made |
4774 |
}
|
4775 |
*/
|
|
1
by brian
clean slate |
4776 |
}
|
4777 |
||
632.1.12
by Monty Taylor
Fixed more sun studio warnings. |
4778 |
static int com_prompt(string *, const char *line) |
1
by brian
clean slate |
4779 |
{
|
520.4.43
by mordred
A set of Solaris fixes. |
4780 |
const char *ptr=strchr(line, ' '); |
656.1.51
by Monty Taylor
Fixed strdup return checking in client/ |
4781 |
if (ptr == NULL) |
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
4782 |
tee_fprintf(stdout, _("Returning to default PROMPT of %s\n"), |
182.1.2
by Jim Winstead
Various fixes to enable compilation on Mac OS X, and remove the glib dependency. |
4783 |
default_prompt); |
656.1.51
by Monty Taylor
Fixed strdup return checking in client/ |
4784 |
prompt_counter = 0; |
4785 |
char * tmpptr= strdup(ptr ? ptr+1 : default_prompt); |
|
4786 |
if (tmpptr == NULL) |
|
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
4787 |
tee_fprintf(stdout, _("Memory allocation error. Not changing prompt\n")); |
1
by brian
clean slate |
4788 |
else
|
656.1.51
by Monty Taylor
Fixed strdup return checking in client/ |
4789 |
{
|
1567.3.1
by Vijay Samuel
Refactoring of the drizzle client. |
4790 |
current_prompt.erase(); |
656.1.51
by Monty Taylor
Fixed strdup return checking in client/ |
4791 |
current_prompt= tmpptr; |
1729.3.1
by LinuxJedi
some string and options cleanups for drizzle and drizzledump |
4792 |
tee_fprintf(stdout, _("PROMPT set to '%s'\n"), current_prompt.c_str()); |
656.1.51
by Monty Taylor
Fixed strdup return checking in client/ |
4793 |
}
|
1
by brian
clean slate |
4794 |
return 0; |
4795 |
}
|
|
266.6.1
by Andy Lester
merging from main |
4796 |
|
4797 |
/*
|
|
1441.3.1
by Vijay Samuel
all required updations have been made |
4798 |
strcont(str, set) if str contanies any character in the string set.
|
4799 |
The result is the position of the first found character in str, or NULL
|
|
4800 |
if there isn't anything found.
|
|
266.6.1
by Andy Lester
merging from main |
4801 |
*/
|
4802 |
||
2187.4.1
by Olaf van der Spek
Remove register keyword |
4803 |
static const char * strcont(const char *str, const char *set) |
266.6.1
by Andy Lester
merging from main |
4804 |
{
|
2187.4.1
by Olaf van der Spek
Remove register keyword |
4805 |
const char * start = (const char *) set; |
266.6.1
by Andy Lester
merging from main |
4806 |
|
4807 |
while (*str) |
|
4808 |
{
|
|
4809 |
while (*set) |
|
4810 |
{
|
|
4811 |
if (*set++ == *str) |
|
4812 |
return ((const char*) str); |
|
4813 |
}
|
|
4814 |
set=start; str++; |
|
4815 |
}
|
|
4816 |
return NULL; |
|
4817 |
} /* strcont */ |