Commit adceb1f1 authored by unknown's avatar unknown
Browse files

Merge bk-internal.mysql.com:/data0/bk/mysql-5.1

into  bk-internal.mysql.com:/data0/bk/mysql-5.1-arch


sql/sql_show.cc:
  Auto merged
parents 6db6be5a 0447c1e5
Loading
Loading
Loading
Loading
+19 −1
Original line number Diff line number Diff line
@@ -29,7 +29,8 @@
#define MYSQL_STORAGE_ENGINE_PLUGIN  1  /* Storage Engine               */
#define MYSQL_FTPARSER_PLUGIN        2  /* Full-text parser plugin      */
#define MYSQL_DAEMON_PLUGIN          3  /* The daemon/raw plugin type */
#define MYSQL_MAX_PLUGIN_TYPE_NUM    4  /* The number of plugin types   */
#define MYSQL_INFORMATION_SCHEMA_PLUGIN  4  /* The I_S plugin type */
#define MYSQL_MAX_PLUGIN_TYPE_NUM    5  /* The number of plugin types   */

/* We use the following strings to define licenses for plugins */
#define PLUGIN_LICENSE_PROPRIETARY 0
@@ -302,6 +303,13 @@ struct st_mysql_ftparser
/* handlertons of different MySQL releases are incompatible */
#define MYSQL_DAEMON_INTERFACE_VERSION (MYSQL_VERSION_ID << 8)

/*************************************************************************
  API for I_S plugin. (MYSQL_INFORMATION_SCHEMA_PLUGIN)
*/

/* handlertons of different MySQL releases are incompatible */
#define MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION (MYSQL_VERSION_ID << 8)

/*************************************************************************
  API for Storage Engine plugin. (MYSQL_STORAGE_ENGINE_PLUGIN)
*/
@@ -330,5 +338,15 @@ struct st_mysql_daemon
  int interface_version;
};

/*
  Here we define only the descriptor structure, that is referred from
  st_mysql_plugin.
*/

struct st_mysql_information_schema
{
  int interface_version;
};

#endif
+78 −49
Original line number Diff line number Diff line
drop table if exists t1,t2,t3,t4,t5;
DROP TABLE if exists t1,t2,t3,t4,t5,t6;
SET storage_engine=ARCHIVE;
CREATE TABLE t1 (
Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL
@@ -184,7 +185,7 @@ fld1 fld3
250503	heaving
250504	population
250505	bomb
create table t3 engine=archive select * FROM t2;
CREATE TABLE t3 engine=archive select * FROM t2;
select * FROM t3 where fld3='bonfire';
auto	fld1	companynr	fld3	fld4	fld5	fld6
1191	068504	00	bonfire	corresponds	positively	
@@ -12358,7 +12359,7 @@ CREATE TABLE `t5` (
`a` int(11) NOT NULL auto_increment,
b char(12),
PRIMARY KEY  (`a`)
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1;
)  DEFAULT CHARSET=latin1;
INSERT INTO t5 VALUES (NULL, "foo");
INSERT INTO t5 VALUES (NULL, "foo");
INSERT INTO t5 VALUES (NULL, "foo");
@@ -12366,6 +12367,7 @@ INSERT INTO t5 VALUES (NULL, "foo");
INSERT INTO t5 VALUES (NULL, "foo");
INSERT INTO t5 VALUES (32, "foo");
INSERT INTO t5 VALUES (23, "foo");
ERROR 23000: Can't write; duplicate key in table 't5'
INSERT INTO t5 VALUES (NULL, "foo");
INSERT INTO t5 VALUES (NULL, "foo");
INSERT INTO t5 VALUES (3, "foo");
@@ -12379,7 +12381,6 @@ a b
4	foo
5	foo
32	foo
23	foo
33	foo
34	foo
35	foo
@@ -12391,7 +12392,7 @@ CREATE TABLE `t5` (
`a` int(11) NOT NULL auto_increment,
b char(12),
KEY  (`a`)
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 AUTO_INCREMENT=5;
)  DEFAULT CHARSET=latin1 AUTO_INCREMENT=5;
INSERT INTO t5 VALUES (NULL, "foo");
INSERT INTO t5 VALUES (NULL, "foo");
INSERT INTO t5 VALUES (NULL, "foo");
@@ -12443,7 +12444,7 @@ CREATE TABLE `t5` (
`a` int(11) NOT NULL auto_increment,
b blob(12),
KEY  (`a`)
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1;
)  DEFAULT CHARSET=latin1;
INSERT INTO t5 VALUES (NULL, "foo");
INSERT INTO t5 VALUES (NULL, "We the people");
INSERT INTO t5 VALUES (NULL, "in order to form a more pefect union");
@@ -12496,7 +12497,7 @@ CREATE TABLE `t5` (
b blob(12),
c blob(12),
KEY  (`a`)
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1;
)  DEFAULT CHARSET=latin1;
INSERT INTO t5 VALUES (NULL, "foo", "grok this!");
INSERT INTO t5 VALUES (NULL, "We the people", NULL);
INSERT INTO t5 VALUES (NULL, "in order to form a more peefect union", "secure the blessing of liberty");
@@ -12545,8 +12546,8 @@ SELECT c FROM t5 WHERE a IN (32, 23, 5);
c
NULL
posterity
drop table t1;
create table t1 (v varchar(32));
DROP TABLE t1;
CREATE TABLE t1 (v varchar(32)) ;
insert into t1 values ('def'),('abc'),('hij'),('3r4f');
select * from t1;
v
@@ -12554,68 +12555,34 @@ def
abc
hij
3r4f
alter table t1 change v v2 varchar(32);
ALTER TABLE t1 change v v2 varchar(32);
select * from t1;
v2
def
abc
hij
3r4f
alter table t1 change v2 v varchar(64);
ALTER TABLE t1 change v2 v varchar(64);
select * from t1;
v
def
abc
hij
3r4f
update t1 set v = 'lmn' where v = 'hij';
select * from t1;
v
def
abc
lmn
3r4f
alter table t1 add i int auto_increment not null primary key first;
ALTER TABLE t1 add i int auto_increment not null primary key first;
select * from t1;
i	v
1	def
2	abc
3	lmn
4	3r4f
update t1 set i=5 where i=3;
select * from t1;
i	v
1	def
2	abc
5	lmn
4	3r4f
alter table t1 change i i bigint;
select * from t1;
i	v
1	def
2	abc
5	lmn
4	3r4f
alter table t1 add unique key (i, v);
select * from t1 where i between 2 and 4 and v in ('def','3r4f','lmn');
i	v
3	hij
4	3r4f
alter table t1 data directory="$MYSQLTEST_VARDIR/tmp";
Warnings:
Warning	0	DATA DIRECTORY option ignored
select * from t1;
i	v
1	def
2	abc
4	3r4f
5	lmn
DROP TABLE t5;
CREATE TABLE `t5` (
`a` int(11) NOT NULL auto_increment,
b varchar(250),
c varchar(800),
KEY  (`a`)
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1;
)  DEFAULT CHARSET=latin1;
INSERT INTO t5 VALUES (NULL, "foo", "grok this!");
INSERT INTO t5 VALUES (NULL, "We the people", NULL);
INSERT INTO t5 VALUES (NULL, "in order to form a more peefect union", "secure the blessing of liberty");
@@ -12636,4 +12603,66 @@ a b c
23	provide for the common defense	posterity
33	promote the general welfare	do ordain
34	abcdeghijklmnopqrstuvwxyzabcdeghijklmnopqrstuvwxyzabcdeghijklmnopqrstuvwxyzabcdeghijklmnopqrstuvwxyzabcdeghijklmnopqrstuvwxyzabcdeghijklmnopqrstuvwxyzabcdeghijklmnopqrstuvwxyzabcdeghijklmnopqrstuvwxyzabcdeghijklmnopqrstuvwxyzabcdeghijklmnopqrstuvwxyz	do ordain
drop table t1, t2, t4, t5;
CREATE TABLE `t6` (
`a` int(11) NOT NULL auto_increment,
b blob(12),
c int,
KEY  (`a`)
)  DEFAULT CHARSET=latin1;
SELECT * FROM t6;
a	b	c
INSERT INTO t6 VALUES (NULL, "foo", NULL);
INSERT INTO t6 VALUES (NULL, "We the people", 5);
INSERT INTO t6 VALUES (NULL, "in order to form a more pefect union", 9);
INSERT INTO t6 VALUES (NULL, "establish justice", NULL);
INSERT INTO t6 VALUES (NULL, NULL, NULL);
INSERT INTO t6 VALUES (32, "ensure domestic tranquility", NULL);
INSERT INTO t6 VALUES (23, "provide for the common defense", 30);
INSERT INTO t6 VALUES (NULL, "fo fooo", 70);
INSERT INTO t6 VALUES (NULL, NULL, 98);
INSERT INTO t6 VALUES (NULL, "promote the general welfare", 50);
SELECT * FROM t6;
a	b	c
1	foo	NULL
2	We the people	5
3	in order to form a more pefect union	9
4	establish justice	NULL
5	NULL	NULL
32	ensure domestic tranquility	NULL
23	provide for the common defense	30
33	fo fooo	70
34	NULL	98
35	promote the general welfare	50
SELECT * FROM t6 ORDER BY a;
a	b	c
1	foo	NULL
2	We the people	5
3	in order to form a more pefect union	9
4	establish justice	NULL
5	NULL	NULL
23	provide for the common defense	30
32	ensure domestic tranquility	NULL
33	fo fooo	70
34	NULL	98
35	promote the general welfare	50
SELECT * FROM t6 ORDER BY a DESC;
a	b	c
35	promote the general welfare	50
34	NULL	98
33	fo fooo	70
32	ensure domestic tranquility	NULL
23	provide for the common defense	30
5	NULL	NULL
4	establish justice	NULL
3	in order to form a more pefect union	9
2	We the people	5
1	foo	NULL
SHOW CREATE TABLE t6;
Table	Create Table
t6	CREATE TABLE `t6` (
  `a` int(11) NOT NULL AUTO_INCREMENT,
  `b` tinyblob,
  `c` int(11) DEFAULT NULL,
  KEY `a` (`a`)
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1
DROP TABLE t1, t2, t4, t5, t6;
+45 −29
Original line number Diff line number Diff line
@@ -6,9 +6,11 @@
-- source include/have_binlog_format_mixed_or_statement.inc

--disable_warnings
drop table if exists t1,t2,t3,t4,t5;
DROP TABLE if exists t1,t2,t3,t4,t5,t6;
--enable_warnings

SET storage_engine=ARCHIVE;

CREATE TABLE t1 (
  Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
  Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL
@@ -1294,7 +1296,7 @@ select fld1,fld3 FROM t2 where fld1 like "25050_";
#
# Test rename of table
#
create table t3 engine=archive select * FROM t2;
CREATE TABLE t3 engine=archive select * FROM t2;
select * FROM t3 where fld3='bonfire';
select count(*) FROM t3;
# Clean up path in error message
@@ -1356,7 +1358,7 @@ while (`SELECT COUNT(auto)!=1214 FROM t2`)
}
SELECT COUNT(auto) FROM t2;

# Adding test for alter table
# Adding test for ALTER TABLE
ALTER TABLE t2 DROP COLUMN fld6; 
SHOW CREATE TABLE t2;
SELECT * FROM t2;
@@ -1369,7 +1371,7 @@ CREATE TABLE `t5` (
`a` int(11) NOT NULL auto_increment,
b char(12),
PRIMARY KEY  (`a`)
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1;
)  DEFAULT CHARSET=latin1;

INSERT INTO t5 VALUES (NULL, "foo");
INSERT INTO t5 VALUES (NULL, "foo");
@@ -1377,6 +1379,7 @@ INSERT INTO t5 VALUES (NULL, "foo");
INSERT INTO t5 VALUES (NULL, "foo");
INSERT INTO t5 VALUES (NULL, "foo");
INSERT INTO t5 VALUES (32, "foo");
--error 1022
INSERT INTO t5 VALUES (23, "foo");
INSERT INTO t5 VALUES (NULL, "foo");
INSERT INTO t5 VALUES (NULL, "foo");
@@ -1393,7 +1396,7 @@ CREATE TABLE `t5` (
`a` int(11) NOT NULL auto_increment,
b char(12),
KEY  (`a`)
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 AUTO_INCREMENT=5;
)  DEFAULT CHARSET=latin1 AUTO_INCREMENT=5;

INSERT INTO t5 VALUES (NULL, "foo");
INSERT INTO t5 VALUES (NULL, "foo");
@@ -1419,7 +1422,7 @@ CREATE TABLE `t5` (
`a` int(11) NOT NULL auto_increment,
b blob(12),
KEY  (`a`)
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1;
)  DEFAULT CHARSET=latin1;

INSERT INTO t5 VALUES (NULL, "foo");
INSERT INTO t5 VALUES (NULL, "We the people");
@@ -1447,7 +1450,7 @@ CREATE TABLE `t5` (
b blob(12),
c blob(12),
KEY  (`a`)
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1;
)  DEFAULT CHARSET=latin1;

INSERT INTO t5 VALUES (NULL, "foo", "grok this!");
INSERT INTO t5 VALUES (NULL, "We the people", NULL);
@@ -1464,35 +1467,24 @@ SELECT c FROM t5;
SELECT c FROM t5 WHERE a =3;
SELECT c FROM t5 WHERE a IN (32, 23, 5);

# Adding this in case someone tries to add fast alter table and doesn't tes
# Adding this in case someone tries to add fast ALTER TABLE and doesn't tes
# it.
# Some additional tests for new, faster alter table.  Note that most of the
# whole alter table code is being tested all around the test suite already.
# Some additional tests for new, faster ALTER TABLE.  Note that most of the
# whole ALTER TABLE code is being tested all around the test suite already.
#

drop table t1;
create table t1 (v varchar(32));
DROP TABLE t1;
CREATE TABLE t1 (v varchar(32)) ;
insert into t1 values ('def'),('abc'),('hij'),('3r4f');
select * from t1;
# Fast alter, no copy performed
alter table t1 change v v2 varchar(32);
ALTER TABLE t1 change v v2 varchar(32);
select * from t1;
# Fast alter, no copy performed
alter table t1 change v2 v varchar(64);
select * from t1;
update t1 set v = 'lmn' where v = 'hij';
select * from t1;
# Regular alter table
alter table t1 add i int auto_increment not null primary key first;
ALTER TABLE t1 change v2 v varchar(64);
select * from t1;
update t1 set i=5 where i=3;
select * from t1;
alter table t1 change i i bigint;
select * from t1;
alter table t1 add unique key (i, v);
select * from t1 where i between 2 and 4 and v in ('def','3r4f','lmn');

alter table t1 data directory="$MYSQLTEST_VARDIR/tmp";
# Regular ALTER TABLE
ALTER TABLE t1 add i int auto_increment not null primary key first;
select * from t1;

# Testing cleared row key
@@ -1503,7 +1495,7 @@ CREATE TABLE `t5` (
b varchar(250),
c varchar(800),
KEY  (`a`)
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1;
)  DEFAULT CHARSET=latin1;

INSERT INTO t5 VALUES (NULL, "foo", "grok this!");
INSERT INTO t5 VALUES (NULL, "We the people", NULL);
@@ -1516,11 +1508,35 @@ INSERT INTO t5 VALUES (NULL, "abcdeghijklmnopqrstuvwxyzabcdeghijklmnopqrstuvwxyz

SELECT * FROM t5;

CREATE TABLE `t6` (
`a` int(11) NOT NULL auto_increment,
b blob(12),
c int,
KEY  (`a`)
)  DEFAULT CHARSET=latin1;
SELECT * FROM t6;
INSERT INTO t6 VALUES (NULL, "foo", NULL);
INSERT INTO t6 VALUES (NULL, "We the people", 5);
INSERT INTO t6 VALUES (NULL, "in order to form a more pefect union", 9);
INSERT INTO t6 VALUES (NULL, "establish justice", NULL);
INSERT INTO t6 VALUES (NULL, NULL, NULL);
INSERT INTO t6 VALUES (32, "ensure domestic tranquility", NULL);
INSERT INTO t6 VALUES (23, "provide for the common defense", 30);
INSERT INTO t6 VALUES (NULL, "fo fooo", 70);
INSERT INTO t6 VALUES (NULL, NULL, 98);
INSERT INTO t6 VALUES (NULL, "promote the general welfare", 50);
SELECT * FROM t6;
SELECT * FROM t6 ORDER BY a;
SELECT * FROM t6 ORDER BY a DESC;

SHOW CREATE TABLE t6;


# 
# Cleanup, test is over
#


--disable_warnings
drop table t1, t2, t4, t5;
DROP TABLE t1, t2, t4, t5, t6;
--enable_warnings
+5 −3
Original line number Diff line number Diff line
@@ -19,18 +19,20 @@ MYSQLSHAREdir = $(pkgdatadir)
MYSQLBASEdir=           $(prefix)
MYSQLLIBdir=            $(pkglibdir)
INCLUDES =              -I$(top_srcdir)/include -I$(top_builddir)/include \
                        -I$(srcdir) 
			-I$(top_srcdir)/regex \
			-I$(top_srcdir)/sql \
                        -I$(srcdir) @ZLIB_INCLUDES@

EXTRA_LTLIBRARIES =	libdaemon_example.la
pkglib_LTLIBRARIES =	@plugin_daemon_example_shared_target@
libdaemon_example_la_LDFLAGS =	-module -rpath $(MYSQLLIBdir)
libdaemon_example_la_CXXFLAGS=	$(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
libdaemon_example_la_CFLAGS =	$(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
libdaemon_example_la_SOURCES =	daemon_example.c
libdaemon_example_la_SOURCES =	daemon_example.cc


EXTRA_LIBRARIES =	libdaemon_example.a
noinst_LIBRARIES =	@plugin_daemon_example_static_target@
libdaemon_example_a_CXXFLAGS =	$(AM_CFLAGS)
libdaemon_example_a_CFLAGS =	$(AM_CFLAGS)
libdaemon_example_a_SOURCES=	daemon_example.c
libdaemon_example_a_SOURCES=	daemon_example.cc
+196 −0
Original line number Diff line number Diff line
@@ -13,10 +13,13 @@
   along with this program; if not, write to the Free Software
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */

#include <mysql_priv.h>
#include <stdlib.h>
#include <ctype.h>
#include <mysql_version.h>
#include <mysql/plugin.h>
#include <my_global.h>
#include <my_dir.h>

/*
#if !defined(__attribute__) && (defined(__cplusplus) || !defined(__GNUC__)  || __GNUC__ == 2 && __GNUC_MINOR__ < 8)
@@ -24,7 +27,44 @@
#endif
*/

#define HEART_STRING_BUFFER 100

struct mysql_heartbeat_context
{
  pthread_t heartbeat_thread;
  File heartbeat_file;
};

pthread_handler_t mysql_heartbeat(void *p)
{
  DBUG_ENTER("mysql_heartbeat");
  struct mysql_heartbeat_context *con= (struct mysql_heartbeat_context *)p;
  char buffer[HEART_STRING_BUFFER];
  unsigned int x= 0;
  time_t result;
  struct tm tm_tmp;

  while(1)
  {
    sleep(5);

    result= time(NULL);
    localtime_r(&result, &tm_tmp);
    my_snprintf(buffer, sizeof(buffer),
                "Heartbeat at %02d%02d%02d %2d:%02d:%02d\n",
                tm_tmp.tm_year % 100,
                tm_tmp.tm_mon+1,
                tm_tmp.tm_mday,
                tm_tmp.tm_hour,
                tm_tmp.tm_min,
                tm_tmp.tm_sec);
    my_write(con->heartbeat_file, buffer, strlen(buffer), MYF(0));
    x++;
  }

  
  DBUG_RETURN(0);
}

/*
  Initialize the daemon example at server start or plugin installation.
@@ -33,7 +73,7 @@
    daemon_example_plugin_init()

  DESCRIPTION
    Does nothing.
    Starts up heartbeatbeat thread

  RETURN VALUE
    0                    success
@@ -42,7 +82,51 @@

static int daemon_example_plugin_init(void *p)
{
  return(0);
  DBUG_ENTER("daemon_example_plugin_init");
  struct mysql_heartbeat_context *con;
  pthread_attr_t attr;          /* Thread attributes */
  char heartbeat_filename[FN_REFLEN];
  char buffer[HEART_STRING_BUFFER];
  time_t result= time(NULL);
  struct tm tm_tmp;

  struct st_plugin_int *plugin= (struct st_plugin_int *)p;

  con= (struct mysql_heartbeat_context *)my_malloc(sizeof(struct mysql_heartbeat_context), MYF(0)); 

  fn_format(heartbeat_filename, "mysql-heartbeat", "", ".log", MY_REPLACE_EXT | MY_UNPACK_FILENAME);
  unlink(heartbeat_filename);
  con->heartbeat_file= my_open(heartbeat_filename, O_CREAT|O_RDWR, MYF(0));

  /*
    No threads exist at this point in time, so this is thread safe.
  */
  localtime_r(&result, &tm_tmp);
  my_snprintf(buffer, sizeof(buffer),
              "Starting up at %02d%02d%02d %2d:%02d:%02d\n",
              tm_tmp.tm_year % 100,
              tm_tmp.tm_mon+1,
              tm_tmp.tm_mday,
              tm_tmp.tm_hour,
              tm_tmp.tm_min,
              tm_tmp.tm_sec);
  my_write(con->heartbeat_file, buffer, strlen(buffer), MYF(0));

  pthread_attr_init(&attr);
  pthread_attr_setdetachstate(&attr,
                              PTHREAD_CREATE_JOINABLE);


  /* now create the thread */
  if (pthread_create(&con->heartbeat_thread, &attr, mysql_heartbeat, (void *)con) != 0)
  {
    fprintf(stderr,"Could not create heartbeat thread!\n");
    exit(0);
  }

  plugin->data= (void *)con;

  DBUG_RETURN(0);
}


@@ -58,10 +142,33 @@ static int daemon_example_plugin_init(void *p)
    1                    failure (cannot happen)

*/

static int daemon_example_plugin_deinit(void *p)
{
  return(0);
  DBUG_ENTER("daemon_example_plugin_deinit");
  char buffer[HEART_STRING_BUFFER];
  struct st_plugin_int *plugin= (struct st_plugin_int *)p;
  struct mysql_heartbeat_context *con= (struct mysql_heartbeat_context *)plugin->data;
  time_t result= time(NULL);
  struct tm tm_tmp;

  pthread_cancel(con->heartbeat_thread);

  localtime_r(&result, &tm_tmp);
  my_snprintf(buffer, sizeof(buffer),
              "Shutting down at %02d%02d%02d %2d:%02d:%02d\n",
              tm_tmp.tm_year % 100,
              tm_tmp.tm_mon+1,
              tm_tmp.tm_mday,
              tm_tmp.tm_hour,
              tm_tmp.tm_min,
              tm_tmp.tm_sec);
  my_write(con->heartbeat_file, buffer, strlen(buffer), MYF(0));
  my_close(con->heartbeat_file, MYF(0));


  my_free((char *)con, MYF(0));

  DBUG_RETURN(0);
}

struct st_mysql_daemon daemon_example_plugin=
@@ -77,7 +184,7 @@ mysql_declare_plugin(daemon_example)
  &daemon_example_plugin,
  "daemon_example",
  "Brian Aker",
  "Daemon example that tests init and deinit of a plugin",
  "Daemon example, creates a heartbeat beat file in mysql-heartbeat.log",
  PLUGIN_LICENSE_GPL,
  daemon_example_plugin_init, /* Plugin Init */
  daemon_example_plugin_deinit, /* Plugin Deinit */
Loading