Opened 5 years ago

Closed 5 years ago

#2759 closed defect (fixed)

script postgis_restore.pl fails on some complexes comments

Reported by: xcaeag Owned by: strk
Priority: medium Milestone: PostGIS 2.1.4
Component: build/upgrade/install Version: 2.1.x
Keywords: Cc:

Description

Migrating a postgis database from v1.5 to 2.1.3, the postgis_restore.pl script fails on some complexes comments (containing comments themselves!)

The SQL script generated is no longer functional.

The removal of the 171 line of the file seems to correct the problem.

L171 : # next if !$inCopy && $l =~ / *--/;

Attachments (1)

test.backup (1.1 KB) - added by xcaeag 5 years ago.
small backup for tests

Download all attachments as: .zip

Change History (10)

comment:1 Changed 5 years ago by robe

Component: postgisbuild/upgrade/install
Milestone: PostGIS 2.1.4
Owner: changed from pramsey to strk

comment:2 Changed 5 years ago by strk

xcaeag, can you provide a small example of a dump that fails to be restored ? Also a patch would help, in case line 171 changed...

comment:3 Changed 5 years ago by strk

Line 171 of postgis_restore.pl in trunk indeed matches what you reported, but I remember it was needed to avoid skipping lines starting with an sql-comment (--) within a COPY FROM STDIN block. Commenting that out would re-introduce that bug. See #1865

comment:4 Changed 5 years ago by xcaeag

I admit that the scenario is not ordinary : These are lines that contain double minus-sign in a commentary table for example.

Sometimes, if this line disappears, the comment will not be closed properly in output.

COMMENT ON TABLE my_table IS 'A comment, with somes - 
-- line 1';

Commenting line 171 allowed us (in our case) to migrate our schema.

comment:5 Changed 5 years ago by strk

Do you have the dump around to test a different patch ? To be robust the patch should recognize COMMENT lines and find the correct end of the command

Changed 5 years ago by xcaeag

Attachment: test.backup added

small backup for tests

comment:6 Changed 5 years ago by xcaeag

attached file (single table, schema only, no data. schema:'dce') generated with :

pg_dump -s -h localhost -Fc -b -v -t dce.station -f "test.backup" refgeo2

comment:7 Changed 5 years ago by strk

Please see how you like r12918 (in trunk). Seems to work fine for your case too, and I tested with a couple more combinations

comment:8 Changed 5 years ago by xcaeag

It's perfect for us! Thank you, the patch is better done like that!

comment:9 Changed 5 years ago by strk

Resolution: fixed
Status: newclosed

Thanks for testing. Backported to 2.1 branch (2.1.4) with r12919

Note: See TracTickets for help on using tickets.