1
0
mirror of https://github.com/postgres/postgres.git synced 2025-10-28 11:55:03 +03:00

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
This commit is contained in:
Bruce Momjian
2000-09-25 12:58:47 +00:00
parent 516aac42f9
commit ebdfac3bb1
5 changed files with 102 additions and 28 deletions

View File

@@ -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;