On Tue, 2006-02-14 at 12:32 -0500, Tom Lane wrote: > Simon Riggs <[EMAIL PROTECTED]> writes: > > Just put an if test around that blob-handling behaviour. The code looks > > very simple, so patch enclosed to augment the already-applied patch. > > Isn't the end-restore test backwards?
Corrected in enclosed patch. Another problem found and fixed also. > > Chris, do you have a set-up to test out the blob behaviour? > > Just do a couple of lo_imports into a test database, dump, look at > pg_restore's output to see if it's sane ... Tests pass. BEGIN/COMMIT in correct places in log files (included). Tests enclosed: without single transaction ./test.sh > 0.log with single transaction ./test.sh -1 > 1.log Also tested with direct database connection, which works both in error and success. [My earlier problem was a library version mismatch from the recent update of the COPY protocol, thankfully.] Best Regards, Simon Riggs
--
-- This runs some common tests against the type
--
-- It's used just for development
--
-- XXX would be nice to turn this into a proper regression test
--
-- Check what is in pg_largeobject
SELECT count(DISTINCT loid) FROM pg_largeobject;
SELECT pg_relation_size('pg_largeobject');
-- create the test table
CREATE TABLE a (fname name,image lo);
-- insert a null object
INSERT INTO a VALUES ('empty');
-- insert a large object based on a file
INSERT INTO a VALUES ('jlo', lo_import('/tmp/jlo')::lo);
INSERT INTO a VALUES ('halo', lo_import('/tmp/jlo')::lo);
-- Check what is in pg_largeobject ... if different from original, trouble
SELECT count(DISTINCT loid) FROM pg_largeobject;
SELECT pg_relation_size('pg_largeobject');
-- end of tests
DROP TABLE
count
-------
0
(1 row)
pg_relation_size
------------------
16384
(1 row)
CREATE TABLE
INSERT 0 1
INSERT 0 1
INSERT 0 1
count
-------
2
(1 row)
pg_relation_size
------------------
32768
(1 row)
DROP DATABASE
CREATE DATABASE
======== start
SET
SET
SET
COMMENT
SET
CREATE DOMAIN
ALTER DOMAIN
CREATE FUNCTION
ALTER FUNCTION
SET
SET
CREATE TABLE
ALTER TABLE
CREATE TABLE
ALTER TABLE
CREATE TABLE
ALTER TABLE
CREATE TABLE
ALTER TABLE
CREATE TABLE
ALTER TABLE
CREATE TABLE
ALTER TABLE
SET
BEGIN
lo_open
---------
0
(1 row)
lowrite
---------
10908
(1 row)
lo_close
----------
0
(1 row)
lo_open
---------
0
(1 row)
lowrite
---------
10908
(1 row)
lo_close
----------
0
(1 row)
COMMIT
REVOKE
REVOKE
GRANT
GRANT
======== end
DROP TABLE
count
-------
0
(1 row)
pg_relation_size
------------------
16384
(1 row)
CREATE TABLE
INSERT 0 1
INSERT 0 1
INSERT 0 1
count
-------
2
(1 row)
pg_relation_size
------------------
32768
(1 row)
DROP DATABASE
CREATE DATABASE
======== start
BEGIN
SET
SET
SET
COMMENT
SET
CREATE DOMAIN
ALTER DOMAIN
CREATE FUNCTION
ALTER FUNCTION
SET
SET
CREATE TABLE
ALTER TABLE
CREATE TABLE
ALTER TABLE
CREATE TABLE
ALTER TABLE
CREATE TABLE
ALTER TABLE
CREATE TABLE
ALTER TABLE
CREATE TABLE
ALTER TABLE
SET
lo_open
---------
0
(1 row)
lowrite
---------
10908
(1 row)
lo_close
----------
0
(1 row)
lo_open
---------
0
(1 row)
lowrite
---------
10908
(1 row)
lo_close
----------
0
(1 row)
REVOKE
REVOKE
GRANT
GRANT
COMMIT
======== end
test.sh
Description: application/shellscript
Index: src/bin/pg_dump/pg_backup_archiver.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v
retrieving revision 1.124
diff -c -r1.124 pg_backup_archiver.c
*** src/bin/pg_dump/pg_backup_archiver.c 13 Feb 2006 21:30:19 -0000 1.124
--- src/bin/pg_dump/pg_backup_archiver.c 14 Feb 2006 22:48:03 -0000
***************
*** 214,220 ****
dumpTimestamp(AH, "Started on", AH->createDate);
if (ropt->single_txn)
! ahprintf(AH, "BEGIN;\n\n");
/*
* Establish important parameter values right away.
--- 214,225 ----
dumpTimestamp(AH, "Started on", AH->createDate);
if (ropt->single_txn)
! {
! if (AH->connection)
! StartTransaction(AH);
! else
! ahprintf(AH, "BEGIN;\n\n");
! }
/*
* Establish important parameter values right away.
***************
*** 377,383 ****
}
if (ropt->single_txn)
! ahprintf(AH, "COMMIT;\n\n");
if (AH->public.verbose)
dumpTimestamp(AH, "Completed on", time(NULL));
--- 382,393 ----
}
if (ropt->single_txn)
! {
! if (AH->connection)
! CommitTransaction(AH);
! else
! ahprintf(AH, "COMMIT;\n\n");
! }
if (AH->public.verbose)
dumpTimestamp(AH, "Completed on", time(NULL));
***************
*** 652,661 ****
void
StartRestoreBlobs(ArchiveHandle *AH)
{
! if (AH->connection)
! StartTransaction(AH);
! else
! ahprintf(AH, "BEGIN;\n\n");
AH->blobCount = 0;
}
--- 662,674 ----
void
StartRestoreBlobs(ArchiveHandle *AH)
{
! if (!AH->ropt->single_txn)
! {
! if (AH->connection)
! StartTransaction(AH);
! else
! ahprintf(AH, "BEGIN;\n\n");
! }
AH->blobCount = 0;
}
***************
*** 666,675 ****
void
EndRestoreBlobs(ArchiveHandle *AH)
{
! if (AH->connection)
! CommitTransaction(AH);
! else
! ahprintf(AH, "COMMIT;\n\n");
ahlog(AH, 1, "restored %d large objects\n", AH->blobCount);
}
--- 679,691 ----
void
EndRestoreBlobs(ArchiveHandle *AH)
{
! if (!AH->ropt->single_txn)
! {
! if (AH->connection)
! CommitTransaction(AH);
! else
! ahprintf(AH, "COMMIT;\n\n");
! }
ahlog(AH, 1, "restored %d large objects\n", AH->blobCount);
}
---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?
http://www.postgresql.org/docs/faq
