Subject: VARLENATT

From: Wolf Guddat <[email-masked]>
Date: Thu, 13 May 93 17:20:26 MESZ

Hi everybody!

I'm a postgres user on a ultrix 4.3 machine. Postgres so far is 
running, but i've got some problems when i try to define an ADT
with internallength=variable.
I know i don't need  variablelength in the example below but that's just a
short version of my problem, which nevertheless should work, shouldn't it?

What am i doing wrong? I would be very glad if someone helps me

Thanks Wolf

****************************************************************************
****************************************************************************
****************************************************************************

 SOURCE CODE OF STR.C 
 both routines doing nothing else than returning NULL 
 compiled with following options:  cc -G0 -O0 -c str.c

****************************************************************************
****************************************************************************
****************************************************************************
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include "postgres.h"
#include "palloc.h"
#include "builtins.h"

struct varlena *xpr_str_in ();
char         *xpr_str_out ();

struct varlena *xpr_str_in (str)
  char *str;
{

  return (NULL);
} /* xpr_string_in */

char *xpr_str_out (arg)
  struct varlena *arg; /* postgresinterne Darstellung eines Strings */
{

  return (NULL);

} /* xpr_string_out */

****************************************************************************
****************************************************************************
****************************************************************************

 This is what i do at the monitor in a brandnew database

****************************************************************************
****************************************************************************
****************************************************************************

define function xpr_str_in (language = "c",
                               returntype = XPR_STR,
                               trusted = f
                              )
                              arg is (char16)
                              as "/user/sonst/wfguddat/XPR2PG/str.o"\g
define function xpr_str_out (language = "c",
                                returntype = char16,
                                trusted = f
                               )
                               arg is (XPR_STR)
                               as "/user/sonst/wfguddat/XPR2PG/str.o"\g
define type XPR_STR (internallength = variable,
                        externallength = variable,
                        input = xpr_str_in,
                        output = xpr_str_out
                       )\g

create S (s= XPR_STR)\g

/**** so far all seems OK 
/**** i've omitted the answers from the backend 
/**** but now i can't do an append

* append S (s = "Test")\g

Query sent to backend is "append S (s = "Test")"
NOTICE:May 13 15:20:04:ufp_start: forked UFP[17543]
NOTICE:May 13 15:20:07:ufp_recv: read failed on length: No such file or directory
NOTICE:May 13 15:20:07:ufp_recvval: read failed on byvalue
NOTICE:May 13 15:20:07:ufp_kill: UFP cleaned up!
WARN:May 13 15:20:07:ufp_execute: error reading return value

Go
*

/*****
/*****The following doesn't work too 
/***** 

* append S (s = "Test"::XPR_STR)\g

Query sent to backend is "append S (s = "Test"::XPR_STR)"
NOTICE:May 13 15:22:20:ufp_start: forked UFP[17558]
NOTICE:May 13 15:22:21:ufp_recv: read failed on length: No such process
NOTICE:May 13 15:22:21:ufp_recvval: read failed on byvalue
NOTICE:May 13 15:22:21:ufp_kill: UFP cleaned up!
WARN:May 13 15:22:21:ufp_execute: error reading return value

*

---

From: [email-masked] (Paul M. Aoki)
Date: Thu, 13 May 93 11:43:45 -0700

ok.  first, the reason you get all of those "ufp..." errors is that 
you are marking your functions with "trusted=f".  now..

>  both routines doing nothing else than returning NULL 

this is the problem.  ok, more error-checking should be done so 
that the untrusted function process handles null pointers more
correctly.. but in general the in/out functions should return 
valid pointers or raise an exception.  (hmm... i wonder how well 
this piece of code works with trusted=t..)

the unhelpful error messages are due to looking at errno when
the error is user-level (wrong number of bytes received) instead 
of system-call level.
--
  Paul M. Aoki  |  CS Div., Dept. of EECS, UCB  |  [email-masked]
                |  Berkeley, CA 94720           |  ...!uunet!ucbvax!aoki