Does the PDO lastinsertid
function use MySQL's last_insert_id
function?
I'm particularly interested in replication with AWS
and per the AWS manual using some MySQL functions break replication:
Other common situations that can cause replication errors include the following:...Using unsafe nondeterministic queries
The mysql
manual states that the functions I'm using aren't actually unsafe though:
Nondeterministic functions not considered unsafe
I plan to rewrite my now()
usages but am not sure how I can avoid the last_insert_id
since PDO, not I, am querying that. I can't do a separate select
because it is likely an insert
was run in parallel and I'll get back the wrong id.
mysql_insert_id
, which reads a value already fetched during execution. So no extra call to MySQL is triggered, but I've no idea what the implications for replication are.binlog_format=ROW
or evenMIXED
, then you won't have to worry about non-deterministic queries. Read dev.mysql.com/doc/refman/8.0/en/replication-formats.htmlNOW()
is safe even when you use statement-based replication. See the list of "not unsafe" (sic) functions here: dev.mysql.com/doc/refman/8.0/en/…binlog_format=ROW, mixed
in the AWS instance. That broke the replication there. I have not had this issue when using standard mysql instances, I've usedmixed
in the past.