Обсуждение: 7.3.3 array_out tweak

Поиск
Список
Период
Сортировка

7.3.3 array_out tweak

От
Thien-Thi Nguyen
Дата:
greetings,

regarding previous grousing regarding array output not being
consistently quoted, what do you think of the following patch?
it jams `nq' when the `typbyval' is not `true' on the presumption
that typbyval is a good way to distinguish numeric/non-numeric.
perhaps there is an even more direct way to discern this?

thi

___________________________________________
cd ~/local/src/postgresql-7.3.3
diff -c src/backend/utils/adt/arrayfuncs.c.ORIG src/backend/utils/adt/arrayfuncs.c
*** src/backend/utils/adt/arrayfuncs.c.ORIG    Mon Jul 28 13:16:54 2003
--- src/backend/utils/adt/arrayfuncs.c    Mon Jul 28 13:17:39 2003
***************
*** 663,669 ****
          p = (char *) att_align(p, typalign);

          /* count data plus backslashes; detect chars needing quotes */
!         nq = (values[i][0] == '\0');    /* force quotes for empty string */
          for (tmp = values[i]; *tmp; tmp++)
          {
              char        ch = *tmp;
--- 663,670 ----
          p = (char *) att_align(p, typalign);

          /* count data plus backslashes; detect chars needing quotes */
!         nq = (values[i][0] == '\0'      /* force quotes for empty string */
!               || typbyval != true);     /* or when not by-value */
          for (tmp = values[i]; *tmp; tmp++)
          {
              char        ch = *tmp;

Diff finished at Mon Jul 28 13:36:12

Re: 7.3.3 array_out tweak

От
Tom Lane
Дата:
Thien-Thi Nguyen <ttn@glug.org> writes:
> regarding previous grousing regarding array output not being
> consistently quoted, what do you think of the following patch?
> it jams `nq' when the `typbyval' is not `true' on the presumption
> that typbyval is a good way to distinguish numeric/non-numeric.

That was what the pre-7.2 coding did, and it was broken.  Types abstime
and "char" are counterexamples in one direction, and float8 and numeric
are counterexamples in the other.  (And that's not even considering
user-defined datatypes.)  We are not going back to that.

            regards, tom lane

Re: 7.3.3 array_out tweak

От
Thien-Thi Nguyen
Дата:
   Date: Mon, 28 Jul 2003 10:11:52 -0400
   From: Tom Lane <tgl@sss.pgh.pa.us>

   That was what the pre-7.2 coding did, and it was broken.  Types abstime
   and "char" are counterexamples in one direction, and float8 and numeric
   are counterexamples in the other.  (And that's not even considering
   user-defined datatypes.)  We are not going back to that.

ok, thanks for the concise summary.  i will try to think of another
approach to achieve this kind of consistency for array output.

thi