agora inbox for postgres@postgres.berkeley.edu
help / color / mirror / Atom feedFrom: James Woods 61-89-895256 <jaws@pangaea.dme.nt.gov.au>
To: postgres@postgres.berkeley.edu
Subject: large objects
Date: Mon, 15 Mar 93 20:46:28 -0800
Message-ID: <9303160446.AA08940@postgres.Berkeley.EDU> (raw)
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);
}
}
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: postgres@postgres.berkeley.edu
Cc: jaws@pangaea.dme.nt.gov.au
Subject: Re: large objects
In-Reply-To: <9303160446.AA08940@postgres.Berkeley.EDU>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox