let $MYSQLD_DATADIR= `select @@datadir`;

--copy_file $MTR_SUITE_DIR/std_data/Testbal.dat $MYSQLD_DATADIR/test/Testbal.dat

SET time_zone='+00:00';

--echo #
--echo # Testing little endian table
--echo #
CREATE TABLE t1
(
  fig INT(4) NOT NULL FIELD_FORMAT='C',
  name CHAR(10) NOT NULL,
  birth DATE NOT NULL FIELD_FORMAT='L',
  id CHAR(5) NOT NULL FIELD_FORMAT='L2',
  salary DOUBLE(9,2) NOT NULL DEFAULT 0.00 FIELD_FORMAT='LF',
  dept INT(4) NOT NULL FIELD_FORMAT='L2'
) ENGINE=CONNECT TABLE_TYPE=BIN BLOCK_SIZE=5 FILE_NAME='Testbal.dat';
SELECT * FROM t1;
INSERT INTO t1 VALUES (5555,'RONALD','1980-02-26','3333',4444.44,555);
SELECT * FROM t1;

DROP TABLE t1;
CREATE TABLE t1
(
  fig INT(4) NOT NULL FIELD_FORMAT='C',
  name CHAR(10) NOT NULL,
  birth DATE NOT NULL,
  id CHAR(5) NOT NULL FIELD_FORMAT='S',
  salary DOUBLE(9,2) NOT NULL DEFAULT 0.00 FIELD_FORMAT='F',
  dept INT(4) NOT NULL FIELD_FORMAT='S'
) ENGINE=CONNECT TABLE_TYPE=BIN BLOCK_SIZE=5 FILE_NAME='Testbal.dat' OPTION_LIST='Endian=Little';
SELECT * FROM t1;

--echo #
--echo # Testing big endian table
--echo #
CREATE TABLE t2 (
  fig INT(4) NOT NULL FIELD_FORMAT='C',
  name CHAR(10) NOT NULL,
  birth DATE NOT NULL FIELD_FORMAT='B',
  id CHAR(5) NOT NULL FIELD_FORMAT='BS',
  salary DOUBLE(9,2) NOT NULL DEFAULT 0.00 FIELD_FORMAT='BF',
  dept INT(4) NOT NULL FIELD_FORMAT='B2'
) ENGINE=CONNECT TABLE_TYPE=BIN BLOCK_SIZE=5 FILE_NAME='Testbal.bin';
INSERT INTO t2 SELECT * FROM t1;
SELECT * FROM t2;

DROP TABLE t2;
CREATE TABLE t2 (
  fig INT(4) NOT NULL FIELD_FORMAT='C',
  name CHAR(10) NOT NULL,
  birth DATE NOT NULL,
  id CHAR(5) NOT NULL FIELD_FORMAT='S',
  salary DOUBLE(9,2) NOT NULL DEFAULT 0.00 FIELD_FORMAT='F',
  dept INT(4) NOT NULL FIELD_FORMAT='2'
) ENGINE=CONNECT TABLE_TYPE=BIN BLOCK_SIZE=5 FILE_NAME='Testbal.bin' OPTION_LIST='Endian=Big';
SELECT * FROM t2;

DROP TABLE t2;
CREATE TABLE t2 (
  fig CHAR(4) NOT NULL,
  name CHAR(10) NOT NULL,
  birth DATE NOT NULL,
  id SMALLINT(5) NOT NULL,
  salary DOUBLE(9,2) NOT NULL DEFAULT 0.00 FIELD_FORMAT='F',
  dept SMALLINT(4) NOT NULL
) ENGINE=CONNECT TABLE_TYPE=BIN BLOCK_SIZE=5 FILE_NAME='Testbal.bin' OPTION_LIST='Endian=Big';
SELECT * FROM t2;

DROP TABLE t2;
CREATE TABLE t2 (
  fig INT(4) NOT NULL FIELD_FORMAT='C',
  name CHAR(10) NOT NULL,
  birth DATE NOT NULL FIELD_FORMAT='B',
  id CHAR(5) NOT NULL FIELD_FORMAT='BS',
  salary DOUBLE(9,2) NOT NULL DEFAULT 0.00 FIELD_FORMAT='BF',
  dept SMALLINT(4) NOT NULL FIELD_FORMAT='B'
) ENGINE=CONNECT TABLE_TYPE=BIN BLOCK_SIZE=5 FILE_NAME='Testbal.bin';
SELECT * FROM t2;

DROP TABLE t1, t2;

#
# Clean up
#
--remove_file $MYSQLD_DATADIR/test/Testbal.dat
--remove_file $MYSQLD_DATADIR/test/Testbal.bin
