This is a discussion on How to get a current session's host(ip and port of the client) and user name in a select within the MySQL forums, part of the Database Server Software category; --> I would like to know how to get the data from a 'select host, user from INFORMATION_SCHEMA.PROCESSLIST' for only ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| I would like to know how to get the data from a 'select host, user from INFORMATION_SCHEMA.PROCESSLIST' for only the current session. Basically I'm trying to make a 'BEFORE INSERT ON' trigger that will fill in fcUser and fcHost (varchar) fields of a table with the inserter's username and host. I tried using the select above but it returns multiple rows for people with the process privilege. I looked around for a local variable but saw no host or user var. Did i just miss it? I'm using the 5.x line. Thanks, Tim |
| |||
| >I would like to know how to get the data from a 'select host, user >from INFORMATION_SCHEMA.PROCESSLIST' for only the current session. select user(); If you must have two fields, split the result at the '@'. >Basically I'm trying to make a 'BEFORE INSERT ON' trigger that will >fill in fcUser and fcHost (varchar) fields of a table with the >inserter's username and host. I tried using the select above but it >returns multiple rows for people with the process privilege. I looked >around for a local variable but saw no host or user var. Did i just >miss it? > >I'm using the 5.x line. My MySQL doesn't seem to have a PROCESSLIST table. If yours does, you might find connection_id() useful. |
| ||||
| On May 24, 5:45 pm, gordonb.8c...@burditt.org (Gordon Burditt) wrote: > >I would like to know how to get the data from a 'select host, user > >from INFORMATION_SCHEMA.PROCESSLIST' for only the current session. > > select user(); > > If you must have two fields, split the result at the '@'. > > >Basically I'm trying to make a 'BEFORE INSERT ON' trigger that will > >fill in fcUser and fcHost (varchar) fields of a table with the > >inserter's username and host. I tried using the select above but it > >returns multiple rows for people with the process privilege. I looked > >around for a local variable but saw no host or user var. Did i just > >miss it? > > >I'm using the 5.x line. > > My MySQL doesn't seem to have a PROCESSLIST table. If yours does, you > might find connection_id() useful. Thanks! That solves it. I was looking for a variable but turns out to be a built-in function. Searching the mysql manual for connection_id() netted me '12.10.3. Information Functions'. Everything I needed. ty. t |