Return-Path: pg_adm@postgres.berkeley.edu Received: by postgres.Berkeley.EDU (5.61/1.29) id AA08940; Mon, 15 Mar 93 20:46:28 -0800 Date: Mon, 15 Mar 93 20:46:28 -0800 Message-Id: <9303160446.AA08940@postgres.Berkeley.EDU> From: jaws@pangaea.dme.nt.gov.au (James Woods 61-89-895256) Subject: large objects To: postgres@postgres.berkeley.edu Sender: pg_adm@postgres.berkeley.edu I am just starting to delve into storing large objects using the inversion method and have run into a few problems. The first was with the setenv() call which I have written my own routine to do what I think it does, could you please tell me if it is correct. int setenv(char *var, char *val, int unknown_param) { char *envstr; if(!var || !val) { fputs("NULL string calling setenv", stderr); return; } if(unknown_param != 1) { fprintf(stderr, "unrecognised third parameter %d to setenv," " assuming it is unimportant", unknown_param); } if(!(envstr = (char*)malloc(strlen(var)+strlen(val)+2))) { fputs("out of memory error\n", stderr); exit(1); } strcpy(envstr, var); strcat(envstr, "="); strcat(envstr, val); return putenv(envstr); } The second one is that I cannot seem to create more than one lage object in a database. I am attempting to store SUN rasterfiles and when I store the first image it appears to work ok giving the following messages on the screen: sock = 4 Pfout = d714 Pfin = d728 When I then attempt to store a second image in the same database with a different name to the first it gives the following message and then just freezes: sock = 4 Pfout = d714 Pfin = d728 Error: WARN:Mar 15 14:59:59:amcreate: Xinv0 relation already exists I am using the following code, which i basically copied out of the reference manual, to store the images. void store(unsigned char *image, char *filename) { int fd; char *qry_result; char dbname[1024]; struct rasterfile *header = (struct rasterfile*)image; int bufsize = sizeof(struct rasterfile) + header->ras_maplength + header->ras_length; PQsetdb("jawsraster"); if(*(qry_result = PQexec("begin")) == 'R') { fputs("error on PQexec\n", stderr); exit(-1); } strcpy(dbname, "jaws/raster/"); if(*filename == '/') strcat(dbname, filename+1); else strcat(dbname, filename); if((fd = p_creat(dbname, INV_WRITE, Inversion)) < 0) { fprintf(stderr, "error creating database file %s\n", dbname); exit(-1); } if(p_write(fd, image, bufsize) < bufsize) { fputs("error writing image to database\n", stderr); exit(-1); } p_close(fd); if(*(qry_result = PQexec("end")) == 'R') { fputs("error commiting transaction\n", stderr); exit(-1); } }