diff -Naur pg_dump_orig/pg_backup_archiver.h pg_dump_122/pg_backup_archiver.h --- pg_dump_orig/pg_backup_archiver.h Mon Jul 10 11:46:40 2000 +++ pg_dump_122/pg_backup_archiver.h Mon Jul 10 11:57:39 2000 @@ -54,7 +54,7 @@ #define K_VERS_MAJOR 1 #define K_VERS_MINOR 2 -#define K_VERS_REV 1 +#define K_VERS_REV 2 /* Some important version numbers (checked in code) */ #define K_VERS_1_0 (( (1 * 256 + 0) * 256 + 0) * 256 + 0) diff -Naur pg_dump_orig/pg_dump.c pg_dump_122/pg_dump.c --- pg_dump_orig/pg_dump.c Mon Jul 10 11:46:40 2000 +++ pg_dump_122/pg_dump.c Mon Jul 10 11:49:04 2000 @@ -2684,8 +2684,8 @@ PQExpBuffer fn = createPQExpBuffer(); PQExpBuffer delqry = createPQExpBuffer(); PQExpBuffer fnlist = createPQExpBuffer(); + PQExpBuffer asPart = createPQExpBuffer(); int j; - char *func_def; char func_lang[NAMEDATALEN + 1]; PGresult *res; int nlangs; @@ -2717,8 +2717,24 @@ } i_lanname = PQfnumber(res, "lanname"); - - func_def = finfo[i].prosrc; + + /* + * See backend/commands/define.c for details of how the 'AS' clause + * is used. + */ + if (strcmp(finfo[i].probin, "-") != 0) + { + if (strcmp(finfo[i].prosrc, "-") != 0) + appendPQExpBuffer(asPart, "AS '%s', '%s'", finfo[i].probin, finfo[i].prosrc); + else + appendPQExpBuffer(asPart, "AS '%s'", finfo[i].probin); + } + else + { + if (strcmp(finfo[i].prosrc, "-") != 0) + appendPQExpBuffer(asPart, "AS '%s'", finfo[i].prosrc); + } + strcpy(func_lang, PQgetvalue(res, 0, i_lanname)); PQclear(res); @@ -2744,10 +2760,10 @@ resetPQExpBuffer(q); appendPQExpBuffer(q, "CREATE FUNCTION %s ", fn->data ); - appendPQExpBuffer(q, "RETURNS %s%s AS '%s' LANGUAGE '%s';\n", + appendPQExpBuffer(q, "RETURNS %s%s %s LANGUAGE '%s';\n", (finfo[i].retset) ? " SETOF " : "", fmtId(findTypeByOid(tinfo, numTypes, finfo[i].prorettype), false), - func_def, func_lang); + asPart->data, func_lang); ArchiveEntry(fout, finfo[i].oid, fn->data, "FUNCTION", NULL, q->data, delqry->data, finfo[i].usename, NULL, NULL);