[SQL] pg_stat_activity return all connections

2009-04-28 Thread Emi Lu

Good morning,

A question about pg_stat_activity:

If believe that "select * from pg_stat_activity where 
usename='db_user1'" returns all connections based on db_user1, no matter 
the connection is through terminal command or jdbc, am I right?



Thank you,
--
Lu Ying



--
Sent via pgsql-sql mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


Re: [SQL] Storing null bytes in bytea

2009-04-28 Thread Andy Shellam

Hi Tom,

Your example works fine in psql:

regression=# create table t1 (f1 bytea);
CREATE TABLE
regression=# insert into t1 values 
(E'IsLoggedIn|b:1;CurrentUser|O:17:"Class_SystemUser":4:{s:26:"\\000Class_SystemUser}'::bytea);
INSERT 0 1
regression=# select * from t1;
f1  
---

 
IsLoggedIn|b:1;CurrentUser|O:17:"Class_SystemUser":4:{s:26:"\000Class_SystemUser}
(1 row)


I suspect what is happening is that some layer on the client side is
doubling (or perhaps undoubling?) the backslashes for you.  Exactly
what are you doing with that literal as you build the query?  It might
help to turn on log_statements so that you can see just what the
server is getting.
  


Many thanks for your reply.  I was a bit naive about the quality of the 
client I was using (Navicat 8.1.)  It turns out in the "Memo" view it 
doesn't show anything past the first zero byte.  However switch it to 
hex view and you see the full bytes.


I think my issue that it wasn't working on the client side (and caused 
me to examine it in more detail in the database) was because it wasn't 
unescaping correctly in the application code when it read the data back 
out of the database.


Next time I won't be so lazy and try it out in psql first...

Regards,
Andy

--
Sent via pgsql-sql mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


Re: [SQL] pg_stat_activity return all connections

2009-04-28 Thread Erik Jones


On Apr 28, 2009, at 8:43 AM, Emi Lu wrote:


Good morning,

A question about pg_stat_activity:

If believe that "select * from pg_stat_activity where  
usename='db_user1'" returns all connections based on db_user1, no  
matter the connection is through terminal command or jdbc, am I right?


Yes.

Erik Jones, Database Administrator
Engine Yard
Support, Scalability, Reliability
866.518.9273 x 260
Location: US/Pacific
IRC: mage2k






--
Sent via pgsql-sql mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql