[HACKERS] To connect a debbuger...

2007-03-12 Thread Jonathan Scher

Hello!

I'm trying to add some features to PostgreSQL, but I just can't figure 
out how to make gdb work with it.


I attach gdb to /usr/.../bin/postgres, then I put a breakpoint. Whenever 
postgres stop on that breakpoint, it just kills/restarts the server 
instead of asking me what to do.


It's surely a noob's question but how can I use a debugger with PostegreSQL?

Regards,
Jonathan Scher

(gdb) file  /usr/local/pgsql/bin/postgres
Reading symbols from /usr/local/pgsql/bin/postgres...(no debugging 
symbols found)...done.

(gdb) set args -D /home/heziva/pgsql/pgsql_data/
(gdb) b transformFromClause
Breakpoint 1 at 0x80e371e
(gdb) r
Starting program: /usr/local/pgsql/bin/postgres -D 
/home/heziva/pgsql/pgsql_data/
(no debugging symbols found)...(no debugging symbols found)...(no 
debugging symbols found)...(no debugging symbols found)...LOG:  database 
system was interrupted; last known up at 2007-03-12 18:04:04 UTC

LOG:  checkpoint record is at 0/481504
LOG:  redo record is at 0/481504; shutdown TRUE
LOG:  next transaction ID: 0/710; next OID: 16392
LOG:  next MultiXactId: 1; next MultiXactOffset: 0
LOG:  database system was not properly shut down; automatic recovery in 
progress

LOG:  record with zero length at 0/481544
LOG:  redo is not required
LOG:  database system is ready to accept connections
LOG:  autovacuum launcher started

= on another shell psql\d

(gdb) file  /usr/local/pgsql/bin/postgres
Reading symbols from /usr/local/pgsql/bin/postgres...(no debugging 
symbols found)...done.

(gdb) set args -D /home/heziva/pgsql/pgsql_data/
(gdb) b transformFromClause
Breakpoint 1 at 0x80e371e
(gdb) r
Starting program: /usr/local/pgsql/bin/postgres -D 
/home/heziva/pgsql/pgsql_data/
(no debugging symbols found)...(no debugging symbols found)...(no 
debugging symbols found)...(no debugging symbols found)...LOG:  database 
system was interrupted; last known up at 2007-03-12 18:04:04 UTC

LOG:  checkpoint record is at 0/481504
LOG:  redo record is at 0/481504; shutdown TRUE
LOG:  next transaction ID: 0/710; next OID: 16392
LOG:  next MultiXactId: 1; next MultiXactOffset: 0
LOG:  database system was not properly shut down; automatic recovery in 
progress

LOG:  record with zero length at 0/481544
LOG:  redo is not required
LOG:  database system is ready to accept connections
LOG:  autovacuum launcher started





---(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: [HACKERS] CLUSTER, using SHARE UPDATE EXCLUSIVE lock?

2007-03-02 Thread Jonathan Scher



That's lock upgrading, which opens you up to deadlocks. If another
process grabs a lock after your update exclusive, you're not going to
be able to upgrade it.

  


OK I got the point.
Is it possible to create a new table-level lock mode that says OK, now 
I'm on share level, but soon I will upgrade it to exclusive. Then it 
would be possible to allow any read-only operation, and to forbid all 
operation that would need to upgrade.
I know that there is a sx_try_upgrade function on freeBSD kernel (man 
sx), so I guess there is a way to do it, isn't it?


Regards,
Jonathan Scher

---(end of broadcast)---
TIP 7: You can help support the PostgreSQL project by donating at

   http://www.postgresql.org/about/donate


[HACKERS] UPSERT

2007-03-02 Thread Jonathan Scher

Hello,

I'd like to work on TODO item:
 Add REPLACE or UPSERT command that does UPDATE, or on failure, INSERT

could you please tell me if I'm going in the right way?

There are some different syntaxes possible, but MySQL has an interesting 
one here:

http://dev.mysql.com/doc/refman/5.0/en/insert-on-duplicate.html

INSERT INTO table (a,b,c) VALUES (1,2,3) ON DUPLICATE KEY UPDATE c=c+1;
This allow to make an insert, and if the key is already there to modify 
the value depending on the current one.


Then I have two choices possible:
- Search for existing tuples among key or unique constraint, then if 
nothing is found, insert it.
- Try to insert a new row, catch if there is any error, and then search 
for all tuple matching.


As it would be a new command, I have no idea on what the data could be.
Does syntax meet your needs? Which choice should I implement?

Regards
Jonathan Scher

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


[HACKERS] CLUSTER, using SHARE UPDATE EXCLUSIVE lock?

2007-03-01 Thread Jonathan Scher

Hello,

CLUSTER uses an ACCESS EXCLUSIVE lock. Why does it forbid concurrent reads?
Florian G. Pflug, on a post ( 
http://archives.postgresql.org/pgsql-hackers/2007-02/msg00081.php ) 
suggested that there were no way to let the old entry until the command 
commit.
I would like Cluster to create a new table, copying old values to this 
one, then delete the old one. This would allow Cluster to work with a 
share update exlusive lock, in order to allow reading the table while 
cluster is working.


How does Cluster actually works? Why making a Cluster command less 
restrictive isn't even in the TO-list?


Best regards,
Jonathan Scher

---(end of broadcast)---
TIP 4: Have you searched our list archives?

  http://archives.postgresql.org


Re: [HACKERS] CLUSTER, using SHARE UPDATE EXCLUSIVE lock?

2007-03-01 Thread Jonathan Scher

Tom Lane a écrit :

Jonathan Scher [EMAIL PROTECTED] writes:
  

CLUSTER uses an ACCESS EXCLUSIVE lock. Why does it forbid concurrent reads?



Because when it drops the old copy of the table there had better not be
any concurrent readers.

regards, tom lane


  
Then, is it possible to take a share update exclusive lock until the new 
table is ready, then an access exclusive one only in order to switch 
tables? I don't think it's already coded like that...


Regards
Jonathan Scher

---(end of broadcast)---
TIP 4: Have you searched our list archives?

  http://archives.postgresql.org