Commit 10de4386 authored by Olivier Bertrand's avatar Olivier Bertrand

Merge branch 'ob-10.0' into 10.0

parents 6e48347d 26adbb2d
......@@ -752,7 +752,7 @@ RCODE CntIndexRead(PGLOBAL g, PTDB ptdb, OPVAL op,
return RC_FX;
} else if (x == 2) {
// Remote index
if (ptdb->ReadKey(g, op, kr))
if (op != OP_SAME && ptdb->ReadKey(g, op, kr))
return RC_FX;
goto rnd;
......
......@@ -2288,7 +2288,7 @@ bool ha_connect::MakeKeyWhere(PGLOBAL g, PSTRG qry, OPVAL vop, char q,
op= OP_EQ;
break;
case HA_READ_AFTER_KEY:
op= (stlen >= len) ? (!i ? OP_GT : OP_LE) : OP_GE;
op= (stlen >= len || i > 0) ? (i > 0 ? OP_LE : OP_GT) : OP_GE;
break;
case HA_READ_KEY_OR_NEXT:
op= OP_GE;
......
......@@ -959,11 +959,16 @@ void MYSQLC::FreeResult(void)
/***********************************************************************/
/* Place the cursor at the beginning of the result set. */
/***********************************************************************/
void MYSQLC::Rewind(void)
int MYSQLC::Rewind(PGLOBAL g, PSZ sql)
{
if (m_Res)
DataSeek(0);
int rc = RC_OK;
if (m_Res)
DataSeek(0);
else if (sql)
rc = ExecSQL(g, sql);
return rc;
} // end of Rewind
/***********************************************************************/
......
......@@ -80,7 +80,7 @@ class DllItem MYSQLC {
int Fetch(PGLOBAL g, int pos);
char *GetCharField(int i);
int GetFieldLength(int i);
void Rewind(void);
int Rewind(PGLOBAL g, PSZ sql);
void FreeResult(void);
void Close(void);
......
......@@ -112,3 +112,324 @@ id msg
6 Six
DROP TABLE t2;
DROP TABLE t1;
#
# Make local FIX table with indices matricule and nom/prenom
#
CREATE TABLE t1
(
matricule INT(4) KEY NOT NULL field_format='Z',
nom VARCHAR(16) NOT NULL,
prenom VARCHAR(20) NOT NULL,
sexe SMALLINT(1) NOT NULL COMMENT 'sexe 1:M 2:F',
aanais INT(4) NOT NULL,
mmnais INT(2) NOT NULL,
ddentree DATE NOT NULL date_format='YYYYMM',
ddnom DATE NOT NULL date_format='YYYYMM',
brut INT(5) NOT NULL,
net DOUBLE(8,2) NOT NULL,
service INT(2) NOT NULL,
sitmat CHAR(1) NOT NULL,
formation CHAR(5) NOT NULL,
INDEX NP(nom,prenom)
) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='emp.txt' ENDING=2;
#
# Make MYSQL table with same indices
#
CREATE TABLE t2
(
matricule INT(4) KEY NOT NULL,
nom VARCHAR(16) NOT NULL,
prenom VARCHAR(20) NOT NULL,
sexe SMALLINT(1) NOT NULL,
aanais INT(4) NOT NULL,
mmnais INT(2) NOT NULL,
ddentree DATE NOT NULL date_format='YYYYMM',
ddnom DATE NOT NULL date_format='YYYYMM',
brut INT(5) NOT NULL,
net DOUBLE(8,2) NOT NULL,
service INT(2) NOT NULL,
sitmat CHAR(1) NOT NULL,
formation CHAR(5) NOT NULL,
INDEX NP(nom,prenom)
) ENGINE=CONNECT TABLE_TYPE=MYSQL CONNECTIOn='mysql://root@localhost/test/t1';
SELECT * FROM t2 limit 10;
matricule nom prenom sexe aanais mmnais ddentree ddnom brut net service sitmat formation
5745 ESCOURCHE BENEDICTE 2 1935 7 1962-12-01 1994-05-01 18345 14275.50 0 M TECHN
9692 VICENTE LAURENCE 2 1941 8 1967-10-01 1989-01-01 16212 13032.80 0 M ANGL
9146 NICOLAS ROGER 1 1941 6 1964-07-01 1995-02-01 34173 25098.65 0 M SANS
2985 TESSEREAU MARIE HELENE 2 1941 9 1967-01-01 1990-01-01 19323 14933.78 0 V SANS
3368 MOGADOR ALAIN 1 1941 1 1961-09-01 1993-11-01 43303 31420.55 0 C SANS
7394 CHAUSSEE ERIC DENIS 1 1944 9 1965-11-01 1983-12-01 32002 23583.86 0 M ANGL
4655 MAILLOT GEORGES 1 1945 5 1970-09-01 1986-12-01 24700 18541.64 0 C ANGL
2825 CAMILLE NADINE 2 1956 9 1994-01-01 1993-01-01 19494 15050.45 0 M SANS
1460 BRUYERES JEAN MARC 1 1958 8 1984-08-01 1988-05-01 20902 15980.07 0 M SANS
4974 LONES GERARD 1 1959 10 1979-01-01 1994-12-01 16081 12916.70 0 M SANS
SELECT matricule, nom, prenom FROM t2 WHERE nom IN ('FOCH','MOGADOR');
matricule nom prenom
1977 FOCH BERNADETTE
5707 FOCH DENIS
2552 FOCH FRANCK
2634 FOCH JOCELYNE
5765 FOCH ROBERT
4080 FOCH SERGE
3368 MOGADOR ALAIN
SELECT matricule, nom, prenom FROM t2 WHERE nom = 'FOCH' OR nom = 'MOGADOR';
matricule nom prenom
1977 FOCH BERNADETTE
5707 FOCH DENIS
2552 FOCH FRANCK
2634 FOCH JOCELYNE
5765 FOCH ROBERT
4080 FOCH SERGE
3368 MOGADOR ALAIN
SELECT matricule, nom, prenom FROM t2 WHERE nom < 'ADDAX';
matricule nom prenom
4552 ABBADIE MONIQUE
307 ABBAYE ANNICK
6627 ABBAYE GERALD
7961 ABBE KATIA
1340 ABBE MICHELE
9270 ABBE SOPHIE
2945 ABBEVILLE PASCAL
8596 ABEBERRY PATRICK
6399 ABEILLES RENE
8673 ABEL JEAN PIERRE
6124 ABELIAS DELIA
6314 ABERDEN EVELYNE
895 ABORD CHANTAL
2728 ABOUT CATHERINE MARIE
398 ABREUVOIR JEAN LUC
1122 ACACIAS SERGE
1644 ACARDIE BEATE
115 ACHILLE JACQUES
4038 ADAM JANICK
3395 ADAM JEAN CLAUDE
SELECT matricule, nom, prenom FROM t2 WHERE nom <= 'ABEL';
matricule nom prenom
4552 ABBADIE MONIQUE
307 ABBAYE ANNICK
6627 ABBAYE GERALD
7961 ABBE KATIA
1340 ABBE MICHELE
9270 ABBE SOPHIE
2945 ABBEVILLE PASCAL
8596 ABEBERRY PATRICK
6399 ABEILLES RENE
8673 ABEL JEAN PIERRE
SELECT matricule, nom, prenom FROM t2 WHERE nom > 'YVON';
matricule nom prenom
9742 YZENGREMER MICHEL
8738 ZILINA JEAN LOUIS
5357 ZOLA BERNARD
5441 ZOLA BRIGITTE
1325 ZOLA CHRISTINE
4859 ZORI CATHERINE
4102 ZOUAVES ALAIN
SELECT matricule, nom, prenom FROM t2 WHERE nom >= 'YVON';
matricule nom prenom
5389 YVON CAROLE
9742 YZENGREMER MICHEL
8738 ZILINA JEAN LOUIS
5357 ZOLA BERNARD
5441 ZOLA BRIGITTE
1325 ZOLA CHRISTINE
4859 ZORI CATHERINE
4102 ZOUAVES ALAIN
SELECT matricule, nom, prenom FROM t2 WHERE nom <= 'ABEL' OR nom > 'YVON';
matricule nom prenom
4552 ABBADIE MONIQUE
307 ABBAYE ANNICK
6627 ABBAYE GERALD
7961 ABBE KATIA
1340 ABBE MICHELE
9270 ABBE SOPHIE
2945 ABBEVILLE PASCAL
8596 ABEBERRY PATRICK
6399 ABEILLES RENE
8673 ABEL JEAN PIERRE
9742 YZENGREMER MICHEL
8738 ZILINA JEAN LOUIS
5357 ZOLA BERNARD
5441 ZOLA BRIGITTE
1325 ZOLA CHRISTINE
4859 ZORI CATHERINE
4102 ZOUAVES ALAIN
SELECT matricule, nom, prenom FROM t2 WHERE nom > 'HELEN' AND nom < 'HEROS';
matricule nom prenom
9096 HELENA PHILIPPE
3309 HELENE ISABELLE
8365 HELIOTROPES LISE
4666 HELLEN PIERRE
5781 HELSINKI DANIELLE
7626 HENIN PHILIPPE
4254 HENIN SERGE
2673 HENNER LILIANE
9716 HENRI JACQUES
2085 HEOL GUY PAUL
2579 HERANDIERE PIERRE
7093 HERAULTS DANIEL
4050 HERBILLON FRANCOIS
9231 HERBILLON MADELEINE
1291 HERMITAGE XAVIER
6185 HERMITTE FRANCOIS
403 HERMITTE PHILIPPE
9749 HEROLD ISABELLE
SELECT matricule, nom, prenom FROM t2 WHERE nom BETWEEN 'HELEN' AND 'HEROS';
matricule nom prenom
6199 HELEN MARTIAL
9096 HELENA PHILIPPE
3309 HELENE ISABELLE
8365 HELIOTROPES LISE
4666 HELLEN PIERRE
5781 HELSINKI DANIELLE
7626 HENIN PHILIPPE
4254 HENIN SERGE
2673 HENNER LILIANE
9716 HENRI JACQUES
2085 HEOL GUY PAUL
2579 HERANDIERE PIERRE
7093 HERAULTS DANIEL
4050 HERBILLON FRANCOIS
9231 HERBILLON MADELEINE
1291 HERMITAGE XAVIER
6185 HERMITTE FRANCOIS
403 HERMITTE PHILIPPE
9749 HEROLD ISABELLE
8445 HEROS SYLVIE
SELECT matricule, nom, prenom FROM t2 WHERE nom BETWEEN 'HELEN' AND 'HEROS' AND prenom = 'PHILIPPE';
matricule nom prenom
9096 HELENA PHILIPPE
7626 HENIN PHILIPPE
403 HERMITTE PHILIPPE
SELECT matricule, nom, prenom FROM t2 ORDER BY nom LIMIT 10;
matricule nom prenom
4552 ABBADIE MONIQUE
6627 ABBAYE GERALD
307 ABBAYE ANNICK
7961 ABBE KATIA
1340 ABBE MICHELE
9270 ABBE SOPHIE
2945 ABBEVILLE PASCAL
8596 ABEBERRY PATRICK
6399 ABEILLES RENE
8673 ABEL JEAN PIERRE
SELECT a.nom, a.prenom, b.nom FROM t1 a STRAIGHT_JOIN t2 b ON a.prenom = b.prenom WHERE a.nom = 'FOCH' AND a.nom != b.nom;
nom prenom nom
FOCH SERGE ACACIAS
FOCH ROBERT AGRIANT
FOCH JOCELYNE ALEXIS
FOCH DENIS AMBOISE
FOCH SERGE ANDALUCIA
FOCH ROBERT ANNECY
FOCH SERGE ARCACHON
FOCH JOCELYNE AUGUSTE
FOCH JOCELYNE BASSE
FOCH SERGE BEACH
FOCH FRANCK BEARN
FOCH SERGE BELLES
FOCH DENIS BERARD
FOCH DENIS BERIN
FOCH BERNADETTE BERTIN
FOCH DENIS BILLEHOU
FOCH DENIS BOILEAU
FOCH BERNADETTE BOISSY
FOCH ROBERT BONVIN
FOCH SERGE BOUTON
FOCH SERGE BREUIL
FOCH SERGE CARREFOUR
FOCH JOCELYNE CARRERE
FOCH JOCELYNE CHAPELLE
FOCH SERGE CHATEAU
FOCH ROBERT CHENIER
FOCH SERGE COLLETTE
FOCH DENIS CONNE
FOCH SERGE COOLE
FOCH DENIS COULOUBRIER
FOCH DENIS COUTURIER
FOCH ROBERT CURAT
FOCH ROBERT DAUDET
FOCH SERGE ECLUSE
FOCH SERGE EGUILLON
FOCH DENIS EPINETTES
FOCH DENIS FIGOURNAS
FOCH JOCELYNE FLEMING
FOCH JOCELYNE GAMBADES
FOCH ROBERT GIOTERAIE
FOCH SERGE GOAS
FOCH ROBERT GRAFFIANE
FOCH SERGE GREFFIER
FOCH ROBERT GUILLOTIERE
FOCH SERGE HENIN
FOCH BERNADETTE HUNTZIGER
FOCH FRANCK ILLIERS
FOCH DENIS ISTANBUL
FOCH DENIS ITALIE
FOCH SERGE JARDIN
FOCH FRANCK JEANPIERRE
FOCH JOCELYNE KENNEDY
FOCH FRANCK LABBE
FOCH DENIS LACATE
FOCH FRANCK LACOMBE
FOCH ROBERT LAMOTHE
FOCH BERNADETTE LATECOERE
FOCH BERNADETTE LEGER
FOCH SERGE LEONIE
FOCH FRANCK LEROY
FOCH SERGE LOZERE
FOCH DENIS MAROLLES
FOCH ROBERT MARRONIERS
FOCH SERGE MARSAT
FOCH SERGE MONTAGNE
FOCH FRANCK MONTALEIGNE
FOCH DENIS MONTELIER
FOCH DENIS MONTILS
FOCH BERNADETTE MONTJUSTIN
FOCH SERGE MORIZET
FOCH ROBERT NIMES
FOCH ROBERT NORD
FOCH SERGE NOVEMBRE
FOCH BERNADETTE ONZE
FOCH SERGE ORANGERIE
FOCH FRANCK ORVEAU
FOCH BERNADETTE PALMAROLE
FOCH JOCELYNE PEYBERT
FOCH ROBERT PEYNIBLOU
FOCH ROBERT PIECE
FOCH JOCELYNE PIED
FOCH ROBERT PLAGNE
FOCH SERGE PLAISANCE
FOCH BERNADETTE PLOUHARNEL
FOCH DENIS POINTE
FOCH ROBERT POMMERY
FOCH JOCELYNE PONTAROUX
FOCH DENIS PORTO
FOCH ROBERT PRESIDENT
FOCH ROBERT PUJADE
FOCH FRANCK PURPAN
FOCH ROBERT QUILICHINI
FOCH DENIS REINOTS
FOCH DENIS REMPART
FOCH SERGE RESISTANCE
FOCH SERGE RESTANQUES
FOCH ROBERT RIOU
FOCH FRANCK ROCQUENCOURT
FOCH ROBERT ROLL
FOCH ROBERT ROSSA
FOCH SERGE ROSSAYS
FOCH DENIS ROUSSIER
FOCH FRANCK RUSSIE
FOCH ROBERT SABLONS
FOCH SERGE SARTRE
FOCH SERGE SAVIGNAC
FOCH SERGE SEGUR
FOCH ROBERT STRASBOURG
FOCH ROBERT TIRE
FOCH DENIS TORTE
FOCH DENIS TOULON
FOCH ROBERT TUBY
FOCH DENIS VALMANTE
FOCH SERGE VANOEL
FOCH ROBERT VIARMES
FOCH SERGE WILSON
DROP TABLE t2;
DROP TABLE t1;
......@@ -64,3 +64,70 @@ SELECT * FROM t2;
DROP TABLE t2;
DROP TABLE t1;
let $MYSQLD_DATADIR= `select @@datadir`;
--copy_file $MTR_SUITE_DIR/std_data/emp.txt $MYSQLD_DATADIR/test/emp.txt
--echo #
--echo # Make local FIX table with indices matricule and nom/prenom
--echo #
CREATE TABLE t1
(
matricule INT(4) KEY NOT NULL field_format='Z',
nom VARCHAR(16) NOT NULL,
prenom VARCHAR(20) NOT NULL,
sexe SMALLINT(1) NOT NULL COMMENT 'sexe 1:M 2:F',
aanais INT(4) NOT NULL,
mmnais INT(2) NOT NULL,
ddentree DATE NOT NULL date_format='YYYYMM',
ddnom DATE NOT NULL date_format='YYYYMM',
brut INT(5) NOT NULL,
net DOUBLE(8,2) NOT NULL,
service INT(2) NOT NULL,
sitmat CHAR(1) NOT NULL,
formation CHAR(5) NOT NULL,
INDEX NP(nom,prenom)
) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='emp.txt' ENDING=2;
--echo #
--echo # Make MYSQL table with same indices
--echo #
CREATE TABLE t2
(
matricule INT(4) KEY NOT NULL,
nom VARCHAR(16) NOT NULL,
prenom VARCHAR(20) NOT NULL,
sexe SMALLINT(1) NOT NULL,
aanais INT(4) NOT NULL,
mmnais INT(2) NOT NULL,
ddentree DATE NOT NULL date_format='YYYYMM',
ddnom DATE NOT NULL date_format='YYYYMM',
brut INT(5) NOT NULL,
net DOUBLE(8,2) NOT NULL,
service INT(2) NOT NULL,
sitmat CHAR(1) NOT NULL,
formation CHAR(5) NOT NULL,
INDEX NP(nom,prenom)
) ENGINE=CONNECT TABLE_TYPE=MYSQL CONNECTIOn='mysql://root@localhost/test/t1';
SELECT * FROM t2 limit 10;
SELECT matricule, nom, prenom FROM t2 WHERE nom IN ('FOCH','MOGADOR');
SELECT matricule, nom, prenom FROM t2 WHERE nom = 'FOCH' OR nom = 'MOGADOR';
SELECT matricule, nom, prenom FROM t2 WHERE nom < 'ADDAX';
SELECT matricule, nom, prenom FROM t2 WHERE nom <= 'ABEL';
SELECT matricule, nom, prenom FROM t2 WHERE nom > 'YVON';
SELECT matricule, nom, prenom FROM t2 WHERE nom >= 'YVON';
SELECT matricule, nom, prenom FROM t2 WHERE nom <= 'ABEL' OR nom > 'YVON';
SELECT matricule, nom, prenom FROM t2 WHERE nom > 'HELEN' AND nom < 'HEROS';
SELECT matricule, nom, prenom FROM t2 WHERE nom BETWEEN 'HELEN' AND 'HEROS';
SELECT matricule, nom, prenom FROM t2 WHERE nom BETWEEN 'HELEN' AND 'HEROS' AND prenom = 'PHILIPPE';
SELECT matricule, nom, prenom FROM t2 ORDER BY nom LIMIT 10;
SELECT a.nom, a.prenom, b.nom FROM t1 a STRAIGHT_JOIN t2 b ON a.prenom = b.prenom WHERE a.nom = 'FOCH' AND a.nom != b.nom;
DROP TABLE t2;
DROP TABLE t1;
#
# Clean up
#
--remove_file $MYSQLD_DATADIR/test/emp.txt
--remove_file $MYSQLD_DATADIR/test/emp.fnx
......@@ -19,7 +19,7 @@
/* --------------- */
/* TABMYSQL.CPP - Source code */
/* PLGDBSEM.H - DB application declaration file */
/* TABMYSQL.H - TABODBC classes declaration file */
/* TABMYSQL.H - TABMYSQL classes declaration file */
/* GLOBAL.H - Global declaration file */
/* */
/* REQUIRED LIBRARIES: */
......@@ -857,7 +857,9 @@ bool TDBMYSQL::OpenDB(PGLOBAL g)
/*******************************************************************/
/* Table already open, just replace it at its beginning. */
/*******************************************************************/
Myc.Rewind();
if (Myc.Rewind(g, (Mode == MODE_READX) ? Query->GetStr() : NULL) != RC_OK)
return true;
N = -1;
return false;
} // endif use
......
......@@ -566,17 +566,17 @@ int get_connection(MEM_ROOT *mem_root, FEDERATEDX_SHARE *share)
at the address of the share.
*/
share->server_name_length= server->server_name_length;
share->server_name= server->server_name;
share->username= server->username;
share->password= server->password;
share->database= server->db;
share->server_name= const_cast<char*>(server->server_name);
share->username= const_cast<char*>(server->username);
share->password= const_cast<char*>(server->password);
share->database= const_cast<char*>(server->db);
share->port= server->port > MIN_PORT && server->port < 65536 ?
(ushort) server->port : MYSQL_PORT;
share->hostname= server->host;
if (!(share->socket= server->socket) &&
share->hostname= const_cast<char*>(server->host);
if (!(share->socket= const_cast<char*>(server->socket)) &&
!strcmp(share->hostname, my_localhost))
share->socket= (char *) MYSQL_UNIX_ADDR;
share->scheme= server->scheme;
share->scheme= const_cast<char*>(server->scheme);
DBUG_PRINT("info", ("share->username: %s", share->username));
DBUG_PRINT("info", ("share->password: %s", share->password));
......@@ -1319,7 +1319,7 @@ bool ha_federatedx::create_where_from_key(String *to,
break;
}
DBUG_PRINT("info", ("federatedx HA_READ_AFTER_KEY %d", i));
if (store_length >= length) /* end key */
if (store_length >= length || i > 0) /* end key */
{
if (emit_key_part_name(&tmp, key_part))
goto err;
......@@ -2555,9 +2555,7 @@ int ha_federatedx::index_read_idx(uchar *buf, uint index, const uchar *key,
RESULT
0 ok In this case *result will contain the result set
table->status == 0
# error In this case *result will contain 0
table->status == STATUS_NOT_FOUND
*/
int ha_federatedx::index_read_idx_with_result_set(uchar *buf, uint index,
......@@ -2614,11 +2612,9 @@ int ha_federatedx::index_read_idx_with_result_set(uchar *buf, uint index,
insert_dynamic(&results, (uchar*) result);
*result= 0;
table->status= STATUS_NOT_FOUND;
DBUG_RETURN(retval);
error:
table->status= STATUS_NOT_FOUND;
my_error(retval, MYF(0), error_buffer);
DBUG_RETURN(retval);
}
......@@ -2699,7 +2695,6 @@ int ha_federatedx::read_range_first(const key_range *start_key,
DBUG_RETURN(retval);
error:
table->status= STATUS_NOT_FOUND;
DBUG_RETURN(retval);
}
......@@ -2904,8 +2899,6 @@ int ha_federatedx::read_next(uchar *buf, FEDERATEDX_IO_RESULT *result)
FEDERATEDX_IO_ROW *row;
DBUG_ENTER("ha_federatedx::read_next");
table->status= STATUS_NOT_FOUND; // For easier return
if ((retval= txn->acquire(share, TRUE, &io)))
DBUG_RETURN(retval);
......@@ -2990,7 +2983,6 @@ int ha_federatedx::rnd_pos(uchar *buf, uchar *pos)
DBUG_RETURN(retval);
error:
table->status= STATUS_NOT_FOUND;
DBUG_RETURN(retval);
}
......@@ -3093,7 +3085,7 @@ int ha_federatedx::info(uint flag)
else if (remote_error_number != -1 /* error already reported */)
{
error_code= remote_error_number;
my_error(error_code, MYF(0), ER(error_code));
my_error(error_code, MYF(0), ER_THD(thd, error_code));
}
fail:
tmp_txn->release(&tmp_io);
......
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