Обсуждение: binary upgade errors

Поиск
Список
Период
Сортировка

binary upgade errors

От
David Modica
Дата:

hi all. first time posting here.

 

I have been unsuccessfully trying to use pg_upgrade to upgrade from 9.6 to 10.4.

 

we have the uint extension in some of the databases. a combination of that extension

 

and probably how we have used it is causing the upgrade to fail. I will include the error msg.

 

can anyone with some experience please point me in the right direction to fix it ?

 

thanks, 

 

david

 

output from pg_upgrade:

command: "/usr/pgsql-10.4/bin/pg_restore" --host /var/lib/pgsql/10.4 --port 50432 --username postgres --exit-on-error --verbose --dbname 'dbname=devel8' "pg_upgrade_dump_271840.custom" >> "pg_upgrade_dump_271840.log" 2>&1

pg_restore: connecting to database for restore

pg_restore: creating pg_largeobject "pg_largeobject"

pg_restore: creating pg_largeobject_metadata "pg_largeobject_metadata"

pg_restore: creating SCHEMA "its"

pg_restore: creating SCHEMA "public"

pg_restore: creating COMMENT "SCHEMA "public""

pg_restore: creating EXTENSION "uint"

pg_restore: creating COMMENT "EXTENSION "uint""

pg_restore: creating DOMAIN "its.adj_id_t"

pg_restore: creating DOMAIN "its.any_id_t"

pg_restore: creating DOMAIN "its.bigint_id_t"

pg_restore: creating SHELL TYPE "public.uint1"

pg_restore: creating FUNCTION "public.uint1in("cstring")"

pg_restore: creating FUNCTION "public.uint1out("public"."uint1")"

pg_restore: creating TYPE "public.uint1"

pg_restore: creating FUNCTION "public.uint1(integer)"

pg_restore: creating DOMAIN "its.bool_t"

pg_restore: [archiver (db)] Error while PROCESSING TOC:

pg_restore: [archiver (db)] Error from TOC entry 4538; 1247 280489 DOMAIN bool_t postgres

pg_restore: [archiver (db)] could not execute query: ERROR:  cannot cast type integer to public.uint1

    Command was:

-- For binary upgrade, must preserve pg_type oid

SELECT pg_catalog.binary_upgrade_set_next_pg_type_oid('280489'::pg_catalog.oid);

 

CREATE DOMAIN "its"."bool_t" AS "public"."uint1" DEFAULT (0)::"public"."uint1";

 

 

Re: binary upgade errors

От
Tom Lane
Дата:
David Modica <davidmo@imaginesoftware.com> writes:
> I have been unsuccessfully trying to use pg_upgrade to upgrade from 9.6 to 10.4.
> we have the uint extension in some of the databases. a combination of that extension
> and probably how we have used it is causing the upgrade to fail. I will include the error msg.

> pg_restore: [archiver (db)] Error while PROCESSING TOC:
> pg_restore: [archiver (db)] Error from TOC entry 4538; 1247 280489 DOMAIN bool_t postgres
> pg_restore: [archiver (db)] could not execute query: ERROR:  cannot cast type integer to public.uint1
>     Command was:
> -- For binary upgrade, must preserve pg_type oid
> SELECT pg_catalog.binary_upgrade_set_next_pg_type_oid('280489'::pg_catalog.oid);

> CREATE DOMAIN "its"."bool_t" AS "public"."uint1" DEFAULT (0)::"public"."uint1";

Hmm ... it looks like this domain is depending on there to be a cast from
integer to uint1, but that hasn't been created yet.  There may be a bug
here; I'm not sure why pg_dump didn't delay dumping the domain to after
it'd dumped the cast.  In the meantime, though, it seems like it would
work (and probably be faster anyway) if you spelled the default value
like '0'::uint1 rather than 0::uint1, as the former isn't depending on
any run-time cast.  So try altering the domain like that and then doing
the upgrade.

            regards, tom lane


RE: binary upgade errors

От
David Modica
Дата:
tom,

thank you so much for your reply.

isn't 0::uint1 casting an int as uint and '0'::uint1 is casting a text as a uint1 ?

not sure why one doesn't require a run time cast and the other doesn't. would you

be able to explain to me ? I am sorry but this casting is new for me.

thanks,

david



-----Original Message-----
From: Tom Lane <tgl@sss.pgh.pa.us>
Sent: Thursday, June 14, 2018 4:24 PM
To: David Modica <davidmo@imaginesoftware.com>
Cc: pgsql-admin@lists.postgresql.org
Subject: Re: binary upgade errors

David Modica <davidmo@imaginesoftware.com> writes:
> I have been unsuccessfully trying to use pg_upgrade to upgrade from 9.6 to 10.4.
> we have the uint extension in some of the databases. a combination of
> that extension and probably how we have used it is causing the upgrade to fail. I will include the error msg.

> pg_restore: [archiver (db)] Error while PROCESSING TOC:
> pg_restore: [archiver (db)] Error from TOC entry 4538; 1247 280489
> DOMAIN bool_t postgres
> pg_restore: [archiver (db)] could not execute query: ERROR:  cannot cast type integer to public.uint1
>     Command was:
> -- For binary upgrade, must preserve pg_type oid SELECT
> pg_catalog.binary_upgrade_set_next_pg_type_oid('280489'::pg_catalog.oi
> d);

> CREATE DOMAIN "its"."bool_t" AS "public"."uint1" DEFAULT
> (0)::"public"."uint1";

Hmm ... it looks like this domain is depending on there to be a cast from integer to uint1, but that hasn't been
createdyet.  There may be a bug here; I'm not sure why pg_dump didn't delay dumping the domain to after it'd dumped the
cast. In the meantime, though, it seems like it would work (and probably be faster anyway) if you spelled the default
valuelike '0'::uint1 rather than 0::uint1, as the former isn't depending on any run-time cast.  So try altering the
domainlike that and then doing the upgrade. 

            regards, tom lane


Re: binary upgade errors

От
Tom Lane
Дата:
David Modica <davidmo@imaginesoftware.com> writes:
> isn't 0::uint1 casting an int as uint and '0'::uint1 is casting a text as a uint1 ?

No.  0 is an integer constant and so the first case requires invoking
an int -> uint1 cast.  The second syntax implies applying uint1's type
input function to the string '0', and arriving at a constant immediately.
It's perhaps unfortunate that similar-looking syntax means two basically
different things ... but it's not the only place in SQL where much turns
on punctuation.

https://www.postgresql.org/docs/current/static/sql-expressions.html#SQL-SYNTAX-TYPE-CASTS

            regards, tom lane


binary upgade errors

От
"David G. Johnston"
Дата:
On Monday, June 18, 2018, David Modica <davidmo@imaginesoftware.com> wrote:
isn't 0::uint1 casting an int as uint and '0'::uint1 is casting a text as a uint1 ?

The second one isn't casting, period.  It is an alternate spelling of "uint1 '0'" which itself is how you write a typed literal in SQL (:: syntax is a PostgreSQL extension).  The text between the single quotes is an untyped character string that gets passed directly into the declared type's constructor/_in function.

Since the first one is not quoted the value is interpreted as a number (special case reserved for core types, I think) and the :: is then interpreted as a cast in order to go from the number to the custom type.

David J.