Re: [HACKERS] Open 7.1 items

Поиск
Список
Период
Сортировка
От Tatsuo Ishii
Тема Re: [HACKERS] Open 7.1 items
Дата
Msg-id 20010126072403D.t-ishii@sra.co.jp
обсуждение исходный текст
Ответ на Open 7.1 items  (Bruce Momjian <pgman@candle.pha.pa.us>)
Ответы Re: [HACKERS] Open 7.1 items
Список pgsql-jdbc
> Fix for pg_dump of bad system tables

Ok. I have made patches for fixing some of pg_dump problems(see
attached patches). The patches address the problem with user defined
functions, operators and aggregates. Could someone please review and
commit them if they look ok?  (I'm now in US and have only very
expensive internet connection through an international phone call to
Japan in a hotel! Also I'm not quite sure "#arg" (stringification) is
portable enough in all platforms.)  Or I could commit after going back
to Japan planned on Feb 2 if that's not too late.

However I have not address what Tom Lane said yet(actually I do not
understand what he says).

> The other flavor of problems that pg_dump
> has in this area are in doing inner joins across system catalogs ...
>
>             regards, tom lane

Index: common.c
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/bin/pg_dump/common.c,v
retrieving revision 1.49
diff -c -r1.49 common.c
*** common.c    2001/01/12 15:41:29    1.49
--- common.c    2001/01/21 01:38:48
***************
*** 86,95 ****
          }
      }

!     /* should never get here */
!     fprintf(stderr, "failed sanity check, type with oid %s was not found\n",
!             oid);
!     exit(2);
  }

  /*
--- 86,93 ----
          }
      }

!     /* no suitable type name was found */
!     return(NULL);
  }

  /*
***************
*** 114,120 ****
      /* should never get here */
      fprintf(stderr, "failed sanity check, opr with oid %s was not found\n",
              oid);
!     exit(2);
  }


--- 112,120 ----
      /* should never get here */
      fprintf(stderr, "failed sanity check, opr with oid %s was not found\n",
              oid);
!
!     /* no suitable operator name was found */
!     return(NULL);
  }


*** pg_dump.c.orig    Fri Jan 26 06:56:09 2001
--- pg_dump.c    Fri Jan 26 06:35:26 2001
***************
*** 2928,2933 ****
--- 2928,2942 ----
              char       *elemType;

              elemType = findTypeByOid(tinfo, numTypes, tinfo[i].typelem, zeroAsOpaque);
+             if (elemType == NULL)
+             {
+                 fprintf(stderr, "Notice: type for oid %s is not dumped.\n",
+                         tinfo[i].typelem);
+                 resetPQExpBuffer(q);
+                 resetPQExpBuffer(delq);
+                 continue;
+             }
+
              appendPQExpBuffer(q, ", element = %s, delimiter = ", elemType);
              formatStringLiteral(q, tinfo[i].typdelim);
          }
***************
*** 3086,3091 ****
--- 3095,3101 ----
      char        *listSep;
      char        *listSepComma = ",";
      char        *listSepNone = "";
+     char        *rettypename;

      if (finfo[i].dumped)
          return;
***************
*** 3147,3152 ****
--- 3157,3177 ----
          char            *typname;

          typname = findTypeByOid(tinfo, numTypes, finfo[i].argtypes[j], zeroAsOpaque);
+         if (typname == NULL)
+         {
+             fprintf(stderr, "Notice: function \"%s\" is not dumped.\n",
+                     finfo[i].proname);
+
+             fprintf(stderr, "Reason: the %d th argument type name (oid %s) not found.\n",
+                     j, finfo[i].argtypes[j]);
+             resetPQExpBuffer(q);
+             resetPQExpBuffer(fn);
+             resetPQExpBuffer(delqry);
+             resetPQExpBuffer(fnlist);
+             resetPQExpBuffer(asPart);
+             return;
+         }
+
          appendPQExpBuffer(fn, "%s%s",
                              (j > 0) ? "," : "",
                              typname);
***************
*** 3159,3169 ****
      resetPQExpBuffer(delqry);
      appendPQExpBuffer(delqry, "DROP FUNCTION %s;\n", fn->data );

      resetPQExpBuffer(q);
      appendPQExpBuffer(q, "CREATE FUNCTION %s ", fn->data );
      appendPQExpBuffer(q, "RETURNS %s%s %s LANGUAGE ",
                        (finfo[i].retset) ? "SETOF " : "",
!                       findTypeByOid(tinfo, numTypes, finfo[i].prorettype, zeroAsOpaque),
                        asPart->data);
      formatStringLiteral(q, func_lang);

--- 3184,3211 ----
      resetPQExpBuffer(delqry);
      appendPQExpBuffer(delqry, "DROP FUNCTION %s;\n", fn->data );

+     rettypename = findTypeByOid(tinfo, numTypes, finfo[i].prorettype, zeroAsOpaque);
+
+     if (rettypename == NULL)
+     {
+         fprintf(stderr, "Notice: function \"%s\" is not dumped.\n",
+                 finfo[i].proname);
+
+         fprintf(stderr, "Reason: return type name (oid %s) not found.\n",
+                 finfo[i].prorettype);
+             resetPQExpBuffer(q);
+             resetPQExpBuffer(fn);
+             resetPQExpBuffer(delqry);
+             resetPQExpBuffer(fnlist);
+             resetPQExpBuffer(asPart);
+             return;
+     }
+
      resetPQExpBuffer(q);
      appendPQExpBuffer(q, "CREATE FUNCTION %s ", fn->data );
      appendPQExpBuffer(q, "RETURNS %s%s %s LANGUAGE ",
                        (finfo[i].retset) ? "SETOF " : "",
!                       rettypename,
                        asPart->data);
      formatStringLiteral(q, func_lang);

***************
*** 3208,3213 ****
--- 3250,3261 ----
  dumpOprs(Archive *fout, OprInfo *oprinfo, int numOperators,
           TypeInfo *tinfo, int numTypes)
  {
+ #define OPR_NOTICE(arg) {\
+         fprintf(stderr, "Notice: operator \"%s\"(oid %s) is not dumped.\n",oprinfo[i].oprname, oprinfo[i].oid);\
+     fprintf(stderr, "Reason: " #arg);\
+     fprintf (stderr, " (oid %s) not found.\n",oprinfo[i].arg);\
+     }
+
      int            i;
      PQExpBuffer q = createPQExpBuffer();
      PQExpBuffer delq = createPQExpBuffer();
***************
*** 3222,3227 ****
--- 3270,3276 ----

      for (i = 0; i < numOperators; i++)
      {
+         char *name;

          resetPQExpBuffer(leftarg);
          resetPQExpBuffer(rightarg);
***************
*** 3250,3271 ****
          if (strcmp(oprinfo[i].oprkind, "r") == 0 ||
              strcmp(oprinfo[i].oprkind, "b") == 0)
          {
!             appendPQExpBuffer(leftarg, ",\n\tLEFTARG = %s ",
!                                 findTypeByOid(tinfo, numTypes, oprinfo[i].oprleft, zeroAsOpaque) );
          }
          if (strcmp(oprinfo[i].oprkind, "l") == 0 ||
              strcmp(oprinfo[i].oprkind, "b") == 0)
          {
!             appendPQExpBuffer(rightarg, ",\n\tRIGHTARG = %s ",
!                               findTypeByOid(tinfo, numTypes, oprinfo[i].oprright, zeroAsOpaque) );
          }
          if (!(strcmp(oprinfo[i].oprcom, "0") == 0))
!             appendPQExpBuffer(commutator, ",\n\tCOMMUTATOR = %s ",
!                  findOprByOid(oprinfo, numOperators, oprinfo[i].oprcom));

          if (!(strcmp(oprinfo[i].oprnegate, "0") == 0))
!             appendPQExpBuffer(negator, ",\n\tNEGATOR = %s ",
!               findOprByOid(oprinfo, numOperators, oprinfo[i].oprnegate));

          if (!(strcmp(oprinfo[i].oprrest, "-") == 0))
              appendPQExpBuffer(restrictor, ",\n\tRESTRICT = %s ", oprinfo[i].oprrest);
--- 3299,3348 ----
          if (strcmp(oprinfo[i].oprkind, "r") == 0 ||
              strcmp(oprinfo[i].oprkind, "b") == 0)
          {
!             name = findTypeByOid(tinfo, numTypes,
!                                   oprinfo[i].oprleft, zeroAsOpaque);
!             if (name == NULL)
!             {
!                 OPR_NOTICE(oprleft);
!                 continue;
!             }
!             appendPQExpBuffer(leftarg, ",\n\tLEFTARG = %s ",name);
          }
+
          if (strcmp(oprinfo[i].oprkind, "l") == 0 ||
              strcmp(oprinfo[i].oprkind, "b") == 0)
          {
!             name = findTypeByOid(tinfo, numTypes,
!                                   oprinfo[i].oprright, zeroAsOpaque);
!             if (name == NULL)
!             {
!                 OPR_NOTICE(oprright);
!                 continue;
!             }
!             appendPQExpBuffer(rightarg, ",\n\tRIGHTARG = %s ", name);
          }
+
          if (!(strcmp(oprinfo[i].oprcom, "0") == 0))
!         {
!             name = findOprByOid(oprinfo, numOperators, oprinfo[i].oprcom);
!             if (name == NULL)
!             {
!                 OPR_NOTICE(oprcom);
!                 continue;
!             }
!             appendPQExpBuffer(commutator, ",\n\tCOMMUTATOR = %s ", name);
!         }

          if (!(strcmp(oprinfo[i].oprnegate, "0") == 0))
!         {
!             name = findOprByOid(oprinfo, numOperators, oprinfo[i].oprnegate);
!             if (name == NULL)
!             {
!                 OPR_NOTICE(oprnegate);
!                 continue;
!             }
!             appendPQExpBuffer(negator, ",\n\tNEGATOR = %s ", name);
!         }

          if (!(strcmp(oprinfo[i].oprrest, "-") == 0))
              appendPQExpBuffer(restrictor, ",\n\tRESTRICT = %s ", oprinfo[i].oprrest);
***************
*** 3274,3285 ****
              appendPQExpBuffer(join, ",\n\tJOIN = %s ", oprinfo[i].oprjoin);

          if (!(strcmp(oprinfo[i].oprlsortop, "0") == 0))
!             appendPQExpBuffer(sort1, ",\n\tSORT1 = %s ",
!              findOprByOid(oprinfo, numOperators, oprinfo[i].oprlsortop));

          if (!(strcmp(oprinfo[i].oprrsortop, "0") == 0))
!             appendPQExpBuffer(sort2, ",\n\tSORT2 = %s ",
!              findOprByOid(oprinfo, numOperators, oprinfo[i].oprrsortop));

          resetPQExpBuffer(delq);
          appendPQExpBuffer(delq, "DROP OPERATOR %s (%s", oprinfo[i].oprname,
--- 3351,3376 ----
              appendPQExpBuffer(join, ",\n\tJOIN = %s ", oprinfo[i].oprjoin);

          if (!(strcmp(oprinfo[i].oprlsortop, "0") == 0))
!         {
!             name =     findOprByOid(oprinfo, numOperators, oprinfo[i].oprlsortop);
!             if (name == NULL)
!             {
!                 OPR_NOTICE(oprlsortop);
!                 continue;
!             }
!             appendPQExpBuffer(sort1, ",\n\tSORT1 = %s ", name);
!         }

          if (!(strcmp(oprinfo[i].oprrsortop, "0") == 0))
!         {
!             name =     findOprByOid(oprinfo, numOperators, oprinfo[i].oprrsortop);
!             if (name == NULL)
!             {
!                 OPR_NOTICE(oprrsortop);
!                 continue;
!             }
!             appendPQExpBuffer(sort2, ",\n\tSORT2 = %s ", name);
!         }

          resetPQExpBuffer(delq);
          appendPQExpBuffer(delq, "DROP OPERATOR %s (%s", oprinfo[i].oprname,
***************
*** 3317,3322 ****
--- 3408,3419 ----
  dumpAggs(Archive *fout, AggInfo *agginfo, int numAggs,
           TypeInfo *tinfo, int numTypes)
  {
+ #define AGG_NOTICE(arg) {\
+         fprintf(stderr, "Notice: aggregate \"%s\"(oid %s) is not dumped.\n",agginfo[i].aggname, agginfo[i].oid);\
+     fprintf(stderr, "Reason: " #arg);\
+     fprintf (stderr, " (oid %s) not found.\n",agginfo[i].arg);\
+     }
+
      int            i;
      PQExpBuffer q = createPQExpBuffer();
      PQExpBuffer delq = createPQExpBuffer();
***************
*** 3325,3344 ****

      for (i = 0; i < numAggs; i++)
      {
          resetPQExpBuffer(details);

          /* skip all the builtin oids */
          if (atooid(agginfo[i].oid) <= g_last_builtin_oid)
              continue;

!         appendPQExpBuffer(details,
!                           "BASETYPE = %s, ",
!                           findTypeByOid(tinfo, numTypes, agginfo[i].aggbasetype, zeroAsAny + useBaseTypeName));

          appendPQExpBuffer(details,
                            "SFUNC = %s, STYPE = %s",
!                           agginfo[i].aggtransfn,
!                           findTypeByOid(tinfo, numTypes, agginfo[i].aggtranstype, zeroAsOpaque + useBaseTypeName));

          if (agginfo[i].agginitval)
          {
--- 3422,3452 ----

      for (i = 0; i < numAggs; i++)
      {
+         char *name;
+
          resetPQExpBuffer(details);

          /* skip all the builtin oids */
          if (atooid(agginfo[i].oid) <= g_last_builtin_oid)
              continue;

!         name = findTypeByOid(tinfo, numTypes, agginfo[i].aggbasetype, zeroAsAny + useBaseTypeName);
!         if (name == NULL)
!         {
!             AGG_NOTICE(aggbasetype);
!             continue;
!         }
!         appendPQExpBuffer(details, "BASETYPE = %s, ", name);

+         name = findTypeByOid(tinfo, numTypes, agginfo[i].aggtranstype, zeroAsOpaque + useBaseTypeName);
+         if (name == NULL)
+         {
+             AGG_NOTICE(aggtranstype);
+             continue;
+         }
          appendPQExpBuffer(details,
                            "SFUNC = %s, STYPE = %s",
!                           agginfo[i].aggtransfn, name);

          if (agginfo[i].agginitval)
          {

В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Barry Lind
Дата:
Сообщение: Re: [BUGS] no way in LargeObject API to detect short read?
Следующее
От: aoki@acm.org (Paul M. Aoki)
Дата:
Сообщение: Re: Re: [BUGS] no way in LargeObject API to detect short read?