Re: [GENERAL] libpq ASYNC with PQgetResult and PQisBusy

2010-12-21 Thread Raimon Fernandez
hi again, On 20dic, 2010, at 18:48 , Tom Lane wrote: >> So, now I'm using the PQisBusy to check if postgre is still busy and I can >> safely call the PQgetResult wihtout blocking, or just wait *some time* >> before sending a new PQisBusy. > > Your proposed code is still a busy-wait loop. What

Re: [GENERAL] libpq ASYNC with PQgetResult and PQisBusy

2010-12-20 Thread Raimon Fernandez
On 21dic, 2010, at 00:56 , Alban Hertroys wrote: > On 20 Dec 2010, at 21:49, Raimon Fernandez wrote: > >> The select(2) that says that are using for wait is this line ? if >> (select(sock + 1, &input_mask, NULL, NULL, NULL) < 0) { >> >> I can't see wh

Re: [GENERAL] libpq ASYNC with PQgetResult and PQisBusy

2010-12-20 Thread Raimon Fernandez
On 20dic, 2010, at 18:48 , Tom Lane wrote: >> So, now I'm using the PQisBusy to check if postgre is still busy and I can >> safely call the PQgetResult wihtout blocking, or just wait *some time* >> before sending a new PQisBusy. > > Your proposed code is still a busy-wait loop. This is how ar

[GENERAL] libpq ASYNC with PQgetResult and PQisBusy

2010-12-20 Thread Raimon Fernandez
Hello, I'm trying to create a plugin using the libpq. Almost everything is working, and now I want to implememt the asynchronous issue. I send the SQL using the PQsendQuery, and my interface is not blocking, great. Now, everytime I check fot the PQgetResult my interface gets blocked. So, now

Re: [GENERAL] pg_restore 8.x to postgreSQL 9.x functions and triggers aren't created [solved]

2010-12-20 Thread Raimon Fernandez
ok, solved. it was a problem with the application that interfaces with pg that has a bug ... sorry, regards, r. On 20dic, 2010, at 09:28 , Raimon Fernandez wrote: > Hello, > > We have two postgreSQL servers that are in the latest 9.x as testing, but > when we use pg_dump an

[GENERAL] pg_restore 8.x to postgreSQL 9.x functions and triggers aren't created

2010-12-20 Thread Raimon Fernandez
Hello, We have two postgreSQL servers that are in the latest 9.x as testing, but when we use pg_dump and pg_restore, our functions and triggers are never copied to postgreSQL Server 9.x. This is how we restore: data=`date +%Y_%m_%d` pg_restore -c -i -h 192.168.0.9 -p 5432 -U postgres -d global

Re: [GENERAL] Getting number of affected rows after DELETE FROM

2010-12-19 Thread Raimon Fernandez
On 19dic, 2010, at 10:33 , Jasen Betts wrote: > On 2010-12-17, Raimon Fernandez wrote: >> Hi, >> >> I'm trying to solve what I think must be a real trivial question. >> >> When I use psql after every DELETE FROM table WHERE id= I get how many >&g

[GENERAL] Getting number of affected rows after DELETE FROM

2010-12-17 Thread Raimon Fernandez
Hi, I'm trying to solve what I think must be a real trivial question. When I use psql after every DELETE FROM table WHERE id= I get how many rows were affected, in this case, deleted. Also I've implemented the full FrontEnd/BackEnd Protocol v3 and there after a CommandComplete also I recei

Re: [GENERAL] use a variable name for an insert in a trigger for an audit

2010-12-09 Thread Raimon Fernandez
On 9dic, 2010, at 04:40 , Raimon Fernandez wrote: > Hello, > > I have to audit all the changes for all rows of one database. > > I have a trigger that executes BEFORE any update or delete, and simply copy > the row (INSERT INTO) into the replicated table. > > For exam

Re: [GENERAL] SELECT is immediate but the UPDATE takes forever

2010-12-09 Thread Raimon Fernandez
On 9dic, 2010, at 14:32 , Vick Khera wrote: >> well, after a VACUUM things are going faster ... I'm still trying to analyze >> the function as it seems there are other bottlechecnk, but at least the >> first update now is faster as before ... >> > > If that's the case then your 'no' answer to

[GENERAL] use a variable name for an insert in a trigger for an audit

2010-12-08 Thread Raimon Fernandez
Hello, I have to audit all the changes for all rows of one database. I have a trigger that executes BEFORE any update or delete, and simply copy the row (INSERT INTO) into the replicated table. For example, every table has the same name plus '_audit' at the end and belongs to the schema audit:

Re: [GENERAL] SELECT is immediate but the UPDATE takes forever

2010-12-08 Thread Raimon Fernandez
On 7dic, 2010, at 16:37 , Tom Lane wrote: >> Quoting Raimon Fernandez : >>> I want to understand why one of my postgresql functions takes an >>> eternity to finish. > >> Maybe there is any check or constraint on belongs_to_compte_id.comptes that >> might t

Re: [GENERAL] SELECT is immediate but the UPDATE takes forever

2010-12-08 Thread Raimon Fernandez
On 8dic, 2010, at 18:18 , Vick Khera wrote: > 2010/12/7 Raimon Fernandez : >> I'm using now another database with same structure and data and the delay >> doesn't exist there, there must be something wrong in my current development >> database. >> > &g

Re: [GENERAL] SELECT is immediate but the UPDATE takes forever

2010-12-07 Thread Raimon Fernandez
On 7dic, 2010, at 15:45 , Michał Roszka wrote: > Quoting Raimon Fernandez : > >> I want to understand why one of my postgresql functions takes an >> eternity to finish. >> >> Here's an example: >> >> UPDATE comptes SET belongs_to_compte_i

[GENERAL] SELECT is immediate but the UPDATE takes forever

2010-12-07 Thread Raimon Fernandez
Hi, I want to understand why one of my postgresql functions takes an eternity to finish. Here's an example: UPDATE comptes SET belongs_to_compte_id=42009 WHERE (codi_compte LIKE '1%' AND empresa_id=2 AND nivell=11); // takes forever to finish QUERY PLAN

Re: [GENERAL] Extended Query, flush or sync ?

2009-12-23 Thread Raimon Fernandez
On 22/12/2009, at 18:15, Tom Lane wrote: > Raimon Fernandez writes: >> But the portal isn't destroyed after a sync ? > > Not directly by a Sync, no. > >> I'm getting a "Portal 'myPortal' doesn't exist "when sending the next &

Re: [GENERAL] Extended Query, flush or sync ?

2009-12-22 Thread Raimon Fernandez
On 22/12/2009, at 18:15, Tom Lane wrote: > Raimon Fernandez writes: >> But the portal isn't destroyed after a sync ? > > Not directly by a Sync, no. ok, >> I'm getting a "Portal 'myPortal' doesn't exist "when sending the next >

[GENERAL] Extended Query vs Simple Query

2009-12-22 Thread Raimon Fernandez
Hello again, Now that I have working the Extended Query using the Front End Protocol 3.0, I'm getting better results with simple queries than extended queries. table comptes: Simple query: select * from comptes WHERE codi_empresa = '05' AND nivell=11 and clau_compte like '05430%' => 0,027

Re: [GENERAL] Extended Query, flush or sync ?

2009-12-22 Thread Raimon Fernandez
On 19/12/2009, at 16:32, John DeSoi wrote: >> If I execute with a row limit of 1000, and I know there are more than 1000 >> rows, I get the portalSuspended as described. >> >> But, If a issue a new Execute, postgresql says that myPortal doesn't exist >> anymore. >> >> How I can get those 1000

Re: [GENERAL] Extended Query, flush or sync ?

2009-12-21 Thread Raimon Fernandez
Hi John, I'm not seeing my e-mails on the PostgreSQL General List ... ?? On 19/12/2009, at 16:32, John DeSoi wrote: > > On Dec 19, 2009, at 2:40 AM, Raimon Fernandez wrote: > >>> I send: >>> >>> parse >>> bind >>> describe &g

Re: [GENERAL] Extended Query, flush or sync ?

2009-12-21 Thread Raimon Fernandez
On 18/12/2009, at 22:55, Tom Lane wrote: > Raimon Fernandez writes: >> It's not clear for me if I have to issue a flush or sync after each process >> of an extended query. > > Basically, you send one of these at the points where you're going to > wait for

Re: [GENERAL] Extended Query, flush or sync ?

2009-12-21 Thread Raimon Fernandez
Hello, On 19/12/2009, at 4:31, John DeSoi wrote: > > On Dec 18, 2009, at 4:44 PM, Raimon Fernandez wrote: > >> It's not clear for me if I have to issue a flush or sync after each process >> of an extended query. >> >> It's almost working for me onl

[GENERAL] Extended Query, flush or sync ?

2009-12-18 Thread Raimon Fernandez
Hello, It's not clear for me if I have to issue a flush or sync after each process of an extended query. It's almost working for me only when I send a sync, but not when I send a flush. With the flush, the connection seems freezed, or at least, I don't get any data from postgre. - Send the p

Re: [GENERAL] Extended Query using the Frontend/Backend Protocol 3.0

2009-12-18 Thread Raimon Fernandez
On 18/12/2009, at 2:26, John DeSoi wrote: > > On Dec 17, 2009, at 11:13 AM, Raimon Fernandez wrote: > >> I'm trying to integrate the extended query protocol with my libraries. >> >> I'm sending a simple SELECT to validate the method, but I'm getting

[GENERAL] Extended Query using the Frontend/Backend Protocol 3.0

2009-12-17 Thread Raimon Fernandez
Hello again, I'm trying to integrate the extended query protocol with my libraries. I'm sending a simple SELECT to validate the method, but I'm getting an Invalid Message Format. 50 => P 00 00 00 29 => length 6D7973746174656D656E74 00 => mystatement + null 73656C656374202A2066726F6D206D797461

Re: [GENERAL] Encoding using the Frontend/Backend Protocol TCP/IP

2009-11-19 Thread Raimon Fernandez
On 19/11/2009, at 21:21, Kovalevski Andrei wrote: > Hi, > > the string is ok, but the problem is inside the message. The length of the > message is incorrect: > > your message: > 510046557064617465207472616E73616374696F6E7320736574206465736372697074696F6E3D27546573742056616C75657364C387272

Re: [GENERAL] Encoding using the Frontend/Backend Protocol TCP/IP

2009-11-19 Thread Raimon Fernandez
On 19/11/2009, at 18:13, Raimon Fernandez wrote: > > On 19/11/2009, at 17:27, Kovalevski Andrei wrote: > >> Hi >> >> could it be that you have errors in your UTF8 string? For example you might >> use UTF16 encoding, it can explain why some characters fo

Re: [GENERAL] Encoding using the Frontend/Backend Protocol TCP/IP

2009-11-19 Thread Raimon Fernandez
ription='Test ValuesdÇ' where id=113 510046557064617465207472616E73616374696F6E7320736574206465736372697074696F6E3D27546573742056616C75657364C387272077686572652069643D313133 It has also the header Q and the length ... thanks, regards, r. > Raimon Fernandez wrote: >> Hello, >> >> >> I'm trying to send some stri

[GENERAL] Encoding using the Frontend/Backend Protocol TCP/IP

2009-11-19 Thread Raimon Fernandez
Hello, I'm trying to send some strings that have chars outside from standar ascii, like çñàèó Once I'm connected, the client and server both uses UT8Encoding. And I'm sending all the strings encoded in UTF8. At least the received ones are working, as I get the text exactly as it is, with spe

Re: [GENERAL] Where I can find "SSL specification"?

2009-11-10 Thread Raimon Fernandez
Hello, More on this ... To be clear, just after receiving the S confirmation that PostgreSQL can handle SSL connections, I have to switch my TCPSocket into SSL. Immediatly, I receive some errors, depending my configuration: 0 - SSLv2: SSL (Secure Sockets Layer) version 2. ERROR =>

Re: [GENERAL] MD5 Authentication

2009-11-06 Thread Raimon Fernandez
On 06/11/2009, at 8:48, Raimon Fernandez wrote: I'm blocked ... On 06/11/2009, at 6:27, John DeSoi wrote: On Nov 5, 2009, at 12:35 PM, Raimon Fernandez wrote: at least, my first md5 (psw+user) is the same as the pg_shadow (wihtout the 'md5') ... should I md5 the

Re: [GENERAL] MD5 Authentication

2009-11-05 Thread Raimon Fernandez
I'm blocked ... On 06/11/2009, at 6:27, John DeSoi wrote: On Nov 5, 2009, at 12:35 PM, Raimon Fernandez wrote: at least, my first md5 (psw+user) is the same as the pg_shadow (wihtout the 'md5') ... should I md5 the first md5 as I get it as string (like username) or

[GENERAL] Where I can find "SSL specification"?

2009-11-04 Thread Raimon Fernandez
Hello, I want to implement SSL in my Frontend implementation with TCP/IP. The manual just says, after receiving an S: "To continue after S, perform an SSL startup handshake (not described here, part of the SSL specification) with the server." I can't find it in the manual or in the postgres

Re: [GENERAL] Cancelling Requests Frontend/Backend Protocol TCP/IP

2009-11-02 Thread Raimon Fernandez
On 02/11/2009, at 20:01, John DeSoi wrote: On Nov 2, 2009, at 12:17 PM, Raimon Fernandez wrote: when postgres has finished processing the select, just before sending the first row(1), in the middle(2), or at the end(3), when the last row has been sent ? If I send the CancelRequest when

Re: [GENERAL] Cancelling Requests Frontend/Backend Protocol TCP/IP

2009-11-02 Thread Raimon Fernandez
On 02/11/2009, at 17:53, Tom Lane wrote: Raimon Fernandez writes: The sentence 'backend has finished processing the query' means that postgresql has finished processing the select and also has sent all the rows ? There is no distinction; rows are sent as they are generated. Y

Re: [GENERAL] Cancelling Requests Frontend/Backend Protocol TCP/IP

2009-11-02 Thread Raimon Fernandez
On 02/11/2009, at 17:35, Tom Lane wrote: Raimon Fernandez writes: Quoted from the documentation: "The cancellation signal might or might not have any effect — for example, if it arrives after the backend has finished processing the query, then it will have no effect. Here I understand

Re: [GENERAL] Cancelling Requests Frontend/Backend Protocol TCP/IP

2009-11-02 Thread Raimon Fernandez
On 02/11/2009, at 15:12, John DeSoi wrote: On Nov 2, 2009, at 4:15 AM, Raimon Fernandez wrote: If for example I send a SELECT * from myTable, it has 2 rows, and postgre starts sending the rows, how I can cancel this operation ? I thought Cancelling Requests would be perfect for

Re: [GENERAL] Cancelling Requests Frontend/Backend Protocol TCP/IP

2009-11-02 Thread Raimon Fernandez
On 02/11/2009, at 15:38, Tom Lane wrote: Craig Ringer writes: On 2/11/2009 5:15 PM, Raimon Fernandez wrote: If for example I send a SELECT * from myTable, it has 2 rows, and postgre starts sending the rows, how I can cancel this operation ? Assuming you're asking "is the

Re: [GENERAL] DataRow Null values Frontend/Backend Protocol TCP/IP

2009-11-02 Thread Raimon Fernandez
On 02/11/2009, at 10:37, Craig Ringer wrote: On 2/11/2009 5:21 PM, Raimon Fernandez wrote: Here I'm again ... I'm parsing the DataRow(B), and I'm having problems with NULL values. In the docs I can read they have a -1 value, an no bytes follow them for the value. But I&#

Re: [GENERAL] Cancelling Requests Frontend/Backend Protocol TCP/IP

2009-11-02 Thread Raimon Fernandez
On 02/11/2009, at 10:29, Craig Ringer wrote: On 2/11/2009 5:15 PM, Raimon Fernandez wrote: For what I've read in the manuals, this operation is only valid before PostgreSQL has finished processing the SELECT statement ? If for example I send a SELECT * from myTable, it has 2

Re: [GENERAL] DataRow Null values Frontend/Backend Protocol TCP/IP

2009-11-02 Thread Raimon Fernandez
Here I'm again ... I'm parsing the DataRow(B), and I'm having problems with NULL values. In the docs I can read they have a -1 value, an no bytes follow them for the value. But I'm getting a 1020 value instead of -1 Int32 The length of the column value, in bytes (this count does not inc

Re: [GENERAL] Cancelling Requests Frontend/Backend Protocol TCP/IP

2009-11-02 Thread Raimon Fernandez
Hello, For what I've read in the manuals, this operation is only valid before PostgreSQL has finished processing the SELECT statement ? If for example I send a SELECT * from myTable, it has 2 rows, and postgre starts sending the rows, how I can cancel this operation ? I thought Canc

Re: [GENERAL] Implementing Frontend/Backend Protocol TCP/IP

2009-10-27 Thread Raimon Fernandez
On 27/10/2009, at 15:06, Alvaro Herrera wrote: Raimon Fernandez wrote: how I know where the length ends ? You count 4 bytes. thanks, I'm parsing now the resulted string as a binarystring and all is getting sense ... thanks for your help, raimon -- Alvaro He

Re: [GENERAL] Implementing Frontend/Backend Protocol TCP/IP

2009-10-27 Thread Raimon Fernandez
On 27/10/2009, at 14:41, Alvaro Herrera wrote: Raimon Fernandez wrote: After the S I found thre char(0) and later the size of the packet, and later the name + char(0) (separator between value and parameter), the parameter, and so on. Why I found those three char(0) after the S and before

Re: [GENERAL] Implementing Frontend/Backend Protocol TCP/IP

2009-10-27 Thread Raimon Fernandez
Hello, As this thread it's alive, I'm going to ask more specific questions: After sending the satartup sequence, I receive the paramlist. I don't need to send Authentication as I'm using a Trust user, for making things easier. I receive string data, I suppose it's text data. I can parse

Re: [GENERAL] Implementing Frontend/Backend Protocol TCP/IP

2009-10-27 Thread Raimon Fernandez
On 27/10/2009, at 14:00, Alvaro Herrera wrote: Raimon Fernandez wrote: REALbasic has plugin for PostgreSQL, but they are synchronous and freeze the GUI when interacting with PG. This is not a problem noramlly, as the SELECTS/UPDATES/... are fast enopugh, but sometimes we need to fetch 1000

Re: [GENERAL] Implementing Frontend/Backend Protocol TCP/IP

2009-10-27 Thread Raimon Fernandez
On 27/10/2009, at 8:29, John R Pierce wrote: Raimon Fernandez wrote: REALbasic has plugin for PostgreSQL, but they are synchronous and freeze the GUI when interacting with PG. This is not a problem noramlly, as the SELECTS/UPDATES/... are fast enopugh, but sometimes we need to fetch

Re: [GENERAL] Implementing Frontend/Backend Protocol TCP/IP

2009-10-27 Thread Raimon Fernandez
On 27/10/2009, at 0:17, John R Pierce wrote: Alvaro Herrera wrote: I'm trying to implement the front-end protocol with TCP from REALbasic to PostgreSQL. That sounds the most difficult way to do it. Can't you just embed libpq? yah, seriously. the binary protocol is not considered stabl

[GENERAL] Implementing Frontend/Backend Protocol TCP/IP

2009-10-26 Thread Raimon Fernandez
Hello, I'm trying to implement the front-end protocol with TCP from REALbasic to PostgreSQL. The docs from PostgreSQL, well, I understand almost, but there are some points that maybe need more clarification. Anyone have some experience to start making questions ? :-) The front-end t