Subject: side effect

From: [email-masked] (Young Tae Lee)
Date: Thu, 9 Jul 92 23:36:09 KDT

I was the graduate student of Dept. of Control & Instru. ,Seoul National University in Korea.
Some days ago, while I was developing simple application program using POSTGRES.I had difficulty with loading the file to the backends. I am sorry to bother you but
please tell me the mechanism that POSTGRES loads and links the object file.

I defined C function as fillowing.

  define function window(language="c",returntype=int4)
  arg is (char16) as "/user/people/young/window.o" \g

Then I tried to load the file "window.o" as following.

  load "/user/people/young/window.o" \g

But I failed, and there was a error message "link failed"

The source code "window.c" is as following.

  # include <X11/Xlib.h>
  # include <X11/Xutil.h>

  int disp(in)

  char *in;
  {
    Display *d;
    Window w;

    d=XOpenDisplay(NULL);
    w=XCreateSimpleWindow(d,DefaultRootWindow(d),50,50,400,300,2,BlackPixel(d,0),WhitePixel(d,0));
    XMapWindow(d,w);
    XFlush(d);

    return(1);
  }

In this program, I tried to get simple window by using side effect but I failed.Can't the backends link the program object code with Xlib?

Also, I programmed another simple example using side effect.
In this program, I wanted the backends to print the string in the screen and create file  "test" in "user/people/young" , but the backends did not in spite of no error in compiling and loading to the backends.
Do you know the reason?  If you know, please mail to me sooner or later.
The source code is as follows.   

> more win1.c
# include <stdio.h>
int win()
{
  FILE *fp;
  
  fp=fopen("user/people/young/test","w");
  printf("I am a student");  return(1);
}

> cc -c win1.c
> monitor fms
Welcome to the C POSTGRES terminal monitor

Go 
* define function win(language="c",returntype=int4)
arg is (motor) as "/user/people/young/win1.o"\g

Query sent to backend is "define function win(language="c",returntype=int4) arg is (motor) as "/user/people/young/win1.o""
DEFINE
Go 
* load "/user/people/young/win1.o"\g

Query sent to backend is "load "/user/people/young/win1.o""
LOAD
Go 
* retrieve (a=win(motor)) where motor.name="CAP60"\g

Query sent to backend is "retrieve (a=win(motor)) where motor.name="CAP60""
---------------
| a           |
---------------
| 1           |
---------------

---

From: postarch (Postgres Mailing Archive)
Date: Tue, 21 Jul 92 09:59:32 PDT

you write:

>     w=XCreateSimpleWindow(d,DefaultRootWindow(d),50,50,400,300,2,BlackPixel(d
 +,0),WhitePixel(d,0));
>     return(1);

The answers to these questions have been tossed around on the post_questions
alias, I'm now broadcasting the final conclusions.

| When Postgres loads an object file, it links it against itself, the standard
| C runtime library and the C math library.  Other links must be done by the
| user before Postgres attempts the load - doing a preliminary load with "ld -r"
| and having postgres load *that* file should be enough, although I've never
| tried this.

> In this program, I wanted the backends to print the string in the screen and 
 +create file  "test" in "user/people/young" , but the backends did not in spit
 +e of no error in compiling and loading to the backends.
>   printf("I am a student");  return(1);

| When running postgres under the postmaster stdin and stdout are closed
| (we use up file descriptors like they are going out of style).  If you
| want to print something in the front-end you should use elog(NOTICE, "msg");
| You will have to include "utils/log.h" to get the definition of NOTICE.

Jeff Meredith
[email-masked]