12
12
* by PostgreSQL
13
13
*
14
14
* IDENTIFICATION
15
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.405 2005/04/01 18:35:41 tgl Exp $
15
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.406 2005/04/12 04:26:27 tgl Exp $
16
16
*
17
17
*-------------------------------------------------------------------------
18
18
*/
@@ -6325,13 +6325,15 @@ dumpAgg(Archive *fout, AggInfo *agginfo)
6325
6325
int ntups ;
6326
6326
int i_aggtransfn ;
6327
6327
int i_aggfinalfn ;
6328
+ int i_aggsortop ;
6328
6329
int i_aggtranstype ;
6329
6330
int i_agginitval ;
6330
6331
int i_anybasetype ;
6331
6332
int i_fmtbasetype ;
6332
6333
int i_convertok ;
6333
6334
const char * aggtransfn ;
6334
6335
const char * aggfinalfn ;
6336
+ const char * aggsortop ;
6335
6337
const char * aggtranstype ;
6336
6338
const char * agginitval ;
6337
6339
bool convertok ;
@@ -6349,10 +6351,25 @@ dumpAgg(Archive *fout, AggInfo *agginfo)
6349
6351
selectSourceSchema (agginfo -> aggfn .dobj .namespace -> dobj .name );
6350
6352
6351
6353
/* Get aggregate-specific details */
6352
- if (g_fout -> remoteVersion >= 70300 )
6354
+ if (g_fout -> remoteVersion >= 80100 )
6355
+ {
6356
+ appendPQExpBuffer (query , "SELECT aggtransfn, "
6357
+ "aggfinalfn, aggtranstype::pg_catalog.regtype, "
6358
+ "aggsortop::pg_catalog.regoperator, "
6359
+ "agginitval, "
6360
+ "proargtypes[0] = 'pg_catalog.\"any\"'::pg_catalog.regtype as anybasetype, "
6361
+ "proargtypes[0]::pg_catalog.regtype as fmtbasetype, "
6362
+ "'t'::boolean as convertok "
6363
+ "from pg_catalog.pg_aggregate a, pg_catalog.pg_proc p "
6364
+ "where a.aggfnoid = p.oid "
6365
+ "and p.oid = '%u'::pg_catalog.oid" ,
6366
+ agginfo -> aggfn .dobj .catId .oid );
6367
+ }
6368
+ else if (g_fout -> remoteVersion >= 70300 )
6353
6369
{
6354
6370
appendPQExpBuffer (query , "SELECT aggtransfn, "
6355
6371
"aggfinalfn, aggtranstype::pg_catalog.regtype, "
6372
+ "0 as aggsortop, "
6356
6373
"agginitval, "
6357
6374
"proargtypes[0] = 'pg_catalog.\"any\"'::pg_catalog.regtype as anybasetype, "
6358
6375
"proargtypes[0]::pg_catalog.regtype as fmtbasetype, "
@@ -6366,6 +6383,7 @@ dumpAgg(Archive *fout, AggInfo *agginfo)
6366
6383
{
6367
6384
appendPQExpBuffer (query , "SELECT aggtransfn, aggfinalfn, "
6368
6385
"format_type(aggtranstype, NULL) as aggtranstype, "
6386
+ "0 as aggsortop, "
6369
6387
"agginitval, "
6370
6388
"aggbasetype = 0 as anybasetype, "
6371
6389
"CASE WHEN aggbasetype = 0 THEN '-' "
@@ -6380,6 +6398,7 @@ dumpAgg(Archive *fout, AggInfo *agginfo)
6380
6398
appendPQExpBuffer (query , "SELECT aggtransfn1 as aggtransfn, "
6381
6399
"aggfinalfn, "
6382
6400
"(select typname from pg_type where oid = aggtranstype1) as aggtranstype, "
6401
+ "0 as aggsortop, "
6383
6402
"agginitval1 as agginitval, "
6384
6403
"aggbasetype = 0 as anybasetype, "
6385
6404
"(select typname from pg_type where oid = aggbasetype) as fmtbasetype, "
@@ -6403,6 +6422,7 @@ dumpAgg(Archive *fout, AggInfo *agginfo)
6403
6422
6404
6423
i_aggtransfn = PQfnumber (res , "aggtransfn" );
6405
6424
i_aggfinalfn = PQfnumber (res , "aggfinalfn" );
6425
+ i_aggsortop = PQfnumber (res , "aggsortop" );
6406
6426
i_aggtranstype = PQfnumber (res , "aggtranstype" );
6407
6427
i_agginitval = PQfnumber (res , "agginitval" );
6408
6428
i_anybasetype = PQfnumber (res , "anybasetype" );
@@ -6411,6 +6431,7 @@ dumpAgg(Archive *fout, AggInfo *agginfo)
6411
6431
6412
6432
aggtransfn = PQgetvalue (res , 0 , i_aggtransfn );
6413
6433
aggfinalfn = PQgetvalue (res , 0 , i_aggfinalfn );
6434
+ aggsortop = PQgetvalue (res , 0 , i_aggsortop );
6414
6435
aggtranstype = PQgetvalue (res , 0 , i_aggtranstype );
6415
6436
agginitval = PQgetvalue (res , 0 , i_agginitval );
6416
6437
/* we save anybasetype for format_aggregate_signature */
@@ -6471,6 +6492,13 @@ dumpAgg(Archive *fout, AggInfo *agginfo)
6471
6492
aggfinalfn );
6472
6493
}
6473
6494
6495
+ aggsortop = convertOperatorReference (aggsortop );
6496
+ if (aggsortop )
6497
+ {
6498
+ appendPQExpBuffer (details , ",\n SORTOP = %s" ,
6499
+ aggsortop );
6500
+ }
6501
+
6474
6502
/*
6475
6503
* DROP must be fully qualified in case same name appears in
6476
6504
* pg_catalog
0 commit comments