12
12
* by PostgreSQL
13
13
*
14
14
* IDENTIFICATION
15
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.502 2008/09/24 19:33:15 heikki Exp $
15
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.503 2008/10/31 08:39:21 heikki Exp $
16
16
*
17
17
*-------------------------------------------------------------------------
18
18
*/
@@ -36,6 +36,7 @@ int optreset;
36
36
37
37
#include "access/attnum.h"
38
38
#include "access/sysattr.h"
39
+ #include "catalog/pg_cast.h"
39
40
#include "catalog/pg_class.h"
40
41
#include "catalog/pg_proc.h"
41
42
#include "catalog/pg_trigger.h"
@@ -4410,21 +4411,31 @@ getCasts(int *numCasts)
4410
4411
int i_casttarget ;
4411
4412
int i_castfunc ;
4412
4413
int i_castcontext ;
4414
+ int i_castmethod ;
4413
4415
4414
4416
/* Make sure we are in proper schema */
4415
4417
selectSourceSchema ("pg_catalog" );
4416
4418
4417
- if (g_fout -> remoteVersion >= 70300 )
4419
+ if (g_fout -> remoteVersion >= 80400 )
4420
+ {
4421
+ appendPQExpBuffer (query , "SELECT tableoid, oid, "
4422
+ "castsource, casttarget, castfunc, castcontext, "
4423
+ "castmethod "
4424
+ "FROM pg_cast ORDER BY 3,4" );
4425
+ }
4426
+ else if (g_fout -> remoteVersion >= 70300 )
4418
4427
{
4419
4428
appendPQExpBuffer (query , "SELECT tableoid, oid, "
4420
- "castsource, casttarget, castfunc, castcontext "
4429
+ "castsource, casttarget, castfunc, castcontext, "
4430
+ "CASE WHEN castfunc = 0 THEN 'b' ELSE 'f' END AS castmethod "
4421
4431
"FROM pg_cast ORDER BY 3,4" );
4422
4432
}
4423
4433
else
4424
4434
{
4425
4435
appendPQExpBuffer (query , "SELECT 0 as tableoid, p.oid, "
4426
4436
"t1.oid as castsource, t2.oid as casttarget, "
4427
- "p.oid as castfunc, 'e' as castcontext "
4437
+ "p.oid as castfunc, 'e' as castcontext, "
4438
+ "'f' as castmethod "
4428
4439
"FROM pg_type t1, pg_type t2, pg_proc p "
4429
4440
"WHERE p.pronargs = 1 AND "
4430
4441
"p.proargtypes[0] = t1.oid AND "
@@ -4447,6 +4458,7 @@ getCasts(int *numCasts)
4447
4458
i_casttarget = PQfnumber (res , "casttarget" );
4448
4459
i_castfunc = PQfnumber (res , "castfunc" );
4449
4460
i_castcontext = PQfnumber (res , "castcontext" );
4461
+ i_castmethod = PQfnumber (res , "castmethod" );
4450
4462
4451
4463
for (i = 0 ; i < ntups ; i ++ )
4452
4464
{
@@ -4462,6 +4474,7 @@ getCasts(int *numCasts)
4462
4474
castinfo [i ].casttarget = atooid (PQgetvalue (res , i , i_casttarget ));
4463
4475
castinfo [i ].castfunc = atooid (PQgetvalue (res , i , i_castfunc ));
4464
4476
castinfo [i ].castcontext = * (PQgetvalue (res , i , i_castcontext ));
4477
+ castinfo [i ].castmethod = * (PQgetvalue (res , i , i_castmethod ));
4465
4478
4466
4479
/*
4467
4480
* Try to name cast as concatenation of typnames. This is only used
@@ -7188,18 +7201,26 @@ dumpCast(Archive *fout, CastInfo *cast)
7188
7201
getFormattedTypeName (cast -> castsource , zeroAsNone ),
7189
7202
getFormattedTypeName (cast -> casttarget , zeroAsNone ));
7190
7203
7191
- if (!OidIsValid (cast -> castfunc ))
7192
- appendPQExpBuffer (defqry , "WITHOUT FUNCTION" );
7193
- else
7204
+ switch (cast -> castmethod )
7194
7205
{
7195
- /*
7196
- * Always qualify the function name, in case it is not in pg_catalog
7197
- * schema (format_function_signature won't qualify it).
7198
- */
7199
- appendPQExpBuffer (defqry , "WITH FUNCTION %s." ,
7200
- fmtId (funcInfo -> dobj .namespace -> dobj .name ));
7201
- appendPQExpBuffer (defqry , "%s" ,
7202
- format_function_signature (funcInfo , true));
7206
+ case COERCION_METHOD_BINARY :
7207
+ appendPQExpBuffer (defqry , "WITHOUT FUNCTION" );
7208
+ break ;
7209
+ case COERCION_METHOD_INOUT :
7210
+ appendPQExpBuffer (defqry , "WITH INOUT" );
7211
+ break ;
7212
+ case COERCION_METHOD_FUNCTION :
7213
+ /*
7214
+ * Always qualify the function name, in case it is not in
7215
+ * pg_catalog schema (format_function_signature won't qualify it).
7216
+ */
7217
+ appendPQExpBuffer (defqry , "WITH FUNCTION %s." ,
7218
+ fmtId (funcInfo -> dobj .namespace -> dobj .name ));
7219
+ appendPQExpBuffer (defqry , "%s" ,
7220
+ format_function_signature (funcInfo , true));
7221
+ break ;
7222
+ default :
7223
+ write_msg (NULL , "WARNING: bogus value in pg_cast.castmethod field\n" );
7203
7224
}
7204
7225
7205
7226
if (cast -> castcontext == 'a' )
0 commit comments