dbTalk Databases Forums  

[BUGS] BUG #2383: MessageBox Win32 API makes clients freeze

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss [BUGS] BUG #2383: MessageBox Win32 API makes clients freeze in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Pegasus86
 
Posts: n/a

Default [BUGS] BUG #2383: MessageBox Win32 API makes clients freeze - 04-09-2006 , 06:47 PM







The following bug has been logged online:

Bug reference: 2383
Logged by: Pegasus86
Email address: Pegasus86 (AT) katamail (DOT) com
PostgreSQL version: 8.1.3
Operating system: Windows XP Professional
Description: MessageBox Win32 API makes clients freeze
Details:

I am working on a PC with AMD64 X2 processor, but 32-bit XP Professional.

I have created a db which contains a function linked to a C function
contained in a dll. This function should show a message box to the users.
The problem is that every client freezes when I call this function through
SQL commands.
I have tried PgAdminIII, psql AND clients, written by me in Delphi,
accessing PostgreSQL via ODBC.

To reproduce the problem, use Dev-Cpp 5 beta for Windows (using GCC) and
create a dll project (choose any name), choosing C as the language for the
project.

Now, you will have 2 files: one .c file, and .h file. These are the
contents:


/************************************************** **
C FILE: I have called it "dllmain.c"
************************************************** **/
#include "dll.h"
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <libpq-fe.h>

DLLIMPORT void f1 (void)
{
/*Remember to grant access to user 'Postgres' to the file you want to
open! (in this case, C:/Test.txt */
FILE *fp = fopen("C:/Test.txt", "w");

if (!fp){
exit(1);
}

fprintf(fp, "Hello, World of C!!!");
fclose(fp);
}


DLLIMPORT void f2 (void)
{
MessageBox (0, "Hello World from DLL!\n", "Hi", MB_ICONINFORMATION);
}


/*DllMain generated by Dev-Cpp*/
BOOL APIENTRY DllMain (HINSTANCE hInst /* Library instance handle. */ ,
DWORD reason /* Reason this function is being
called. */ ,
LPVOID reserved /* Not used. */ )
{
switch (reason)
{
case DLL_PROCESS_ATTACH:
break;

case DLL_PROCESS_DETACH:
break;

case DLL_THREAD_ATTACH:
break;

case DLL_THREAD_DETACH:
break;
}

/* Returns TRUE on success, FALSE on failure */
return TRUE;
}



/************************************************
HEADER FILE: I have called it "dll.h"
************************************************/
#ifndef _DLL_H_
#define _DLL_H_

#if BUILDING_DLL
# define DLLIMPORT __declspec (dllexport)
#else /* Not BUILDING_DLL */
# define DLLIMPORT __declspec (dllimport)
#endif /* Not BUILDING_DLL */


DLLIMPORT void f1 (void);
DLLIMPORT void f2 (void);


#endif /* _DLL_H_ */



Now, simply build the DLL, and create two "C" functions in your database,
called f1 and f2, linking them to the corresponding function in the DLL.

Now, create the file "c:/Test.txt" (you can leave it empty) and run (from
any client):

"SELECT <schema-name>.f1()" --> it works!!! The file is written!

Now, run

"SELECT <schema-name>.f2()" ---> frozen!!!


And, last but not least, even wxPython, called trough "plpythonu" freezes
when I try to use its MessageBox() function!!!

Thanks
P.86

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

Reply With Quote
  #2  
Old   
Tom Lane
 
Posts: n/a

Default Re: [BUGS] BUG #2383: MessageBox Win32 API makes clients freeze - 04-09-2006 , 06:55 PM






"Pegasus86" <Pegasus86 (AT) katamail (DOT) com> writes:
Quote:
I have created a db which contains a function linked to a C function
contained in a dll. This function should show a message box to the users.
This makes no sense whatsoever, as a C function will run in the server
process, which may not even be on the same machine as the clients, and
certainly will not have access to their screens given any minimal
concern for security in the system setup.

regards, tom lane

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

http://archives.postgresql.org


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.