Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit faba9fa

Browse files
committed
pg_dump was trying to use an incorrect (or, perhaps, only obsolete?)
syntax for CREATE OPERATOR with SORT parameters. Fixed. It is now actually possible to dump and reload a database containing fully specified user-definable operators ...
1 parent 29e2916 commit faba9fa

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

src/bin/pg_dump/pg_dump.c

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
*
2222
*
2323
* IDENTIFICATION
24-
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.102 1999/02/13 23:20:23 momjian Exp $
24+
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.103 1999/04/14 23:47:19 tgl Exp $
2525
*
2626
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
2727
*
@@ -2321,7 +2321,8 @@ dumpOprs(FILE *fout, OprInfo *oprinfo, int numOperators,
23212321
char negator[MAXQUERYLEN];
23222322
char restrictor[MAXQUERYLEN];
23232323
char join[MAXQUERYLEN];
2324-
char sortop[MAXQUERYLEN];
2324+
char sort1[MAXQUERYLEN];
2325+
char sort2[MAXQUERYLEN];
23252326

23262327
for (i = 0; i < numOperators; i++)
23272328
{
@@ -2347,49 +2348,48 @@ dumpOprs(FILE *fout, OprInfo *oprinfo, int numOperators,
23472348
if (strcmp(oprinfo[i].oprkind, "r") == 0 ||
23482349
strcmp(oprinfo[i].oprkind, "b") == 0)
23492350
{
2350-
sprintf(leftarg, ", LEFTARG = %s ",
2351+
sprintf(leftarg, ",\n\tLEFTARG = %s ",
23512352
fmtId(findTypeByOid(tinfo, numTypes, oprinfo[i].oprleft), false));
23522353
}
23532354
if (strcmp(oprinfo[i].oprkind, "l") == 0 ||
23542355
strcmp(oprinfo[i].oprkind, "b") == 0)
23552356
{
2356-
sprintf(rightarg, ", RIGHTARG = %s ",
2357+
sprintf(rightarg, ",\n\tRIGHTARG = %s ",
23572358
fmtId(findTypeByOid(tinfo, numTypes, oprinfo[i].oprright), false));
23582359
}
23592360
if (strcmp(oprinfo[i].oprcom, "0") == 0)
23602361
commutator[0] = '\0';
23612362
else
2362-
sprintf(commutator, ", COMMUTATOR = %s ",
2363+
sprintf(commutator, ",\n\tCOMMUTATOR = %s ",
23632364
findOprByOid(oprinfo, numOperators, oprinfo[i].oprcom));
23642365

23652366
if (strcmp(oprinfo[i].oprnegate, "0") == 0)
23662367
negator[0] = '\0';
23672368
else
2368-
sprintf(negator, ", NEGATOR = %s ",
2369+
sprintf(negator, ",\n\tNEGATOR = %s ",
23692370
findOprByOid(oprinfo, numOperators, oprinfo[i].oprnegate));
23702371

23712372
if (strcmp(oprinfo[i].oprrest, "-") == 0)
23722373
restrictor[0] = '\0';
23732374
else
2374-
sprintf(restrictor, ", RESTRICT = %s ", oprinfo[i].oprrest);
2375+
sprintf(restrictor, ",\n\tRESTRICT = %s ", oprinfo[i].oprrest);
23752376

23762377
if (strcmp(oprinfo[i].oprjoin, "-") == 0)
23772378
join[0] = '\0';
23782379
else
2379-
sprintf(join, ", JOIN = %s ", oprinfo[i].oprjoin);
2380+
sprintf(join, ",\n\tJOIN = %s ", oprinfo[i].oprjoin);
23802381

23812382
if (strcmp(oprinfo[i].oprlsortop, "0") == 0)
2382-
sortop[0] = '\0';
2383+
sort1[0] = '\0';
23832384
else
2384-
{
2385-
sprintf(sortop, ", SORT = %s ",
2386-
findOprByOid(oprinfo, numOperators,
2387-
oprinfo[i].oprlsortop));
2388-
if (strcmp(oprinfo[i].oprrsortop, "0") != 0)
2389-
sprintf(sortop, "%s , %s", sortop,
2390-
findOprByOid(oprinfo, numOperators,
2391-
oprinfo[i].oprlsortop));
2392-
}
2385+
sprintf(sort1, ",\n\tSORT1 = %s ",
2386+
findOprByOid(oprinfo, numOperators, oprinfo[i].oprlsortop));
2387+
2388+
if (strcmp(oprinfo[i].oprrsortop, "0") == 0)
2389+
sort2[0] = '\0';
2390+
else
2391+
sprintf(sort2, ",\n\tSORT2 = %s ",
2392+
findOprByOid(oprinfo, numOperators, oprinfo[i].oprrsortop));
23932393

23942394
becomeUser(fout, oprinfo[i].usename);
23952395

@@ -2403,17 +2403,18 @@ dumpOprs(FILE *fout, OprInfo *oprinfo, int numOperators,
24032403

24042404
sprintf(q,
24052405
"CREATE OPERATOR %s "
2406-
"(PROCEDURE = %s %s %s %s %s %s %s %s %s);\n ",
2406+
"(PROCEDURE = %s %s%s%s%s%s%s%s%s%s);\n",
24072407
oprinfo[i].oprname,
24082408
oprinfo[i].oprcode,
24092409
leftarg,
24102410
rightarg,
24112411
commutator,
24122412
negator,
24132413
restrictor,
2414-
(strcmp(oprinfo[i].oprcanhash, "t") == 0) ? ", HASHES" : "",
2414+
(strcmp(oprinfo[i].oprcanhash, "t") == 0) ? ",\n\tHASHES" : "",
24152415
join,
2416-
sortop);
2416+
sort1,
2417+
sort2);
24172418

24182419
fputs(q, fout);
24192420
}

0 commit comments

Comments
 (0)