Unix Technical Forum

How to get a current session's host(ip and port of the client) and user name in a select

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 ...


Go Back   Unix Technical Forum > Database Server Software > MySQL

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 10:54 AM
gz.admin@gmail.com
 
Posts: n/a
Default How to get a current session's host(ip and port of the client) and user name in a select

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 10:54 AM
Gordon Burditt
 
Posts: n/a
Default Re: How to get a current session's host(ip and port of the client) and user name in a select

>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.


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-28-2008, 10:54 AM
gz.admin@gmail.com
 
Posts: n/a
Default Re: How to get a current session's host(ip and port of the client) and user name in a select

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 07:07 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com