Обсуждение: pg_dump ignore CASTs when using --schema
Hello, we have a problem with pg_dump and CAST. After some digging and asking someone pointed me to this email address. Our server: postgresql-9.4 - 9.4.6-0+deb8u1 Our problem: http://blog.endpoint.com/2015/02/postgres-pgdump-implicit-cast-problem.html?showComment=1424179126489#c5762559318074857599 short example: $ pg_dump -s --schema testschema testdatabase | grep CAST $ pg_dump -s testdatabase | grep CAST -- Name: CAST (text AS testschema.enum_users_title); Type: CAST; Schema: pg_catalog; Owner: CREATE CAST (text AS testschema.enum_users_title) WITH FUNCTION testschema.cast_users_title(text) AS IMPLICIT; Have a nice day Felix Ostmann
Felix Ostmann <felix.ostmann@gmail.com> writes: > we have a problem with pg_dump and CAST. Casts don't have names, therefore they don't have schemas, therefore a dump that is restricted to a particular schema won't select them. So this isn't a bug; it's operating as designed. This is kind of unfortunate in many scenarios, but it's hard to see a principled way around it. You might propose something like pretending that a cast is in the same schema as its implementation function, but what about casts that have no implementation function? Likewise, tying it to the schema of either the input or the output datatype seems arbitrary and about as likely to be wrong as right. regards, tom lane
On Fri, Mar 4, 2016 at 11:23 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote: > Felix Ostmann <felix.ostmann@gmail.com> writes: > > we have a problem with pg_dump and CAST. > > Casts don't have names, therefore they don't have schemas, therefore > a dump that is restricted to a particular schema won't select them. > So this isn't a bug; it's operating as designed. > > This is kind of unfortunate in many scenarios, but it's hard to see a > principled way around it. You might propose something like pretending > that a cast is in the same schema as its implementation function, but > what about casts that have no implementation function? Likewise, > tying it to the schema of either the input or the output datatype > seems arbitrary and about as likely to be wrong as right. > > =E2=80=8BBegs the question - why don't we just name them and allow them to = be placed in a schema? OR They have to exist somewhere...can we add an explicit pg_dump option to target them specifically? i.e., pg_dump --dump-unnamed David J.