From ebdfac3bb115dfa6f77b851188de3c132f43d966 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Mon, 25 Sep 2000 12:58:47 +0000 Subject: the patch include: - rename ichar() to chr() (discussed with Tom) - add docs for oracle compatible routines: btrim() ascii() chr() repeat() - fix bug with timezone in to_char() - all to_char() variants return NULL instead textin("") if it's needful. The contrib/odbc is without changes and contains same routines as main tree ... because I not sure how plans are Thomas with this :-) Karel --------------------------------------------------------------------------- This effectively one line patch should fix the fact that foreign key definitions in create table were erroring if a primary key was defined. I was using the columns list to get the columns of the table for comparison, but it got reused as a temporary list inside the primary key stuff. Stephan Szabo --- src/backend/utils/adt/formatting.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'src/backend/utils/adt/formatting.c') diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c index 8dcce7f1d9..748bb694d7 100644 --- a/src/backend/utils/adt/formatting.c +++ b/src/backend/utils/adt/formatting.c @@ -1,7 +1,7 @@ /* ----------------------------------------------------------------------- * formatting.c * - * $Header: /cvsroot/pgsql/src/backend/utils/adt/formatting.c,v 1.21 2000/08/29 04:41:47 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/formatting.c,v 1.22 2000/09/25 12:58:47 momjian Exp $ * * * Portions Copyright (c) 1999-2000, PostgreSQL, Inc @@ -1742,7 +1742,7 @@ dch_time(int arg, char *inout, int suf, int flag, FormatNode *node) break; case DCH_tz: case DCH_TZ: - if (flag == TO_CHAR) + if (flag == TO_CHAR && tzn) { int siz = strlen(tzn); @@ -2452,7 +2452,7 @@ timestamp_to_char(PG_FUNCTION_ARGS) len = VARSIZE(fmt) - VARHDRSZ; if (len <= 0 || TIMESTAMP_NOT_FINITE(dt)) - return DirectFunctionCall1(textin, CStringGetDatum("")); + PG_RETURN_NULL(); ZERO_tm(tm); tzn = NULL; @@ -2552,7 +2552,12 @@ timestamp_to_char(PG_FUNCTION_ARGS) * needs, now it must be re-allocate to result real size * ---------- */ - len = strlen(VARDATA(result)); + if (!(len = strlen(VARDATA(result)))) + { + pfree(result); + PG_RETURN_NULL(); + } + result_tmp = result; result = (text *) palloc(len + 1 + VARHDRSZ); @@ -4017,12 +4022,17 @@ do { \ if (flag) \ pfree(format); \ \ - /* ---------- \ + /* ---------- \ * for result is allocated max memory, which current format-picture\ * needs, now it must be re-allocate to result real size \ * ---------- \ */ \ - len = strlen(VARDATA(result)); \ + if (!(len = strlen(VARDATA(result)))) \ + { \ + pfree(result); \ + PG_RETURN_NULL(); \ + } \ + \ result_tmp = result; \ result = (text *) palloc( len + 1 + VARHDRSZ); \ \ -- cgit v1.2.1