Bluehost.com Web Hosting $6.95

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 Database forums, part of the Database Forums category; I would like to know how to get the data from a 'select host, user from INFORMATION_SCHEMA.PROCESSLIST' for only ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-24-2007
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

Reply With Quote
  #2 (permalink)  
Old 05-24-2007
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.


Reply With Quote
  #3 (permalink)  
Old 05-25-2007
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

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 07:01 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0