Re: Rethinking pg_dump's function sorting code

From: Noah Misch <noah(at)leadboat(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgreSQL(dot)org, marko(at)joh(dot)to
Subject: Re: Rethinking pg_dump's function sorting code
Date: 2015-03-06 08:33:28
Message-ID: 20150306083328.GA121893@tornado.leadboat.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Mar 05, 2015 at 07:28:33PM -0500, Tom Lane wrote:
> In bug #12832 Marko Tiikkaja points out that commit
> 7b583b20b1c95acb621c71251150beef958bb603 created a rather unnecessary
> dump failure hazard, since it applies pg_get_function_identity_arguments()
> to every function in the database, even those that won't get dumped.
> I think we should fix this by getting rid of pg_dump's use of that
> function altogether. A low-tech way to sort functions of identical names
> would be to compare argument type OIDs, as in the attached simple patch.
> If people feel it's important to avoid depending on numerical OID order,
> we could instead look up type names locally and compare them as in the
> attached less-simple patch.

Comparing argument type names sounds fine. Comparing argument type OID does
not offer enough to justify the loss of cross-cluster sort equivalence.

> Neither patch will exactly preserve the sort behavior of the current
> code, but I don't think that's important.

Agreed.

> --- 291,313 ----
> {
> FuncInfo *fobj1 = *(FuncInfo *const *) p1;
> FuncInfo *fobj2 = *(FuncInfo *const *) p2;
> + int i;
>
> cmpval = fobj1->nargs - fobj2->nargs;
> if (cmpval != 0)
> return cmpval;
> ! for (i = 0; i < fobj1->nargs; i++)
> ! {
> ! TypeInfo *argtype1 = findTypeByOid(fobj1->argtypes[i]);
> ! TypeInfo *argtype2 = findTypeByOid(fobj2->argtypes[i]);
> !
> ! if (argtype1 && argtype2)
> ! {
> ! cmpval = strcmp(argtype1->dobj.name, argtype2->dobj.name);
> ! if (cmpval != 0)
> ! return cmpval;
> ! }
> ! }

So as to stably compare f(nsp0.t) to f(nsp1.t), this should also compare the
dobj.namespace name.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Kyotaro HORIGUCHI 2015-03-06 08:33:41 Clamping reulst row number of joins.
Previous Message Marko Tiikkaja 2015-03-06 08:30:29 Re: Rethinking pg_dump's function sorting code