postgresql - Unaccent issue when restoring a Postgres database -
i want restore particular database under database name server well. far, good.
i used command :
pg_dump -u postgres -f c -o -b -f maindb.dump maindb
to dump main database on production server. use command :
pg_restore --verbose -o -l -d restoredb maindb.dump
to restore database in database on our test server. restore ok, there errors, :
pg_restore: [archiver (db)] error while processing toc: pg_restore: [archiver (db)] error toc entry 3595; 1259 213452 index idx_clientnomclient maindbuser pg_restore: [archiver (db)] not execute query: error: function unaccent(text) not exist line 1: select unaccent(lower($1)); ^ hint: no function matches given name , argument types. might need add explicit type casts. query: select unaccent(lower($1)); context: sql function "cyunaccent" during inlining command was: create index idx_clientnomclient on client using btree (public.cyunaccent((lower((nomclient)::text))::character varying));
cyunaccent function in public shcema , gets created restore.
after restore, able re-create indexs perfecly same sql, without errors.
i've tried restore -i option of pg_restore single transaction, doesn't help.
what doing wrong ?
i found problem, , able narrow down simple test-case.
create schema intranet; create extension if not exists unaccent schema public; set search_path = public, pg_catalog; create function cyunaccent(character varying) returns character varying language sql immutable $_$ select unaccent(lower($1)); $_$; set search_path = intranet, pg_catalog; create table intranet.client ( codeclient character varying(10) not null, noclient character varying(7), nomclient character varying(200) collate pg_catalog."fr_ca" ); alter table client add constraint client_pkey primary key (codeclient); create index idx_clientnomclient on client using btree (public.cyunaccent((lower((nomclient)::text))::character varying));
this test case pg_dump done in plain text.
as can see, cyunaccent function created in public shcema, it's later used other tables in other schema.
psql/pg_restore won't re-create index, cannot find function, despite fact shcema name specified reference it. problem lies in the
set search_path = intranet, pg_catalog;
call. changing to
set search_path = intranet, public, pg_catalog;
solves problem. i've submitted bug report postgres this, not yet in queue.
Comments
Post a Comment