Postgre SQL Events Alerter

Code patches written by our users to solve certain "problems" that were not solved, yet.

Moderators: gto, cipto_kh, EgonHugeist, mdaems

mrLion
Senior Boarder
Senior Boarder
Posts: 71
Joined: 20.03.2010, 10:17

Postgre SQL Events Alerter

Postby mrLion » 26.03.2010, 21:58

The archive is the component itself and changed files version ZEOS 6.6.6. The project collected and tested for CodeGear 2007
Any comments - welcome
You do not have the required permissions to view the files attached to this post.

silvioprog
Junior Boarder
Junior Boarder
Posts: 42
Joined: 10.01.2009, 00:34
Location: Brasil
Contact:

Postby silvioprog » 16.05.2010, 10:41

Please, this component will not have a version for Lazarus?
I need a lot of one component to notify events of Pg (but to Lazarus).

silvioprog
Junior Boarder
Junior Boarder
Posts: 42
Joined: 10.01.2009, 00:34
Location: Brasil
Contact:

Postby silvioprog » 16.05.2010, 12:12

I managed to work in Lazarus (in attached). I'm interested to see this component working with Zeos7.

(Please, no see my english :oops: )
You do not have the required permissions to view the files attached to this post.

mrLion
Senior Boarder
Senior Boarder
Posts: 71
Joined: 20.03.2010, 10:17

Postby mrLion » 16.05.2010, 15:44

silvioprog, i`m so sorry, but i`m don`t planned use lazarus! And i`m NOT USE PASCAL in any his variants! I`m use C++ ONLY. So, if you want rewrite this code - DO IT yourself. Only base copyright insert in code. Thats is all.
In short time will appear PostgreSQL 9. In this release Post Event tech will be extended. :)

silvioprog
Junior Boarder
Junior Boarder
Posts: 42
Joined: 10.01.2009, 00:34
Location: Brasil
Contact:

Postby silvioprog » 16.05.2010, 17:47

Ok, thanks for the contribution! :)

User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Postby mdaems » 16.05.2010, 22:29

mrLion,
And i`m NOT USE PASCAL in any his variants!

What language did you write your contribution in, then? To me this looks likes the most pure object pascal you can get :D

Anyway, looks to me Silvio only changed some upper/lowercase thingies and uses clause to get your fine contribution compiled in FPC as well. So you'll perfectly be comfortable with 'his' version.

Just a little question about the code. Is the comment
//-- ðåçóëüòàò âûïîëíåíèÿ êîìàíä ñåðâåðà
useful in any way? If not I'd prefer to remove it.

Finally, I'd prefered not to add this component officially to version 6.6 as I have no clue on how it reacts for the older compilers supported by that zeoslib version. For version 7.x, I don't see why I wouldn't add it. Let's just try how it compiles now. I'll use Silvio's modified version as I both compile on Delphi and fpc.

Mark

EDIT : Done. SVN rev 807.
Image

silvioprog
Junior Boarder
Junior Boarder
Posts: 42
Joined: 10.01.2009, 00:34
Location: Brasil
Contact:

Postby silvioprog » 17.05.2010, 20:47

Friends, I tested ZPgEventAlerter in FPC-2.4.0-2 / Laz-0.9.29 (current SVN version) / (Win32[WindowsXP] / Linux[Ubuntu-10:04] / Zeos-6.6.6-stable/Pg-8.4.3 ), it worked perfectly well.

Now I'll try to compile with Zeos7 (current SVN version), when I have some something new, I return again. :wink:

Thanks again, this component will be very helpful to me. (I'm creating a Twitter to run on a local network)

silvioprog
Junior Boarder
Junior Boarder
Posts: 42
Joined: 10.01.2009, 00:34
Location: Brasil
Contact:

Postby silvioprog » 18.05.2010, 06:30

Hm, there is a small problem, ZPgEventAlerter not listing the events issued by another application (e.g, a event emited from pgAdmin III). :(

I compared with PostgreDAC (for Delphi):

http://www.microolap.com/downloads/postgresdac/postgresdac_trial_license.zip

I will try to resolve this problem, and I'll stay very grateful if someone can help me. :)

P.S.: In attached I sending the new files of resources of the component. And the Delphi demo with PostgregDAC.
You do not have the required permissions to view the files attached to this post.

silvioprog
Junior Boarder
Junior Boarder
Posts: 42
Joined: 10.01.2009, 00:34
Location: Brasil
Contact:

Postby silvioprog » 18.05.2010, 06:48

I bring more information. I tested from pgAdmin on Linux (Ubuntu), and PostgreDAC on Windows (XP), when I executed in pgAdmin, imediately is listed in memo of my Delphi test. Please, see in this picture:

http://imagebin.org/97299

To ZPgEventAlerter work identical to PosgreDAC, I have to be running a local ZQuery (ExecSQL), only then it lists events from other applications. :(

silvioprog
Junior Boarder
Junior Boarder
Posts: 42
Joined: 10.01.2009, 00:34
Location: Brasil
Contact:

Postby silvioprog » 18.05.2010, 14:28

I think it would be necessary to use PQnoticeReceiver:

http://www.network-theory.co.uk/docs/postgresql/vol2/NoticeProcessing.html

(
http://svn.freepascal.org/svn/fpc/trunk/packages/postgres/src/postgres3dyn.pp
http://svn.freepascal.org/svn/fpc/trunk/packages/postgres/src/
)

I'm not have sure if this is it, I tried to do in various ways, but without success.

My last test in attached(the example in attachment is not secure, it was just a test to show). And this picture:

http://imagebin.org/97320

Thanks for all for the patience :)
You do not have the required permissions to view the files attached to this post.

mrLion
Senior Boarder
Senior Boarder
Posts: 71
Joined: 20.03.2010, 10:17

Postby mrLion » 20.05.2010, 20:09

mdaems, no problem! Do it, as you wish... Comment, what you show - on Russian, so you don`t have Cyrillic codepage.

silvioprog, this Pascal code is adapted code from PostgresDAC. My code, what i use writing on C++.

in later im can`t support this component and don`t have any wishes refactoring this. i`m sory - time limit... :)

p.s. OH! i`m forget one.... Code from postgresDAC consist complex critical errors, what rise in case if you use more than 1 EventAlerter in you project. Sory, but explain this error i`m can only on russian.

User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Postby mdaems » 26.05.2010, 23:07

silvioprog,
I'm afraid you are mixing Notices/Warnings and Notify/Listen
They are fundamentally different I believe. The event monitor is only for Notify/Listen.

For the artwork: SVN rev 808. Thanks!

Mark
Concerning Notce/Warning : have a look at TZPostgreSQLConnection.Open. There I already use FPlainDriver.SetNoticeProcessor(FHandle,FNoticeProcessor,nil) to avoid the default NoticeProcessing being used. (Otherwise stderr is flooded with messages)

If you know a good way we can pass a custom NoticeProcessor from TZConnection to TZPostGreSQLCnnection, you may have what you want.

Mark
Image

silvioprog
Junior Boarder
Junior Boarder
Posts: 42
Joined: 10.01.2009, 00:34
Location: Brasil
Contact:

Postby silvioprog » 27.05.2010, 03:38

Thanks for the excellent work. I did tests again and the component is working perfectly well. :up:

Please, I updated my SVN and did not see the updated files (ZPgEventAlerter.pas, ZComponentReg.lrs ...). :(

Is there any estimate of when the component is released in the palette of Lazarus?

See ZPgEventAlerter in my IDE:

http://imagebin.org/98465

In attached a updated (and refactored) ZPgEventAlerter.pas(if you prefer, you can modify), and patchs.

Thank you my friends, I'm using the component in an application for chat, in Linux and Win. ^_^

Thanks again.
You do not have the required permissions to view the files attached to this post.

silvioprog
Junior Boarder
Junior Boarder
Posts: 42
Joined: 10.01.2009, 00:34
Location: Brasil
Contact:

Postby silvioprog » 27.05.2010, 07:33

Hi again guys,

A simple sample in attached.

Thansk :wink:

In run: http://imagebin.org/98510
You do not have the required permissions to view the files attached to this post.

mrLion
Senior Boarder
Senior Boarder
Posts: 71
Joined: 20.03.2010, 10:17

Postby mrLion » 30.05.2010, 18:33

silvioprog, The component has a critical error, which is not so obvious perhaps ...
Description:
Suppose we have an event 'any_evnt'.
Create 2 MDI-windows, each of which has its EventAlerter, which handles the message. When it starts to work or other windows - we do not know! But suppose the user has launched immediately both. Everything is normal. However, as soon will be closed any of them, then the other components will stop receiving messages from the server.

This situation - my constant problem. I solved it, but not too gracefully and to the same code was a bit crooked. What does not satisfy me.
The simplest thing that comes to mind - is the creation of "manager", through which will connect every EventAlerter, and which will be sent by the active components of incoming messages.

It turns out that some sort of loading / unloading of DLL libraries or COM objects. I'll try to make such a system in C + +, and even it turns out, but not enough time because of work. Can throw the source code in C + + (bound to PostgresDAC), if there is a desire to help / take the ideas and refine - I will be very glad and grateful.

Yes, and yet, it is worth to pass the parameter 'extra' in the function OnEvent. Then, would not be necessary to alter the code component at the output PostgreSQL 9.

Ivan.


Return to “User Patches”

Who is online

Users browsing this forum: No registered users and 1 guest