diff options
| author | Bruce Momjian <bruce@momjian.us> | 2000-09-25 12:58:47 +0000 |
|---|---|---|
| committer | Bruce Momjian <bruce@momjian.us> | 2000-09-25 12:58:47 +0000 |
| commit | ebdfac3bb115dfa6f77b851188de3c132f43d966 (patch) | |
| tree | 865bee9d9c3eb245bbb4aac885ccb3ed6223981d /src/backend/utils/adt/oracle_compat.c | |
| parent | 516aac42f9eabfd227005797feceaf3dcadbf2f5 (diff) | |
| download | postgresql-ebdfac3bb115dfa6f77b851188de3c132f43d966.tar.gz | |
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/oracle_compat.c')
| -rw-r--r-- | src/backend/utils/adt/oracle_compat.c | 62 |
1 files changed, 51 insertions, 11 deletions
diff --git a/src/backend/utils/adt/oracle_compat.c b/src/backend/utils/adt/oracle_compat.c index db49f7d9e8..8b483ee5c6 100644 --- a/src/backend/utils/adt/oracle_compat.c +++ b/src/backend/utils/adt/oracle_compat.c @@ -1,7 +1,7 @@ /* * Edmund Mergl <E.Mergl@bawue.de> * - * $Header: /cvsroot/pgsql/src/backend/utils/adt/oracle_compat.c,v 1.27 2000/07/06 05:48:11 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/oracle_compat.c,v 1.28 2000/09/25 12:58:47 momjian Exp $ * */ @@ -515,6 +515,20 @@ translate(PG_FUNCTION_ARGS) PG_RETURN_TEXT_P(result); } +/******************************************************************** + * + * ascii + * + * Syntax: + * + * int ascii(text string) + * + * Purpose: + * + * Returns the decimal representation of the first character from + * string. + * + ********************************************************************/ Datum ascii(PG_FUNCTION_ARGS) @@ -527,12 +541,25 @@ ascii(PG_FUNCTION_ARGS) PG_RETURN_INT32((int32) *((unsigned char *) VARDATA(string))); } +/******************************************************************** + * + * chr + * + * Syntax: + * + * text chr(int val) + * + * Purpose: + * + * Returns the character having the binary equivalent to val + * + ********************************************************************/ Datum -ichar(PG_FUNCTION_ARGS) +chr(PG_FUNCTION_ARGS) { - int32 cvalue = PG_GETARG_INT32(0); - text *result; + int32 cvalue = PG_GETARG_INT32(0); + text *result; result = (text *) palloc(VARHDRSZ + 1); VARATT_SIZEP(result) = VARHDRSZ + 1; @@ -541,17 +568,30 @@ ichar(PG_FUNCTION_ARGS) PG_RETURN_TEXT_P(result); } +/******************************************************************** + * + * repeat + * + * Syntax: + * + * text repeat(text string, int val) + * + * Purpose: + * + * Repeat string by val. + * + ********************************************************************/ Datum repeat(PG_FUNCTION_ARGS) { - text *string = PG_GETARG_TEXT_P(0); - int32 count = PG_GETARG_INT32(1); - text *result; - int slen, - tlen; - int i; - char *cp; + text *string = PG_GETARG_TEXT_P(0); + int32 count = PG_GETARG_INT32(1); + text *result; + int slen, + tlen; + int i; + char *cp; if (count < 0) count = 0; |
