Re: [HACKERS] Backend problem with large objects - Mailing list pgsql-hackers
From | Ian Grant |
---|---|
Subject | Re: [HACKERS] Backend problem with large objects |
Date | |
Msg-id | Pine.LNX.3.96.990204223934.3966A-100000@thegrants Whole thread Raw |
In response to | Re: [HACKERS] Backend problem with large objects (Bruce Momjian <maillist@candle.pha.pa.us>) |
Responses |
Re: [HACKERS] Backend problem with large objects
|
List | pgsql-hackers |
On Thu, 4 Feb 1999, Bruce Momjian wrote: > Applied manually. The patch did not apply cleanly, and needed a &tuple > in inv_wrold, not tuple. In the 4.6.2 release there are no &tuple arguments to inv_wrold around the patch. Perhaps there is a patch you have applied that I need? Please see below: > > > On Tue, 2 Feb 1999, Tatsuo Ishii wrote: > > > > > Ok. I think I have found the source of the problem. Please apply > > included patches and try again. Many thanks indeed for this. Unfortunately it doesn't completely work: it fixes the problem as reported, but when, instead of writing five characters, one at a time, I write five at once, the backend dies in the same place it did before. Here's the C code slightly modified to reproduce the problem: #include <stdio.h> #include "libpq-fe.h" #include "libpq/libpq-fs.h" void exec_cmd(PGconn *conn, char *str); main (int argc, char *argv[]) { PGconn *conn; int lobj_fd; char buf[256]; int ret, i; Oid lobj_id; conn = PQconnectdb("dbname=test"); if (PQstatus(conn) != CONNECTION_OK) { fprintf(stderr, "Can't connect to backend.\n"); fprintf(stderr, "ERROR: %s\n", PQerrorMessage(conn)); exit(1); } exec_cmd(conn, "BEGIN TRANSACTION"); PQtrace (conn, stdout); if ((lobj_id = lo_creat(conn, INV_READ | INV_WRITE)) < 0) { fprintf(stderr, "Can'tcreate lobj.\n"); fprintf(stderr, "ERROR: %s\n", PQerrorMessage(conn)); exit(1); } if ((lobj_fd = lo_open(conn,lobj_id, INV_READ | INV_WRITE)) < 0) { fprintf(stderr, "Can't open lobj.\n"); fprintf(stderr, "ERROR:%s\n", PQerrorMessage(conn)); exit(1); } fprintf(stderr, "lo_open returned fd = %d.\n", lobj_fd); /* for (i = 0; i < 5; i++) { */ if ((ret = lo_write(conn, lobj_fd, "XXXXX", 5)) != 5) { fprintf(stderr, "Can't write lobj.\n"); fprintf(stderr,"ERROR: %s\n", PQerrorMessage(conn)); exit(1); } /* } */ if ((ret = lo_lseek(conn, lobj_fd, 1, 0)) != 1) { fprintf(stderr, "error (%d) lseeking in large object.\n", ret); fprintf(stderr, "ERROR: %s\n", PQerrorMessage(conn)); exit(1); } if ((ret = lo_write(conn, lobj_fd, "y", 1))!= 1) { fprintf(stderr, "Can't write lobj.\n"); fprintf(stderr, "ERROR: %s\n", PQerrorMessage(conn)); exit(1); } if ((ret = lo_lseek(conn, lobj_fd, 3, 0)) != 3) { fprintf(stderr, "error (%d) lseeking in large object.\n",ret); fprintf(stderr, "ERROR: %s\n", PQerrorMessage(conn)); exit(1); } if ((ret = lo_write(conn, lobj_fd,"y", 1)) != 1) { fprintf(stderr, "Can't write lobj.\n"); fprintf(stderr, "ERROR: %s\n", PQerrorMessage(conn)); exit(1); } ret = lo_close(conn, lobj_fd); printf("lo_close returned %d.\n", ret); if (ret) fprintf(stderr, "Error message: %s\n", PQerrorMessage(conn)); PQuntrace(conn); exec_cmd(conn, "END TRANSACTION"); exit(0); } void exec_cmd(PGconn *conn, char *str) { PGresult *res; if ((res = PQexec(conn, str)) == NULL) { fprintf(stderr, "Error executing %s.\n", str); fprintf(stderr, "Errormessage: %s\n", PQerrorMessage(conn)); exit(1); } if (PQresultStatus(res) != PGRES_COMMAND_OK) { fprintf(stderr,"Error executing %s.\n", str); fprintf(stderr, "Error message: %s\n", PQerrorMessage(conn)); PQclear(res); exit(1); } PQclear(res); }
pgsql-hackers by date: