Go Back   Forum Care Forums > Development Reference Area > MySQL Discussion

Reply
 
LinkBack Thread Tools Display Modes
How to get a current session's host(ip and port of the client) and user name in a select
Old
  (#1)
Guest
Guest
 
Posts: n/a
Default How to get a current session's host(ip and port of the client) and user name in a select - 06-04-2007, 07:58 AM

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

Re: How to get a current session's host(ip and port of the client) and user name in a select
Old
  (#2)
Gordon Burditt
Guest
 
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 - 06-04-2007, 07:58 AM

>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
Re: How to get a current session's host(ip and port of the client) and user name in a select
Old
  (#3)
Guest
Guest
 
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 - 06-04-2007, 07:58 AM

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Contact Us - Forum Care Forums - Archive - Top