Hi.
I was trying to upgrade PostgreSQL from 7.2.8 to 8.1.2.
Dump and restore work well. But adddepend was failed.
To fix it, this regexp
$seq =~ s|^nextval\(["']+([^'"\)]+)["']+.*\)$|$1|g;
need to change
$seq =~ s|^nextval\(\(["']+([^'"\)]+)["']+.*\)$|$1|g;
or
$seq =~ s|^nextval\(\(?["']+([^'"\)]+)["']+.*\)$|$1|g;
----
[ishida@localhost adddepend]$ ./adddepend -Y -d ishida
Upgrade the Unique Constraint style via:
DROP INDEX t_i_key RESTRICT;
ALTER TABLE t ADD CONSTRAINT t_i_key UNIQUE (i);
NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "t_i_key"
for table "t"
Do you wish to upgrade Sequence 'nextval(('"t_i_seq"'::text)::regclass)'
to SERIAL?
Found on column t.i
DBD::Pg::st execute failed: ERROR: syntax error at or near ""t_i_seq""
at character 790 at ./adddepend line 539.
----
---- logfile
ERROR: syntax error at or near ""t_i_seq"" at character 790
STATEMENT:
INSERT INTO pg_catalog.pg_depend
( classid
, objid
, objsubid
, refclassid
, refobjid
, refobjsubid
, deptype
) VALUES ( (SELECT c.oid -- classid
FROM pg_class as c
JOIN pg_namespace as n
ON (n.oid = c.relnamespace)
WHERE n.nspname = 'pg_catalog'
AND c.relname = 'pg_class')
, (SELECT c.oid -- objid
FROM pg_class as c
JOIN pg_namespace as n
ON (n.oid = c.relnamespace)
WHERE n.nspname = 'public'
AND c.relname =
'nextval(('"t_i_seq"'::text)::regclass)')
, 0 -- objsubid
, (SELECT c.oid -- refclassid
FROM pg_class as c
JOIN pg_namespace as n
ON (n.oid = c.relnamespace)
WHERE n.nspname = 'pg_catalog'
AND c.relname = 'pg_class')
, (SELECT c.oid -- refobjid
FROM pg_class as c
JOIN pg_namespace as n
ON (n.oid = c.relnamespace)
WHERE n.nspname = 'public'
AND c.relname = 't')
, (SELECT a.attnum -- refobjsubid
FROM pg_class as c
JOIN pg_namespace as n
ON (n.oid = c.relnamespace)
JOIN pg_attribute as a
ON (a.attrelid = c.oid)
WHERE n.nspname = 'public'
AND c.relname = 't'
AND a.attname = 'i')
, 'i' -- deptype
);
--
ISHIDA Akio <iakio@mono-space.net / ishida@cycleof5th.com>
*** ./contrib/adddepend/adddepend.orig 2003-11-30 07:39:16.000000000 +0900
--- ./contrib/adddepend/adddepend 2006-01-18 00:46:32.000000000 +0900
***************
*** 469,475 ****
my $seq = $row->{'adsrc'};
# Extract the sequence name from the default
! $seq =~ s|^nextval\(["']+([^'"\)]+)["']+.*\)$|$1|g;
# Does the user want to upgrade this sequence?
print <<MSG
--- 469,475 ----
my $seq = $row->{'adsrc'};
# Extract the sequence name from the default
! $seq =~ s|^nextval\(\(["']+([^'"\)]+)["']+.*\)$|$1|g;
# Does the user want to upgrade this sequence?
print <<MSG