Commit 02997c8d authored by unknown's avatar unknown

Merge eherman@bk-internal.mysql.com:/home/bk/mysql-5.0

into  mysql.com:/home/eric/mysql-5.0

parents 849273bc 6ad5a6c7
This diff is collapsed.
......@@ -21,7 +21,7 @@ CREATE TABLE federated.t1 (
PRIMARY KEY (`id`)
)
ENGINE="FEDERATED" DEFAULT CHARSET=latin1
COMMENT='mysql://root@127.0.0.1:SLAVE_PORT/federated/archive_table';
CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/federated/archive_table';
INSERT INTO federated.t1 (id, name) VALUES (1, 'foo');
INSERT INTO federated.t1 (id, name) VALUES (2, 'bar');
SELECT * FROM federated.t1;
......
This diff is collapsed.
......@@ -25,7 +25,7 @@ eval CREATE TABLE federated.t1 (
PRIMARY KEY (`id`)
)
ENGINE="FEDERATED" DEFAULT CHARSET=latin1
COMMENT='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/archive_table';
CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/archive_table';
INSERT INTO federated.t1 (id, name) VALUES (1, 'foo');
INSERT INTO federated.t1 (id, name) VALUES (2, 'bar');
......
......@@ -518,7 +518,7 @@ error:
/*
Parse connection info from table->s->comment
Parse connection info from table->s->connect_string
SYNOPSIS
parse_url()
......@@ -563,7 +563,14 @@ static int parse_url(FEDERATED_SHARE *share, TABLE *table,
DBUG_ENTER("ha_federated::parse_url");
share->port= 0;
share->scheme= my_strdup(table->s->comment, MYF(0));
DBUG_PRINT("info", ("Length %d \n", table->s->connect_string.length));
DBUG_PRINT("info", ("String %.*s \n", table->s->connect_string.length,
table->s->connect_string.str));
share->scheme= my_strdup_with_length(table->s->connect_string.str,
table->s->connect_string.length+1,
MYF(0));
// Add a null for later termination of table name
share->scheme[table->s->connect_string.length]= 0;
DBUG_PRINT("info",("parse_url alloced share->scheme %lx", share->scheme));
/*
......@@ -673,7 +680,8 @@ error:
my_free((gptr) share->scheme, MYF(0));
share->scheme= 0;
}
my_error(error_num, MYF(0), table->s->comment);
/* FIXME: table->s->connect_string is NOT null terminated */
my_error(error_num, MYF(0), "invalid connection string");
DBUG_RETURN(error_num);
}
......@@ -1313,7 +1321,7 @@ static FEDERATED_SHARE *get_share(const char *table_name, TABLE *table)
&share, sizeof(*share),
&tmp_table_name, tmp_table_name_length+ 1,
&select_query,
query.length()+strlen(table->s->comment)+1,
query.length()+table->s->connect_string.length+1,
NullS)))
{
pthread_mutex_unlock(&federated_mutex);
......@@ -1918,11 +1926,9 @@ int ha_federated::delete_row(const byte *buf)
String delete_string(delete_buffer, sizeof(delete_buffer), &my_charset_bin);
String data_string(data_buffer, sizeof(data_buffer), &my_charset_bin);
delete_string.length(0);
data_string.length(0);
DBUG_ENTER("ha_federated::delete_row");
delete_string.length(0);
delete_string.append(FEDERATED_DELETE);
delete_string.append(FEDERATED_FROM);
delete_string.append(FEDERATED_BTICK);
......@@ -1932,9 +1938,11 @@ int ha_federated::delete_row(const byte *buf)
for (Field **field= table->field; *field; field++)
{
delete_string.append((*field)->field_name);
Field *cur_field= *field;
data_string.length(0);
delete_string.append(cur_field->field_name);
if ((*field)->is_null())
if (cur_field->is_null())
{
delete_string.append(FEDERATED_IS);
data_string.append(FEDERATED_NULL);
......@@ -1942,16 +1950,14 @@ int ha_federated::delete_row(const byte *buf)
else
{
delete_string.append(FEDERATED_EQ);
(*field)->val_str(&data_string);
(*field)->quote_data(&data_string);
cur_field->val_str(&data_string);
cur_field->quote_data(&data_string);
}
delete_string.append(data_string);
data_string.length(0);
if (*(field + 1))
delete_string.append(FEDERATED_AND);
delete_string.append(FEDERATED_AND);
}
delete_string.length(delete_string.length()-5); // Remove trailing AND
delete_string.append(FEDERATED_LIMIT1);
DBUG_PRINT("info",
......
......@@ -209,6 +209,7 @@ enum row_type { ROW_TYPE_NOT_USED=-1, ROW_TYPE_DEFAULT, ROW_TYPE_FIXED,
#define HA_CREATE_USED_ROW_FORMAT (1L << 15)
#define HA_CREATE_USED_COMMENT (1L << 16)
#define HA_CREATE_USED_PASSWORD (1L << 17)
#define HA_CREATE_USED_CONNECTION (1L << 18)
typedef ulonglong my_xid; // this line is the same as in log_event.h
#define MYSQL_XID_PREFIX "MySQLXid"
......@@ -382,6 +383,7 @@ enum enum_tx_isolation { ISO_READ_UNCOMMITTED, ISO_READ_COMMITTED,
typedef struct st_ha_create_information
{
CHARSET_INFO *table_charset, *default_table_charset;
LEX_STRING connect_string;
const char *comment,*password;
const char *data_file_name, *index_file_name;
const char *alias;
......
......@@ -2691,6 +2691,7 @@ create_table_option:
| INSERT_METHOD opt_equal merge_insert_types { Lex->create_info.merge_insert_method= $3; Lex->create_info.used_fields|= HA_CREATE_USED_INSERT_METHOD;}
| DATA_SYM DIRECTORY_SYM opt_equal TEXT_STRING_sys { Lex->create_info.data_file_name= $4.str; Lex->create_info.used_fields|= HA_CREATE_USED_DATADIR; }
| INDEX_SYM DIRECTORY_SYM opt_equal TEXT_STRING_sys { Lex->create_info.index_file_name= $4.str; Lex->create_info.used_fields|= HA_CREATE_USED_INDEXDIR; }
| CONNECTION_SYM opt_equal TEXT_STRING_sys { Lex->create_info.connect_string.str= $3.str; Lex->create_info.connect_string.length= $3.length; Lex->create_info.used_fields|= HA_CREATE_USED_CONNECTION; }
;
default_charset:
......
......@@ -71,7 +71,7 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat,
uint rec_buff_length,n_length,int_length,records,key_parts,keys,
interval_count,interval_parts,read_length,db_create_options;
uint key_info_length, com_length;
ulong pos;
ulong pos, record_offset;
char index_file[FN_REFLEN], *names, *keynames, *comment_pos;
uchar head[288],*disk_buff,new_field_pack_flag;
my_string record;
......@@ -321,11 +321,12 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat,
rec_buff_length * records)))
goto err; /* purecov: inspected */
share->default_values= (byte *) record;
record_offset= (ulong) (uint2korr(head+6)+
((uint2korr(head+14) == 0xffff ?
uint4korr(head+47) : uint2korr(head+14))));
if (my_pread(file,(byte*) record, (uint) share->reclength,
(ulong) (uint2korr(head+6)+
((uint2korr(head+14) == 0xffff ?
uint4korr(head+47) : uint2korr(head+14)))),
MYF(MY_NABP)))
record_offset, MYF(MY_NABP)))
goto err; /* purecov: inspected */
if (records == 1)
......@@ -342,6 +343,19 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat,
outparam->record[1]= outparam->record[0]; // Safety
}
if ((n_length= uint2korr(head+55)))
{
/* Read extra block information */
char *buff;
if (!(buff= alloc_root(&outparam->mem_root, n_length)))
goto err;
if (my_pread(file, buff, n_length, record_offset + share->reclength,
MYF(MY_NABP)))
goto err;
share->connect_string.length= uint2korr(buff);
share->connect_string.str= buff+2;
}
#ifdef HAVE_purify
/*
We need this because when we read var-length rows, we are not updating
......@@ -1350,10 +1364,15 @@ File create_frm(THD *thd, my_string name, const char *db,
ulong length;
char fill[IO_SIZE];
int create_flags= O_RDWR | O_TRUNC;
uint extra_size;
if (create_info->options & HA_LEX_CREATE_TMP_TABLE)
create_flags|= O_EXCL | O_NOFOLLOW;
extra_size= 0;
if (create_info->connect_string.length)
extra_size= 2+create_info->connect_string.length;
#if SIZEOF_OFF_T > 4
/* Fix this when we have new .frm files; Current limit is 4G rows (QQ) */
if (create_info->max_rows > ~(ulong) 0)
......@@ -1381,7 +1400,7 @@ File create_frm(THD *thd, my_string name, const char *db,
fileinfo[4]=1;
int2store(fileinfo+6,IO_SIZE); /* Next block starts here */
key_length=keys*(7+NAME_LEN+MAX_REF_PARTS*9)+16;
length=(ulong) next_io_size((ulong) (IO_SIZE+key_length+reclength));
length= next_io_size((ulong) (IO_SIZE+key_length+reclength+extra_size));
int4store(fileinfo+10,length);
tmp_key_length= (key_length < 0xffff) ? key_length : 0xffff;
int2store(fileinfo+14,tmp_key_length);
......@@ -1403,6 +1422,7 @@ File create_frm(THD *thd, my_string name, const char *db,
int4store(fileinfo+47, key_length);
tmp= MYSQL_VERSION_ID; // Store to avoid warning from int4store
int4store(fileinfo+51, tmp);
int2store(fileinfo+55, extra_size);
bzero(fill,IO_SIZE);
for (; length > IO_SIZE ; length-= IO_SIZE)
{
......
......@@ -126,6 +126,7 @@ typedef struct st_table_share
const char *db; /* Pointer to db */
const char *table_name; /* Table name (for open) */
const char *path; /* Path to .frm file (from datadir) */
LEX_STRING connect_string;
key_map keys_in_use; /* Keys in use for table */
key_map keys_for_keyread;
ulong avg_row_length; /* create information */
......
......@@ -149,6 +149,15 @@ bool mysql_create_frm(THD *thd, my_string file_name,
if (make_empty_rec(thd,file,create_info->db_type,create_info->table_options,
create_fields,reclength, data_offset))
goto err;
if (create_info->connect_string.length)
{
char buff[2];
int2store(buff,create_info->connect_string.length);
if (my_write(file, buff, sizeof(buff), MYF(MY_NABP)) ||
my_write(file, create_info->connect_string.str,
create_info->connect_string.length, MYF(MY_NABP)))
goto err;
}
VOID(my_seek(file,filepos,MY_SEEK_SET,MYF(0)));
if (my_write(file,(byte*) forminfo,288,MYF_RW) ||
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment