re: Bug: last_insert_id() not replicated correctly

2003-03-20 Thread Victoria Reznichenko
On Tuesday 18 March 2003 17:20, Chris Wilson wrote:
 Using mysql 2.23.54a as both master  slave:

 ** On master:

 mysql CREATE DATABASE repl_test;
 Query OK, 1 row affected (0.03 sec)

 mysql USE repl_test;
 Database changed
 mysql CREATE TABLE test (
 - a INT UNSIGNED AUTO_INCREMENT NOT NULL ,
 - b INT UNSIGNED NOT NULL,
 - PRIMARY KEY (a)
 - );
 Query OK, 0 rows affected (0.02 sec)

 mysql INSERT INTO test (b) VALUES (1);
 Query OK, 1 row affected (0.01 sec)

 mysql INSERT INTO test (b) VALUES (LAST_INSERT_ID());
 Query OK, 1 row affected (0.00 sec)

 mysql INSERT INTO test (b) VALUES (LAST_INSERT_ID());
 Query OK, 1 row affected (0.00 sec)

 mysql SELECT * FROM test;
 +---+---+

 | a | b |

 +---+---+

 | 1 | 1 |
 | 2 | 1 |
 | 3 | 2 |

 +---+---+
 3 rows in set (0.00 sec)

 ** On slave:

 mysql USE repl_test;
 Reading table information for completion of table and column names
 You can turn off this feature to get a quicker startup with -A

 Database changed
 mysql SELECT * FROM test;
 +---+---+

 | a | b |

 +---+---+

 | 1 | 1 |
 | 2 | 2 |
 | 3 | 3 |

 +---+---+
 3 rows in set (0.00 sec)

 Looking at the binlog it appears that the problem is on the master and that
 LAST_INSERT_ID gets set to the same value as INSERT_ID rather than the
 previous value (ie this problem only affects inserts that are inserting
 into tables with auto increment columns).

Seems, it's already fixed. I tested on 3.23.56 and ypur example worked fine. I 
got the following result on both boxes.
 
mysql SELECT * FROM test;
+---+---+
| a | b |
+---+---+
| 1 | 1 |
| 2 | 1 |
| 3 | 2 |
+---+---+



-- 
For technical support contracts, goto https://order.mysql.com/?ref=ensita
This email is sponsored by Ensita.net http://www.ensita.net/
   __  ___ ___   __
  /  |/  /_ __/ __/ __ \/ /Victoria Reznichenko
 / /|_/ / // /\ \/ /_/ / /__   [EMAIL PROTECTED]
/_/  /_/\_, /___/\___\_\___/   MySQL AB / Ensita.net
   ___/   www.mysql.com





-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



Bug: last_insert_id() not replicated correctly

2003-03-18 Thread Chris Wilson

Hi all!

Using mysql 2.23.54a as both master  slave:

** On master:

mysql CREATE DATABASE repl_test;
Query OK, 1 row affected (0.03 sec)

mysql USE repl_test;
Database changed
mysql CREATE TABLE test (
- a INT UNSIGNED AUTO_INCREMENT NOT NULL ,
- b INT UNSIGNED NOT NULL,
- PRIMARY KEY (a)
- );
Query OK, 0 rows affected (0.02 sec)

mysql INSERT INTO test (b) VALUES (1);
Query OK, 1 row affected (0.01 sec)

mysql INSERT INTO test (b) VALUES (LAST_INSERT_ID());
Query OK, 1 row affected (0.00 sec)

mysql INSERT INTO test (b) VALUES (LAST_INSERT_ID());
Query OK, 1 row affected (0.00 sec)

mysql SELECT * FROM test;
+---+---+
| a | b |
+---+---+
| 1 | 1 |
| 2 | 1 |
| 3 | 2 |
+---+---+
3 rows in set (0.00 sec)

** On slave:

mysql USE repl_test;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql SELECT * FROM test;
+---+---+
| a | b |
+---+---+
| 1 | 1 |
| 2 | 2 |
| 3 | 3 |
+---+---+
3 rows in set (0.00 sec)

Looking at the binlog it appears that the problem is on the master and that 
LAST_INSERT_ID gets set to the same value as INSERT_ID rather than the previous value 
(ie this problem only affects inserts that are inserting into tables with auto 
increment columns).

Relevant bit of binlog is:

# at 472606546
#030313  9:38:05 server id  101 Query   thread_id=5122  exec_time=0
error_code=0
use repl_test;
SET TIMESTAMP=1047548285;
CREATE TABLE test (
a INT UNSIGNED AUTO_INCREMENT NOT NULL ,
b INT UNSIGNED NOT NULL,
PRIMARY KEY (a)
);
# at 472606683
#030313  9:38:05 server id  101 Intvar
SET INSERT_ID = 1;
# at 472606705
#030313  9:38:05 server id  101 Query   thread_id=5122  exec_time=0
error_code=0
SET TIMESTAMP=1047548285;
INSERT INTO test (b) VALUES (1);
# at 472606770
#030313  9:38:05 server id  101 Intvar
SET LAST_INSERT_ID = 2;
# at 472606792
#030313  9:38:05 server id  101 Intvar
SET INSERT_ID = 2;
# at 472606814
#030313  9:38:05 server id  101 Query   thread_id=5122  exec_time=0
error_code=0
SET TIMESTAMP=1047548285;
INSERT INTO test (b) VALUES (LAST_INSERT_ID());
# at 472606894
#030313  9:38:06 server id  101 Intvar
SET LAST_INSERT_ID = 3;
# at 472606916
#030313  9:38:06 server id  101 Intvar
SET INSERT_ID = 3;
# at 472606938
#030313  9:38:06 server id  101 Query   thread_id=5122  exec_time=0
error_code=0
SET TIMESTAMP=1047548286;
INSERT INTO test (b) VALUES (LAST_INSERT_ID());

# at 472606546
#030313  9:38:05 server id  101 Query   thread_id=5122  exec_time=0
error_code=0
use repl_test;
SET TIMESTAMP=1047548285;
CREATE TABLE test (
a INT UNSIGNED AUTO_INCREMENT NOT NULL ,
b INT UNSIGNED NOT NULL,
PRIMARY KEY (a)
);
# at 472606683
#030313  9:38:05 server id  101 Intvar
SET INSERT_ID = 1;
# at 472606705
#030313  9:38:05 server id  101 Query   thread_id=5122  exec_time=0
error_code=0
SET TIMESTAMP=1047548285;
INSERT INTO test (b) VALUES (1);
# at 472606770
#030313  9:38:05 server id  101 Intvar
SET LAST_INSERT_ID = 2;
# at 472606792
#030313  9:38:05 server id  101 Intvar
SET INSERT_ID = 2;
# at 472606814
#030313  9:38:05 server id  101 Query   thread_id=5122  exec_time=0
error_code=0
SET TIMESTAMP=1047548285;
INSERT INTO test (b) VALUES (LAST_INSERT_ID());
# at 472606894
#030313  9:38:06 server id  101 Intvar
SET LAST_INSERT_ID = 3;
# at 472606916
#030313  9:38:06 server id  101 Intvar
SET INSERT_ID = 3;
# at 472606938
#030313  9:38:06 server id  101 Query   thread_id=5122  exec_time=0
error_code=0
SET TIMESTAMP=1047548286;
INSERT INTO test (b) VALUES (LAST_INSERT_ID());


Let me know if any more info needed!


Regards,

Chris


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



last_insert_id() not replicated correctly (?)

2002-03-27 Thread Chris Wilson


Hi Guys,

http://www.mysql.com/doc/R/e/Replication_Features.html

... states that last_insert_id() will be replicated correctly. However I
don't think this is always the case, for instance:

INSERT INTO TABLE tab1 (field1) values (Test);
INSERT INTO TABLE tab2 (somefield) values (last_insert_id());

Will replicate properly *ONLY IF* tab1 is being replicated by the slave.
If tab1 is not being replicated then the value inserted into somefield on
tab2 will not match that on the server.

This is with 3.23.47 at least.

Is this a bug or simply that my definition of correctly does not match
yours? :)

Regards,

Chris

-- 
Chris Wilson [EMAIL PROTECTED]
http://www.wapmx.com


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php