Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get current session /process id from inside a mysql query

Tags:

mysql

I'm trying to create a table for pseudo array variable. That 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 normalized yet, 'hope this will make it a little simpler to understand :)

To avoid collission between client, there should be a differentiator between client session. For that reason i think need to know current session/process id (just like "SHOW PROCESSLIST") but really need to know IN WHICH process the query are?

like image 497
Indra Ginanjar Avatar asked Dec 03 '22 05:12

Indra Ginanjar


1 Answers

You can use connection_id() function.

like image 148
newtover Avatar answered Jan 18 '23 12:01

newtover