Subject: [[email-masked]: C functions]

From: [email-masked] (Paul M. Aoki)
Date: Thu, 25 Aug 94 11:51:26 -0700

------- Forwarded Message

 From:  N B Idris <[email-masked]>
 To:  [email-masked]
 Cc:  [email-masked]
 Subject:  C functions
 Date:  Thu, 25 Aug 94 19:50:18 BST

 In writing a user defined C function which is callable via a define function command,
 can we have within the C function :
  
 	a) Basic I/O functions such as scanf/printf?
 
 	b) System calls eg. system("shelltool routine2");
 	   where parameter "routine2" is another executable program to be invoked
 	   within the new shelltool called?
 
 I wrote such a C function which does not cause any problem to postgres, i.e. all
 db retrievel etc. are working alright.  However, all statements of the form (a) 
 and (b) above, which exist in the routine seem to be (happily) ignored by postgres.
 
 I am working on version 4.1 using Sunsparc IPX.
 
 My define command is :
 ---------------------
 	define function just_compute
 		(language = "c", returntype = int4)
 		arg is (int4,int4,int4)
 		as "/home/thrall2/scmnbi/C-PROGRAMS/compute.o" \g
 
 and my compute.c program:
 ------------------------
 
 	#include <stdio.h>
 
 		long int 	a, z, n;

 	int just_compute(a,z,n)
 	{
 		long int	x;
 
 		x= a + z + n;
 		printf("x here = %d\n",x);   <-----SEEMED IGNORED!
 		 
 		simple_system_call();
 		return(x);
 
 	}
 
 	simple_system_call()
 	{
 		int	j, t=3;	
 
 	  	for (j=1; j<=t; j++)
 		    {
 			system("shelltool routine2"); 	   <----- IGNORED!
 			/*routine2 is another xcutable */
 		    };
 	}
 
 and I used it as:
 ----------------
 
 * retrieve (employee.all) where get_shares(30,40,50) < employee.empno \g
 
 Query sent to backend is "retrieve (employee.all) where get_shares(30,40,50) < employee.empno "
 -----------------------------------------------------------------------
 | address     | empno       | ssno        | name        | project_done|
 -----------------------------------------------------------------------
 | birmingham  | 2000        | 3003        | brown       | Nato 5      |
 -----------------------------------------------------------------------
 | wolverhampton| 2001        | 3004        | carnduff    | Nato 6      |
 -----------------------------------------------------------------------
 | worcester   | 2002        | 3005        | jones       | Nato 7      |
 -----------------------------------------------------------------------
 
 Go 
 
 This retrievel is OK, but....
 THE MAIN QUESTION : What happens to those ignored statements?
 
 Thanks in anticipation.
 
 norbik.

------- End of Forwarded Message
--
  Paul M. Aoki          |  University of California at Berkeley
  [email-masked]  |  Dept. of EECS, Computer Science Division (#1776) 
                        |  Berkeley, CA 94720-1776

==============================================================================
   To add/remove yourself to/from the POSTGRES mailing list: send mail with 
   the subject line ADD or DEL to "[email-masked]"

   If this fails, send mail to "[email-masked]" and
   a human will deal with it.  DO NOT post to the "postgres" mailing list.
==============================================================================