Return-Path: postman 
Delivery-Date: Wed, 06 Oct 93 10:37:19 PDT
Return-Path: postman
Received: by postgres.Berkeley.EDU (5.61/1.29)
	id AA26814; Wed, 6 Oct 93 10:33:47 -0700
Resent-From: postman (POSTGRES mailing list)
Resent-Message-Id: <9310061733.AA26814@postgres.Berkeley.EDU>
Sender: owner-postman@postgres.Berkeley.EDU
X-Return-Path: gesamic@isa.informatik.th-darmstadt.de
Received: from rs2.hrz.th-darmstadt.de by postgres.Berkeley.EDU (5.61/1.29)
	id AA26806; Wed, 6 Oct 93 10:33:38 -0700
Received: from sun21.isa.informatik.th-darmstadt.de by rs2.hrz.th-darmstadt.de with SMTP id AA05803
  (5.65c/IDA-1.4.4 for <postgres@postgres.berkeley.edu>); Wed, 6 Oct 1993 18:36:13 +0100
Received: from sun38.isa.informatik.th-darmstadt.de by sun21.isa.informatik.th-darmstadt.de (4.1/Server-1.5/HRZ-THD)
	id AA03491; Wed, 6 Oct 93 18:36:12 +0100
From: SEP Lutz <gesamic@isa.informatik.th-darmstadt.de>
Message-Id: <9310061736.AA03491@sun21.isa.informatik.th-darmstadt.de>
Subject: p_read() returning -1 ??!
To: postgres@postgres.berkeley.edu
Date: Wed, 6 Oct 1993 18:36:15 +0100 (MET)
Cc: lutz@isa.informatik.th-darmstadt.de (Guenter Lutz)
X-Mailer: ELM [version 2.4 PL22]
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Content-Length: 2040      
Resent-To: postgres-dist
Resent-Date: Wed, 06 Oct 93 10:33:44 PDT

Hello POSTGRES developers,

in order to copy data with transaction protection from one POSTGRES
database to another, I use the fork() system call to duplicate
my copy process and send the data read in the source database by the
child process part using SysV messages to the father process part of my
program, which stores the received data into the target database.

This procedure works pretty well for "normal" tuple data read into a
portal buffer by retrieve commands.

But when I tried to copy large objects in the same way,
after successfully opening the inversion file, the child gets a return
value of -1 from the p_read() function:


  invfd = p_open(invname, INV_READ);
#if DEBUG_DB_COMPONENT
  fprintf (DEBUGOUT, "invfd = %d\n", invfd);
  fflush (DEBUGOUT);
#endif

  unixfd = open(unixname,             /* neu erstellen, exclusiv */
	        O_WRONLY | O_CREAT | O_EXCL, 
		S_IRUSR | S_IWUSR);   /* User kriegt Schreib/Leserechte */
  if (unixfd == (-1))
    return (FILEEXISTS);              /* Fehler wenn Datei schon existiert */

  if (invfd == (-1))                  /* Datei existiert in PG nicht */
    return (INVNEXISTS);
  
  readcnt = p_read(invfd, buffer, P_BUFSIZE);

#if DEBUG_DB_COMPONENT
  fprintf (DEBUGOUT, "read = ");
  fflush (DEBUGOUT);
#endif

  sumread = readcnt;
  while (readcnt > 0) {                  /* Alle Daten */
    error = write(unixfd, buffer, readcnt);
    sumread += readcnt;

#if DEBUG_DB_COMPONENT
  fprintf (DEBUGOUT, "%d ", sumread);
  fflush (DEBUGOUT);
#endif

    readcnt = p_read(invfd, buffer, P_BUFSIZE);
  }

#if DEBUG_DB_COMPONENT
  fprintf (DEBUGOUT, "%d\n", sumread);
  fflush (DEBUGOUT);
#endif


prints out "read = -1", although reading the large object from a
simple program not using fork() works well.

Any hints or suggestions? Am I doing something wrong?

Thanks for any help,

Andreas Loew
(gesamic@isa.informatik.th-darmstadt.de)


-- 
SE Projektgruppe GeSAMiC      Email: gesamic@isa.informatik.th-darmstadt.de
Fachbereich 1
Technische Hochschule Darmstadt / Germany

