aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/formatting.c
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2000-09-25 12:58:47 +0000
committerBruce Momjian <bruce@momjian.us>2000-09-25 12:58:47 +0000
commitebdfac3bb115dfa6f77b851188de3c132f43d966 (patch)
tree865bee9d9c3eb245bbb4aac885ccb3ed6223981d /src/backend/utils/adt/formatting.c
parent516aac42f9eabfd227005797feceaf3dcadbf2f5 (diff)
downloadpostgresql-ebdfac3bb115dfa6f77b851188de3c132f43d966.tar.gz
postgresql-ebdfac3bb115dfa6f77b851188de3c132f43d966.zip
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
Diffstat (limited to 'src/backend/utils/adt/formatting.c')
-rw-r--r--src/backend/utils/adt/formatting.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c
index 8dcce7f1d90..748bb694d79 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); \
\