The order of output expressions evaluation is not documented or specified. In general the evaluating order matches the text.
Look. You assign @prev := u.plz and then try to compare these values - but they are already equal due to assigning.
@prev as previous, -- @prev stores "old" value
@prev := u.plz as ...
When you run the first two selects MySQL creates two X locks on supremum pseudo-record in tg_user_id because both ids (341292662 and 239302521) outside of the existing range. It looks like a bug. When you run inserts both of them try to get insert intention lock on the same record but they are blocked by previous locks.
Confirmed as bug: https://bugs....
It appears you're having issues with apparmor, still loading the MySQL apparmor profile.
According to this page, MariaDB's recommendation is to disable the mysqld profile like so:
$ sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/
$ sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld
$ sudo aa-status
It seems that MariaDB ...
SIMPLY use user defined variales instead of variables.
CREATE PROCEDURE `new_procedure` (IN tableA varchar(255))
SET @sql = CONCAT(' select count(id) , orgid , (select id from org_subscription t where t.orgid=mainOrgID) into @count,@ParamOrgId ,@isPremium from ', tableA );
PREPARE stmt from @sql;
EXECUTE stmt ;
SELECT concat('my val is ', @...
Is there any way to collect somehow or write in another way query's which is repeated couple of times.
I believe the term you're looking for is a "Data Abstraction Layer".
This might take the form of some functions, or some classes with some methods on them, YMMV, but you basically build something that runs particular queries when they're called ...
Write 5 PHP subroutines, one for each query.
Write 1 PHP subroutine and pass in (in the first case) "belongs_to", $belongs_to, then construct the query and run it.
Write 5 SQL Stored Procedures.
Write 1 SP. (But this gets rather messy.)
Or... Don't worry about it.
Let's itemize the purposes/goals of a PRIMARY KEY:
Uniquely identify each row of a table. This is a requirement for InnoDB.
It provides the disk layout order for the data. This sometimes plays into performance issues. (Regular UUIDs are bad for performance because the "next" UUID is nowhere near the "last" UUID. That is the ...
Bignint is much faster than cvarchar or varbinary. at anbay time..
And so you can have 18446744073709551615 (unsigned) Rows.
You would use uuids, when you enter data in different databases and try to unite them.
but if you only need unique ids, use bigint.
If you have access to the Aria engine or another non-transactional engine, then yes.
Very short proof of concept, tested on MariaDB 10.5.4:
CREATE TABLE test_aria_engine ( a int, b varchar(1000) )
ENGINE=Aria DEFAULT CHARSET=utf8 PAGE_CHECKSUM=1 TRANSACTIONAL=1 TABLE_CHECKSUM=1
COMMENT='test-aria_engine with transactional on 1'
The transactional in Aria is ...