[SQL] How can I read display message from a C function

2006-05-04 Thread Fay Du








Hi All:

    I would like to
put some message in my C function ( myTestFunction).
Currently, I want to see time for each function call inside myTestFunction.
The output to the screen commands are in myTestFunction.
myTestFunction is called
from postgresql. How can I see the messages? Thanks
in advance.

 

Fay








[SQL] Connecting to Postgres from other machines (outside localhost)

2006-05-04 Thread Catalin Pitis
Hello
 
I installed PostgreSQL 8.0 on Windows and I can connect from localhost only. How can I configure the server to allow connection from other machines?
 
Thank you
Catalin


Re: [SQL] Connecting to Postgres from other machines (outside localhost)

2006-05-04 Thread Oisin Glynn

Catalin Pitis wrote:

Hello
 
I installed PostgreSQL 8.0 on Windows and I can connect from localhost 
only. How can I configure the server to allow connection from other 
machines?
 
Thank you

Catalin

Under
Start-> Programs->PostgreSQLXX->Configuration files
postgresql.conf
pg_hba.conf

Are the 2 files I modified.  Please be aware my settings are for a dev 
box and are WIDE OPEN AS SHOWN HERE this might allow alot more people 
connect than you want.


postgresql.conf
# - Connection Settings -

listen_addresses = '*'# what IP address(es) to listen on;
   # comma-separated list of addresses;
   # defaults to 'localhost', '*' = all
port = 5432
max_connections = 100

pg_hba.conf
# TYPE  DATABASEUSERCIDR-ADDRESS  METHOD

# IPv4 local connections:
hostall all 127.0.0.1/32  md5
hostall all 192.168.10.1/24  md5
# IPv6 local connections:
#hostall all ::1/128   md5


---(end of broadcast)---
TIP 3: Have you checked our extensive FAQ?

  http://www.postgresql.org/docs/faq


[SQL] audit table containing Select statements submitted

2006-05-04 Thread Hogan, James F. Jr.
No response from the pgsql-admin list so I though I would try cross
posting here:
pgsql-sql@postgresql.org
pgsql-general@postgresql.org



I just know I am not the first to try and do this 

Jim

*
Can anyone point me in a direction that may help me populate in real
time a table that holds?

Current_user
Timestamp
"The Select Statement Submitted by the User"

I would like to easily determine who viewed what and when they viewed
it.

I have considered the fact that the result from SELECT yesterday may be
different than the result set returned by the SAME SELECT statement
today, but when used in conjunction with the INSERT, UPDATE, DELETE
audit logging I have already created, the answers to who viewed, what
and when would be readily available. 


I have been searching all morning and...

The only thing I find on logging of Select statements is that the
information can be held in the Log Files...if Logging is enabled.  

As I am only interested in the statements presented against certain
tables...

Turning on logging gives me more than I need or care to look through. 

I could write a script to parses the Log Files into a Database Table but
would prefer to avoid enabling the file logging of statements if
possible.

Thanks for any reference or help you may be able to provide.

Jim

---(end of broadcast)---
TIP 2: Don't 'kill -9' the postmaster


Re: [SQL] audit table containing Select statements submitted

2006-05-04 Thread Ben K.

Current_user
Timestamp
"The Select Statement Submitted by the User"


http://www.postgresql.org/docs/8.1/static/plpgsql-trigger.html#PLPGSQL-TRIGGER-AUDIT-EXAMPLE

might be close to what you want.


Regards,

Ben K.
Developer
http://benix.tamu.edu

---(end of broadcast)---
TIP 3: Have you checked our extensive FAQ?

  http://www.postgresql.org/docs/faq


[SQL] is an explicit lock necessary?

2006-05-04 Thread Ash Grove
Hi,

Does beginning a transaction put locks on the tables
queried within the transaction?

In the example below, is #2 necessary? My thought was
that I would need to use an explicit lock to make sure
that the sequence value I'm selecting in #4 is the
same one that is generated from #3. I'm worried about
another instance of the application doing an insert on
table1 between #3 and #4.

1) From my app, I turn off autocommit.
2) I lock table1 in access exclusive mode
3) I do an insert into table1 which generates a
primary key via nextval on sequence1
4) I grab grab the primary key value via currval on
sequence1
5) I do an insert on table2 which includes table1's
primary key so I can join the records later.
6) I manually commit

Thanks!
Ash

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---(end of broadcast)---
TIP 9: In versions below 8.0, the planner will ignore your desire to
   choose an index scan if your joining column's datatypes do not
   match


Re: [SQL] is an explicit lock necessary?

2006-05-04 Thread Andrew Sullivan
On Thu, May 04, 2006 at 11:10:56AM -0700, Ash Grove wrote:
> Hi,
> 
> Does beginning a transaction put locks on the tables
> queried within the transaction?

You mean like a table lock?  No.  A transaction does entail some
locks: for instance, an access exclusive lock will block behind your
share lock while you're looking at the table (because the exclusive
lock wants to be exclusive, of course).  See the concurrency control
section of the manual.

> In the example below, is #2 necessary? My thought was

No.  currval() is local to your _session_ (not even your
transaction).  The docs explain how this works.

A

-- 
Andrew Sullivan  | [EMAIL PROTECTED]
A certain description of men are for getting out of debt, yet are
against all taxes for raising money to pay it off.
--Alexander Hamilton

---(end of broadcast)---
TIP 1: if posting/reading through Usenet, please send an appropriate
   subscribe-nomail command to [EMAIL PROTECTED] so that your
   message can get through to the mailing list cleanly


Re: [SQL] is an explicit lock necessary?

2006-05-04 Thread Stephan Szabo

On Thu, 4 May 2006, Ash Grove wrote:

> Hi,
>
> Does beginning a transaction put locks on the tables
> queried within the transaction?
>
> In the example below, is #2 necessary? My thought was
> that I would need to use an explicit lock to make sure
> that the sequence value I'm selecting in #4 is the
> same one that is generated from #3. I'm worried about
> another instance of the application doing an insert on
> table1 between #3 and #4.

If you have 1 session per instance and #3 and #4 are done after each
other without any intervening commands, the behavior of nextval/currval
should guarantee that (currval gives the value from this session's
nextval, not any other).


---(end of broadcast)---
TIP 1: if posting/reading through Usenet, please send an appropriate
   subscribe-nomail command to [EMAIL PROTECTED] so that your
   message can get through to the mailing list cleanly


Re: [SQL] is an explicit lock necessary?

2006-05-04 Thread Ragnar
On fim, 2006-05-04 at 11:10 -0700, Ash Grove wrote:
> Hi,
> 
> Does beginning a transaction put locks on the tables
> queried within the transaction?
> 
> In the example below, is #2 necessary? My thought was
> that I would need to use an explicit lock to make sure
> that the sequence value I'm selecting in #4 is the
> same one that is generated from #3. I'm worried about
> another instance of the application doing an insert on
> table1 between #3 and #4.
> 
> 1) From my app, I turn off autocommit.
> 2) I lock table1 in access exclusive mode
> 3) I do an insert into table1 which generates a
> primary key via nextval on sequence1
> 4) I grab grab the primary key value via currval on
> sequence1
> 5) I do an insert on table2 which includes table1's
> primary key so I can join the records later.
> 6) I manually commit

No. The locking is not necessary.

currval is defined to return the value most recently obtained by nextval
for this sequence in the current session. 

see:
http://www.postgresql.org/docs/8.1/interactive/functions-sequence.html

gnari




---(end of broadcast)---
TIP 5: don't forget to increase your free space map settings


Re: [SQL] Connecting to Postgres from other machines (outside localhost)

2006-05-04 Thread Catalin Pitis
After I've changed the pg_hba.conf, I got the following error when connecting (from log file)
 
2006-05-04 21:57:26 LOG:  invalid entry in file "C:/Program Files/PostgreSQL/8.0/data/pg_hba.conf" at line 68, token "192.168.0.1/192"2006-05-04 21:57:26 FATAL:  missing or erroneous pg_hba.conf file
2006-05-04 21:57:26 HINT:  See server log for details. 
The pg_hba.conf file is attached...
 
Catalin 
On 5/4/06, Catalin Pitis <[EMAIL PROTECTED]> wrote:


I did all you said:
 
I set pg_hba.conf:
 

# IPv4 local connections:host    all all 127.0.0.1/32
  md5
host    all all 192.168.197.1/192  md5 host    all all 
192.168.123.1/192  md5host    all all 
192.168.0.1/192  md5 
 
I set postgres.conf:
 
listen_addresses = '*' # what IP interface(s) to listen on; # defaults to localhost, '*' = anyport = 5433max_connections = 100 
I'm using jdbc with the following URL:
 
jdbc:postgresql://192.168.197.1:5433/postgres8
 
Where postgres8 is the name of the database.
 
I still can't connect...
 
Can you give me a hint?
 
Thanks 

Catalin 

On 5/4/06, Oisin Glynn <[EMAIL PROTECTED]> wrote:
 
Catalin Pitis wrote:> Hello>> I installed PostgreSQL 8.0 on Windows and I can connect from localhost 
> only. How can I configure the server to allow connection from other> machines?>> Thank you> CatalinUnderStart-> Programs->PostgreSQLXX->Configuration filespostgresql.conf
 pg_hba.confAre the 2 files I modified.  Please be aware my settings are for a devbox and are WIDE OPEN AS SHOWN HERE this might allow alot more peopleconnect than you want.postgresql.conf# - Connection Settings - 
listen_addresses = '*'# what IP address(es) to listen on;   # comma-separated list of addresses;   # defaults to 'localhost', '*' = allport = 5432max_connections = 100 
pg_hba.conf# TYPE  DATABASEUSERCIDR-ADDRESS  METHOD# IPv4 local connections:hostall all 
127.0.0.1/32  md5hostall all 192.168.10.1/24  md5# IPv6 local connections:
#hostall all ::1/128   md5


pg_hba.conf
Description: Binary data

---(end of broadcast)---
TIP 5: don't forget to increase your free space map settings


Re: [SQL] Connecting to Postgres from other machines (outside localhost)

2006-05-04 Thread Catalin Pitis
Ok, I found it, it was my mistake.
 
An IP entry should be have /32 or /128. I used different values. Now I got it (RTFM).
 
Regards,
Catalin 
On 5/4/06, Oisin Glynn <[EMAIL PROTECTED]> wrote:
Catalin Pitis wrote:> I did all you said:>> I set pg_hba.conf:>> # IPv4 local connections:
> hostall all 127.0.0.1/32>   md5> hostall all 
192.168.197.1/192>   md5> hostall all 192.168.123.1/192> <
http://192.168.123.1/192>  md5> hostall all 192.168.0.1/192>   md5>>> I set postgres.conf:>> listen_addresses = '*' # what IP interface(s) to listen on;> # defaults to localhost, '*' = any> port = 5433> max_connections = 100
>> I'm using jdbc with the following URL:>> jdbc:postgresql://192.168.197.1:5433/postgres8>> Where postgres8 is the name of the database.>> I still can't connect...
>> Can you give me a hint?>> Thanks> Catalin>>> On 5/4/06, *Oisin Glynn* <[EMAIL PROTECTED]> 
[EMAIL PROTECTED]>> wrote:>> Catalin Pitis wrote:> > Hello> >> > I installed PostgreSQL 8.0 on Windows and I can connect from> localhost
> > only. How can I configure the server to allow connection from other> > machines?> >> > Thank you> > Catalin> Under> Start-> Programs->PostgreSQLXX->Configuration files
> postgresql.conf> pg_hba.conf>> Are the 2 files I modified.  Please be aware my settings are for a dev> box and are WIDE OPEN AS SHOWN HERE this might allow alot more people
> connect than you want.>> postgresql.conf> # - Connection Settings ->> listen_addresses = '*'# what IP address(es) to listen on;># comma-separated list of addresses;
># defaults to 'localhost', '*' = all> port = 5432> max_connections = 100>> pg_hba.conf> # TYPE  DATABASEUSERCIDR-ADDRESS  METHOD
>> # IPv4 local connections:> hostall all 127.0.0.1/32>   md5
> hostall all 192.168.10.1/24>   md5> # IPv6 local connections:
> #hostall all ::1/128   md5>>Did you stop and start Postgres Service?