20
20
#include <drizzled/global.h>
21
21
#include <mysys/my_sys.h>
22
22
#include "my_time.h"
23
#include <mysys_err.h>
23
#include <mysys/mysys_err.h>
24
24
#include <mystrings/m_string.h>
25
25
#include <mystrings/m_ctype.h>
26
26
#include "drizzle.h"
27
#include "drizzled_error.h"
28
27
#include "errmsg.h"
28
#include <vio/violite.h>
30
29
#include <sys/stat.h>
31
30
#include <signal.h>
81
80
static DRIZZLE_PARAMETERS drizzle_internal_parameters=
82
81
{&max_allowed_packet, &net_buffer_length, 0};
84
DRIZZLE_PARAMETERS *STDCALL drizzle_get_parameters(void)
83
const DRIZZLE_PARAMETERS *STDCALL drizzle_get_parameters(void)
86
85
return &drizzle_internal_parameters;
138
137
/**************************************************************************
139
Connect to sql server
140
If host == 0 then use localhost
141
**************************************************************************/
143
#ifdef USE_OLD_FUNCTIONS
145
drizzle_connect(DRIZZLE *drizzle,const char *host,
146
const char *user, const char *passwd)
149
drizzle=drizzle_init(drizzle); /* Make it thread safe */
151
if (!(res=drizzle_connect(drizzle,host,user,passwd,NullS,0,NullS,0)))
153
if (drizzle->free_me && drizzle)
154
free((uchar*) drizzle);
156
drizzle->reconnect= 1;
163
/**************************************************************************
164
138
Change user and database
165
139
**************************************************************************/
167
int cli_read_change_user_result(DRIZZLE *drizzle, char *buff, const char *passwd)
141
int cli_read_change_user_result(DRIZZLE *drizzle)
171
143
ulong pkt_length;
173
145
pkt_length= cli_safe_read(drizzle);
229
201
/* Write authentication package */
230
202
(void)simple_command(drizzle,COM_CHANGE_USER, (uchar*) buff, (ulong) (end-buff), 1);
232
rc= (*drizzle->methods->read_change_user_result)(drizzle, buff, passwd);
204
rc= (*drizzle->methods->read_change_user_result)(drizzle);
257
#if defined(HAVE_GETPWUID) && defined(NO_GETPWUID_DECL)
258
struct passwd *getpwuid(uid_t);
259
char* getlogin(void);
262
void read_user_name(char *name)
265
(void) strmov(name,"root"); /* allow use of surun */
271
if ((str=getlogin()) == NULL)
273
if ((skr=getpwuid(geteuid())) != NULL)
275
else if (!(str=getenv("USER")) && !(str=getenv("LOGNAME")) &&
276
!(str=getenv("LOGIN")))
279
(void) strmake(name,str,USERNAME_LENGTH);
281
(void) cuserid(name);
283
strmov(name,"UNKNOWN_USER");
289
230
bool handle_local_infile(DRIZZLE *drizzle, const char *net_filename)
704
#ifdef USE_OLD_FUNCTIONS
706
drizzle_create_db(DRIZZLE *drizzle, const char *db)
708
return(simple_command(drizzle,COM_CREATE_DB,db, (ulong) strlen(db),0));
713
drizzle_drop_db(DRIZZLE *drizzle, const char *db)
715
return(simple_command(drizzle,COM_DROP_DB,db,(ulong) strlen(db),0));
721
646
drizzle_shutdown(DRIZZLE *drizzle, enum drizzle_enum_shutdown_level shutdown_level)
788
713
const char * STDCALL
789
drizzle_get_server_info(DRIZZLE *drizzle)
714
drizzle_get_server_info(const DRIZZLE *drizzle)
791
716
return((char*) drizzle->server_version);
795
720
const char * STDCALL
796
drizzle_get_host_info(DRIZZLE *drizzle)
721
drizzle_get_host_info(const DRIZZLE *drizzle)
798
723
return(drizzle->host_info);
803
drizzle_get_proto_info(DRIZZLE *drizzle)
728
drizzle_get_proto_info(const DRIZZLE *drizzle)
805
730
return (drizzle->protocol_version);
816
741
return MYSQL_VERSION_ID;
819
bool STDCALL drizzle_eof(DRIZZLE_RES *res)
744
bool STDCALL drizzle_eof(const DRIZZLE_RES *res)
824
DRIZZLE_FIELD * STDCALL drizzle_fetch_field_direct(DRIZZLE_RES *res,uint fieldnr)
749
const DRIZZLE_FIELD * STDCALL drizzle_fetch_field_direct(const DRIZZLE_RES *res, unsigned int fieldnr)
826
751
return &(res)->fields[fieldnr];
829
DRIZZLE_FIELD * STDCALL drizzle_fetch_fields(DRIZZLE_RES *res)
754
const DRIZZLE_FIELD * STDCALL drizzle_fetch_fields(const DRIZZLE_RES *res)
831
return (res)->fields;
834
DRIZZLE_ROW_OFFSET STDCALL DRIZZLE_ROW_tell(DRIZZLE_RES *res)
759
DRIZZLE_ROW_OFFSET STDCALL drizzle_row_tell(const DRIZZLE_RES *res)
836
761
return res->data_cursor;
839
DRIZZLE_FIELD_OFFSET STDCALL drizzle_field_tell(DRIZZLE_RES *res)
764
DRIZZLE_FIELD_OFFSET STDCALL drizzle_field_tell(const DRIZZLE_RES *res)
841
return (res)->current_field;
766
return res->current_field;
846
unsigned int STDCALL drizzle_field_count(DRIZZLE *drizzle)
771
unsigned int STDCALL drizzle_field_count(const DRIZZLE *drizzle)
848
773
return drizzle->field_count;
851
uint64_t STDCALL drizzle_affected_rows(DRIZZLE *drizzle)
776
uint64_t STDCALL drizzle_affected_rows(const DRIZZLE *drizzle)
853
778
return drizzle->affected_rows;
856
uint64_t STDCALL drizzle_insert_id(DRIZZLE *drizzle)
781
uint64_t STDCALL drizzle_insert_id(const DRIZZLE *drizzle)
858
783
return drizzle->insert_id;
861
const char *STDCALL drizzle_sqlstate(DRIZZLE *drizzle)
786
const char *STDCALL drizzle_sqlstate(const DRIZZLE *drizzle)
863
788
return drizzle ? drizzle->net.sqlstate : cant_connect_sqlstate;
866
uint32_t STDCALL drizzle_warning_count(DRIZZLE *drizzle)
791
uint32_t STDCALL drizzle_warning_count(const DRIZZLE *drizzle)
868
793
return drizzle->warning_count;
871
const char *STDCALL drizzle_info(DRIZZLE *drizzle)
796
const char *STDCALL drizzle_info(const DRIZZLE *drizzle)
873
798
return drizzle->info;
876
uint32_t STDCALL drizzle_thread_id(DRIZZLE *drizzle)
801
uint32_t STDCALL drizzle_thread_id(const DRIZZLE *drizzle)
878
return (drizzle)->thread_id;
803
return drizzle->thread_id;
881
const char * STDCALL drizzle_character_set_name(DRIZZLE *drizzle)
806
const char * STDCALL drizzle_character_set_name(const DRIZZLE *drizzle)
883
808
return drizzle->charset->csname;
886
void STDCALL drizzle_get_character_set_info(DRIZZLE *drizzle, MY_CHARSET_INFO *csinfo)
811
void STDCALL drizzle_get_character_set_info(const DRIZZLE *drizzle, MY_CHARSET_INFO *csinfo)
888
813
csinfo->number = drizzle->charset->number;
889
814
csinfo->state = drizzle->charset->state;
976
901
drizzle_escape_string(char *to,const char *from, uint32_t length)
978
return escape_string_for_mysql(default_charset_info, to, 0, from, length);
903
return escape_string_for_drizzle(default_charset_info, to, 0, from, length);
985
910
if (drizzle->server_status & SERVER_STATUS_NO_BACKSLASH_ESCAPES)
986
return escape_quotes_for_mysql(drizzle->charset, to, 0, from, length);
987
return escape_string_for_mysql(drizzle->charset, to, 0, from, length);
911
return escape_quotes_for_drizzle(drizzle->charset, to, 0, from, length);
912
return escape_string_for_drizzle(drizzle->charset, to, 0, from, length);
991
myodbc_remove_escape(DRIZZLE *drizzle,char *name)
916
myodbc_remove_escape(const DRIZZLE *drizzle, char *name)
995
bool use_mb_flag=use_mb(drizzle->charset);
920
bool use_mb_flag= use_mb(drizzle->charset);
998
923
for (end=name; *end ; end++) ;