Get current session / process id from mysql query

I am trying to create a table for a pseudo-array variable. It looks like

CREATE  TABLE IF NOT EXISTS `MyArray`.`ArrayTable` (
  `ID` INT UNSIGNED NOT NULL COMMENT 'Hash value of SessionID + ArrayName' ,
  `SessionID` INT UNSIGNED NOT NULL ,
  `ArrayName` CHAR(26) NOT NULL 
          COMMENT '32 digit char - 6 digit longest process id (assumtion)' ,
  `Index` INT UNSIGNED NOT NULL ,
  `Value` TEXT NOT NULL ,
  PRIMARY KEY (`ID`, `SessionID`) )
ENGINE = MyISAM;

The table is not yet normalized, "I hope this will be a little easier to understand :)

To avoid conflicts between the client, there must be a difference between the client session. For this reason, it seems to me that you need to know the current session / process identifier (same as "SHOW PROCESSLIST"), but really need to know in which process this request is?

+3
source share
1 answer

You can use connection_id () .

+14
source

Source: https://habr.com/ru/post/1740869/


All Articles