mirror of
https://github.com/postgres/postgres.git
synced 2025-06-01 00:01:20 -04:00
oracle_compat.c fixed for function overloading...
By: From: Edmund Mergl <mergl@nadia.s.bawue.de>
This commit is contained in:
parent
5ea01d62ef
commit
4b4ac7c159
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Edmund Mergl <E.Mergl@bawue.de>
|
* Edmund Mergl <E.Mergl@bawue.de>
|
||||||
*
|
*
|
||||||
* $Id: oracle_compat.c,v 1.4 1997/03/16 01:17:49 scrappy Exp $
|
* $Id: oracle_compat.c,v 1.5 1997/03/16 20:40:39 scrappy Exp $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -10,13 +10,24 @@
|
|||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
|
|
||||||
|
|
||||||
|
text *lower(text *string);
|
||||||
|
text *upper(text *string);
|
||||||
|
text *initcap(text *string);
|
||||||
|
text *lpad(text *string1, int4 len, text *string2);
|
||||||
|
text *rpad(text *string1, int4 len, text *string2);
|
||||||
|
text *ltrim(text *string, text *set);
|
||||||
|
text *rtrim(text *string, text *set);
|
||||||
|
text *substr(text *string, int4 m, int4 n);
|
||||||
|
text *translate(text *string, char from, char to);
|
||||||
|
|
||||||
|
|
||||||
/********************************************************************
|
/********************************************************************
|
||||||
*
|
*
|
||||||
* LOWER
|
* lower
|
||||||
*
|
*
|
||||||
* Syntax:
|
* Syntax:
|
||||||
*
|
*
|
||||||
* text *LOWER(text *string)
|
* text *lower(text *string)
|
||||||
*
|
*
|
||||||
* Purpose:
|
* Purpose:
|
||||||
*
|
*
|
||||||
@ -25,7 +36,7 @@
|
|||||||
********************************************************************/
|
********************************************************************/
|
||||||
|
|
||||||
text *
|
text *
|
||||||
LOWER(text *string)
|
lower(text *string)
|
||||||
{
|
{
|
||||||
text *ret;
|
text *ret;
|
||||||
char *ptr, *ptr_ret;
|
char *ptr, *ptr_ret;
|
||||||
@ -37,7 +48,7 @@ LOWER(text *string)
|
|||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = (text *)malloc(VARSIZE(string));
|
ret = (text *)palloc(VARSIZE(string));
|
||||||
VARSIZE(ret) = VARSIZE(string);
|
VARSIZE(ret) = VARSIZE(string);
|
||||||
|
|
||||||
ptr = VARDATA(string);
|
ptr = VARDATA(string);
|
||||||
@ -53,11 +64,11 @@ LOWER(text *string)
|
|||||||
|
|
||||||
/********************************************************************
|
/********************************************************************
|
||||||
*
|
*
|
||||||
* UPPER
|
* upper
|
||||||
*
|
*
|
||||||
* Syntax:
|
* Syntax:
|
||||||
*
|
*
|
||||||
* text *UPPER(text *string)
|
* text *upper(text *string)
|
||||||
*
|
*
|
||||||
* Purpose:
|
* Purpose:
|
||||||
*
|
*
|
||||||
@ -66,7 +77,7 @@ LOWER(text *string)
|
|||||||
********************************************************************/
|
********************************************************************/
|
||||||
|
|
||||||
text *
|
text *
|
||||||
UPPER(text *string)
|
upper(text *string)
|
||||||
{
|
{
|
||||||
text *ret;
|
text *ret;
|
||||||
char *ptr, *ptr_ret;
|
char *ptr, *ptr_ret;
|
||||||
@ -78,7 +89,7 @@ UPPER(text *string)
|
|||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = (text *)malloc(VARSIZE(string));
|
ret = (text *)palloc(VARSIZE(string));
|
||||||
VARSIZE(ret) = VARSIZE(string);
|
VARSIZE(ret) = VARSIZE(string);
|
||||||
|
|
||||||
ptr = VARDATA(string);
|
ptr = VARDATA(string);
|
||||||
@ -94,11 +105,11 @@ UPPER(text *string)
|
|||||||
|
|
||||||
/********************************************************************
|
/********************************************************************
|
||||||
*
|
*
|
||||||
* INITCAP
|
* initcap
|
||||||
*
|
*
|
||||||
* Syntax:
|
* Syntax:
|
||||||
*
|
*
|
||||||
* text *INITCAP(text *string)
|
* text *initcap(text *string)
|
||||||
*
|
*
|
||||||
* Purpose:
|
* Purpose:
|
||||||
*
|
*
|
||||||
@ -109,7 +120,7 @@ UPPER(text *string)
|
|||||||
********************************************************************/
|
********************************************************************/
|
||||||
|
|
||||||
text *
|
text *
|
||||||
INITCAP(text *string)
|
initcap(text *string)
|
||||||
{
|
{
|
||||||
text *ret;
|
text *ret;
|
||||||
char *ptr, *ptr_ret;
|
char *ptr, *ptr_ret;
|
||||||
@ -121,7 +132,7 @@ INITCAP(text *string)
|
|||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = (text *)malloc(VARSIZE(string));
|
ret = (text *)palloc(VARSIZE(string));
|
||||||
VARSIZE(ret) = VARSIZE(string);
|
VARSIZE(ret) = VARSIZE(string);
|
||||||
|
|
||||||
ptr = VARDATA(string);
|
ptr = VARDATA(string);
|
||||||
@ -144,11 +155,11 @@ INITCAP(text *string)
|
|||||||
|
|
||||||
/********************************************************************
|
/********************************************************************
|
||||||
*
|
*
|
||||||
* LPAD
|
* lpad
|
||||||
*
|
*
|
||||||
* Syntax:
|
* Syntax:
|
||||||
*
|
*
|
||||||
* text *LPAD(text *string1, int4 len, text *string2)
|
* text *lpad(text *string1, int4 len, text *string2)
|
||||||
*
|
*
|
||||||
* Purpose:
|
* Purpose:
|
||||||
*
|
*
|
||||||
@ -158,7 +169,7 @@ INITCAP(text *string)
|
|||||||
********************************************************************/
|
********************************************************************/
|
||||||
|
|
||||||
text *
|
text *
|
||||||
LPAD(text *string1, int4 len, text *string2)
|
lpad(text *string1, int4 len, text *string2)
|
||||||
{
|
{
|
||||||
text *ret;
|
text *ret;
|
||||||
char *ptr1, *ptr2, *ptr_ret;
|
char *ptr1, *ptr2, *ptr_ret;
|
||||||
@ -170,7 +181,7 @@ LPAD(text *string1, int4 len, text *string2)
|
|||||||
return string1;
|
return string1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = (text *)malloc(VARHDRSZ + len);
|
ret = (text *)palloc(VARHDRSZ + len);
|
||||||
VARSIZE(ret) = VARHDRSZ + len;
|
VARSIZE(ret) = VARHDRSZ + len;
|
||||||
|
|
||||||
ptr2 = VARDATA(string2);
|
ptr2 = VARDATA(string2);
|
||||||
@ -194,11 +205,11 @@ LPAD(text *string1, int4 len, text *string2)
|
|||||||
|
|
||||||
/********************************************************************
|
/********************************************************************
|
||||||
*
|
*
|
||||||
* RPAD
|
* rpad
|
||||||
*
|
*
|
||||||
* Syntax:
|
* Syntax:
|
||||||
*
|
*
|
||||||
* text *RPAD(text *string1, int4 len, text *string2)
|
* text *rpad(text *string1, int4 len, text *string2)
|
||||||
*
|
*
|
||||||
* Purpose:
|
* Purpose:
|
||||||
*
|
*
|
||||||
@ -208,7 +219,7 @@ LPAD(text *string1, int4 len, text *string2)
|
|||||||
********************************************************************/
|
********************************************************************/
|
||||||
|
|
||||||
text *
|
text *
|
||||||
RPAD(text *string1, int4 len, text *string2)
|
rpad(text *string1, int4 len, text *string2)
|
||||||
{
|
{
|
||||||
text *ret;
|
text *ret;
|
||||||
char *ptr1, *ptr2, *ptr_ret;
|
char *ptr1, *ptr2, *ptr_ret;
|
||||||
@ -220,7 +231,7 @@ RPAD(text *string1, int4 len, text *string2)
|
|||||||
return string1;
|
return string1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = (text *)malloc(VARHDRSZ + len);
|
ret = (text *)palloc(VARHDRSZ + len);
|
||||||
VARSIZE(ret) = VARHDRSZ + len;
|
VARSIZE(ret) = VARHDRSZ + len;
|
||||||
|
|
||||||
n = VARSIZE(string1) - VARHDRSZ;
|
n = VARSIZE(string1) - VARHDRSZ;
|
||||||
@ -244,11 +255,11 @@ RPAD(text *string1, int4 len, text *string2)
|
|||||||
|
|
||||||
/********************************************************************
|
/********************************************************************
|
||||||
*
|
*
|
||||||
* LTRIM
|
* ltrim
|
||||||
*
|
*
|
||||||
* Syntax:
|
* Syntax:
|
||||||
*
|
*
|
||||||
* text *LTRIM(text *string, text *set)
|
* text *ltrim(text *string, text *set)
|
||||||
*
|
*
|
||||||
* Purpose:
|
* Purpose:
|
||||||
*
|
*
|
||||||
@ -258,7 +269,7 @@ RPAD(text *string1, int4 len, text *string2)
|
|||||||
********************************************************************/
|
********************************************************************/
|
||||||
|
|
||||||
text *
|
text *
|
||||||
LTRIM(text *string, text *set)
|
ltrim(text *string, text *set)
|
||||||
{
|
{
|
||||||
text *ret;
|
text *ret;
|
||||||
char *ptr, *ptr2, *end2, *ptr_ret;
|
char *ptr, *ptr2, *end2, *ptr_ret;
|
||||||
@ -290,7 +301,7 @@ LTRIM(text *string, text *set)
|
|||||||
|
|
||||||
++m;
|
++m;
|
||||||
|
|
||||||
ret = (text *)malloc(VARHDRSZ + m);
|
ret = (text *)palloc(VARHDRSZ + m);
|
||||||
VARSIZE(ret) = VARHDRSZ + m;
|
VARSIZE(ret) = VARHDRSZ + m;
|
||||||
|
|
||||||
ptr_ret = VARDATA(ret);
|
ptr_ret = VARDATA(ret);
|
||||||
@ -305,11 +316,11 @@ LTRIM(text *string, text *set)
|
|||||||
|
|
||||||
/********************************************************************
|
/********************************************************************
|
||||||
*
|
*
|
||||||
* RTRIM
|
* rtrim
|
||||||
*
|
*
|
||||||
* Syntax:
|
* Syntax:
|
||||||
*
|
*
|
||||||
* text *RTRIM(text *string, text *set)
|
* text *rtrim(text *string, text *set)
|
||||||
*
|
*
|
||||||
* Purpose:
|
* Purpose:
|
||||||
*
|
*
|
||||||
@ -319,7 +330,7 @@ LTRIM(text *string, text *set)
|
|||||||
********************************************************************/
|
********************************************************************/
|
||||||
|
|
||||||
text *
|
text *
|
||||||
RTRIM(text *string, text *set)
|
rtrim(text *string, text *set)
|
||||||
{
|
{
|
||||||
text *ret;
|
text *ret;
|
||||||
char *ptr, *ptr2, *end2, *ptr_ret;
|
char *ptr, *ptr2, *end2, *ptr_ret;
|
||||||
@ -351,299 +362,7 @@ RTRIM(text *string, text *set)
|
|||||||
|
|
||||||
++m;
|
++m;
|
||||||
|
|
||||||
ret = (text *)malloc(VARHDRSZ + m);
|
ret = (text *)palloc(VARHDRSZ + m);
|
||||||
VARSIZE(ret) = VARHDRSZ + m;
|
|
||||||
|
|
||||||
ptr_ret = VARDATA(ret) + m - 1;
|
|
||||||
|
|
||||||
while (m--) {
|
|
||||||
*ptr_ret-- = *ptr--;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/********************************************************************
|
|
||||||
*
|
|
||||||
* SUBSTR
|
|
||||||
*
|
|
||||||
* Syntax:
|
|
||||||
*
|
|
||||||
* text *SUBSTR(text *string, int4 m, int4 n)
|
|
||||||
*
|
|
||||||
* Purpose:
|
|
||||||
*
|
|
||||||
* Returns a portion of string, beginning at character m, n
|
|
||||||
* characters long. The first position of string is 1.
|
|
||||||
*
|
|
||||||
********************************************************************/
|
|
||||||
|
|
||||||
text *
|
|
||||||
SUBSTR(text *string, int4 m, int4 n)
|
|
||||||
{
|
|
||||||
text *ret;
|
|
||||||
char *ptr, *ptr_ret;
|
|
||||||
int len;
|
|
||||||
|
|
||||||
len = VARSIZE(string) - VARHDRSZ - m;
|
|
||||||
|
|
||||||
if (m <= 0 || n <= 0 || len <= 0) {
|
|
||||||
return string;
|
|
||||||
}
|
|
||||||
|
|
||||||
len = len + 1 < n ? len + 1 : n;
|
|
||||||
|
|
||||||
ret = (text *)malloc(VARHDRSZ + len);
|
|
||||||
VARSIZE(ret) = VARHDRSZ + len;
|
|
||||||
|
|
||||||
ptr = VARDATA(string) + m - 1;
|
|
||||||
ptr_ret = VARDATA(ret);
|
|
||||||
|
|
||||||
while (len--) {
|
|
||||||
*ptr_ret++ = *ptr++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/********************************************************************
|
|
||||||
*
|
|
||||||
* TRANSLATE
|
|
||||||
*
|
|
||||||
* Syntax:
|
|
||||||
*
|
|
||||||
* text *TRANSLATE(text *string, char from, char to)
|
|
||||||
*
|
|
||||||
* Purpose:
|
|
||||||
*
|
|
||||||
* Returns string after replacing all occurences of from with
|
|
||||||
* the corresponding character in to. TRANSLATE will not remove
|
|
||||||
* characters.
|
|
||||||
*
|
|
||||||
********************************************************************/
|
|
||||||
|
|
||||||
text *
|
|
||||||
TRANSLATE(text *string, char from, char to)
|
|
||||||
{
|
|
||||||
text *ret;
|
|
||||||
char *ptr, *ptr_ret;
|
|
||||||
int m;
|
|
||||||
|
|
||||||
m = VARSIZE(string) - VARHDRSZ;
|
|
||||||
|
|
||||||
if (m <= 0) {
|
|
||||||
return string;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = (text *)malloc(VARSIZE(string));
|
|
||||||
VARSIZE(ret) = VARSIZE(string);
|
|
||||||
|
|
||||||
ptr = VARDATA(string);
|
|
||||||
ptr_ret = VARDATA(ret);
|
|
||||||
|
|
||||||
while (m--) {
|
|
||||||
*ptr_ret++ = *ptr == from ? to : *ptr;
|
|
||||||
ptr++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
|
|
||||||
/********************************************************************
|
|
||||||
*
|
|
||||||
* Functions in lower case are the equivalents with the last
|
|
||||||
* parameter beeing set to a reasonable default.
|
|
||||||
*
|
|
||||||
********************************************************************/
|
|
||||||
|
|
||||||
|
|
||||||
/********************************************************************
|
|
||||||
*
|
|
||||||
* lpad
|
|
||||||
*
|
|
||||||
* Syntax:
|
|
||||||
*
|
|
||||||
* text *lpad(text *string1, int4 len)
|
|
||||||
*
|
|
||||||
* Purpose:
|
|
||||||
*
|
|
||||||
* Returns string1, left-padded to length len with blanks.
|
|
||||||
*
|
|
||||||
********************************************************************/
|
|
||||||
|
|
||||||
text *
|
|
||||||
lpad(text *string1, int4 len)
|
|
||||||
{
|
|
||||||
text *ret;
|
|
||||||
char *ptr1, *ptr_ret;
|
|
||||||
int m, n;
|
|
||||||
|
|
||||||
m = len - VARSIZE(string1) + VARHDRSZ;
|
|
||||||
|
|
||||||
if (m <= 0) {
|
|
||||||
return string1;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = (text *)malloc(VARHDRSZ + len);
|
|
||||||
VARSIZE(ret) = VARHDRSZ + len;
|
|
||||||
|
|
||||||
ptr_ret = VARDATA(ret);
|
|
||||||
|
|
||||||
while (m--) {
|
|
||||||
*ptr_ret++ = ' ';
|
|
||||||
}
|
|
||||||
|
|
||||||
n = VARSIZE(string1) - VARHDRSZ;
|
|
||||||
ptr1 = VARDATA(string1);
|
|
||||||
|
|
||||||
while (n--) {
|
|
||||||
*ptr_ret++ = *ptr1++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/********************************************************************
|
|
||||||
*
|
|
||||||
* rpad
|
|
||||||
*
|
|
||||||
* Syntax:
|
|
||||||
*
|
|
||||||
* text *rpad(text *string1, int4 len)
|
|
||||||
*
|
|
||||||
* Purpose:
|
|
||||||
*
|
|
||||||
* Returns string1, right-padded to length len with blanks.
|
|
||||||
*
|
|
||||||
********************************************************************/
|
|
||||||
|
|
||||||
text *
|
|
||||||
rpad(text *string1, int4 len)
|
|
||||||
{
|
|
||||||
text *ret;
|
|
||||||
char *ptr1, *ptr_ret;
|
|
||||||
int m, n;
|
|
||||||
|
|
||||||
m = len - VARSIZE(string1) + VARHDRSZ;
|
|
||||||
|
|
||||||
if (m <= 0) {
|
|
||||||
return string1;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = (text *)malloc(VARHDRSZ + len);
|
|
||||||
VARSIZE(ret) = VARHDRSZ + len;
|
|
||||||
|
|
||||||
n = VARSIZE(string1) - VARHDRSZ;
|
|
||||||
ptr1 = VARDATA(string1);
|
|
||||||
ptr_ret = VARDATA(ret);
|
|
||||||
|
|
||||||
while (n--) {
|
|
||||||
*ptr_ret++ = *ptr1++;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (m--) {
|
|
||||||
*ptr_ret++ = ' ';
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/********************************************************************
|
|
||||||
*
|
|
||||||
* ltrim
|
|
||||||
*
|
|
||||||
* Syntax:
|
|
||||||
*
|
|
||||||
* text *ltrim(text *string)
|
|
||||||
*
|
|
||||||
* Purpose:
|
|
||||||
*
|
|
||||||
* Returns string with initial blanks removed.
|
|
||||||
*
|
|
||||||
********************************************************************/
|
|
||||||
|
|
||||||
text *
|
|
||||||
ltrim(text *string)
|
|
||||||
{
|
|
||||||
text *ret;
|
|
||||||
char *ptr, *ptr_ret;
|
|
||||||
int m;
|
|
||||||
|
|
||||||
m = VARSIZE(string) - VARHDRSZ;
|
|
||||||
|
|
||||||
if (m <= 0) {
|
|
||||||
return string;
|
|
||||||
}
|
|
||||||
|
|
||||||
ptr = VARDATA(string);
|
|
||||||
|
|
||||||
while (m--) {
|
|
||||||
if (*ptr != ' ') {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
++ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
++m;
|
|
||||||
|
|
||||||
ret = (text *)malloc(VARHDRSZ + m);
|
|
||||||
VARSIZE(ret) = VARHDRSZ + m;
|
|
||||||
|
|
||||||
ptr_ret = VARDATA(ret);
|
|
||||||
|
|
||||||
while (m--) {
|
|
||||||
*ptr_ret++ = *ptr++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/********************************************************************
|
|
||||||
*
|
|
||||||
* rtrim
|
|
||||||
*
|
|
||||||
* Syntax:
|
|
||||||
*
|
|
||||||
* text *rtrim(text *string)
|
|
||||||
*
|
|
||||||
* Purpose:
|
|
||||||
*
|
|
||||||
* Returns string with final blanks removed.
|
|
||||||
*
|
|
||||||
********************************************************************/
|
|
||||||
|
|
||||||
text *
|
|
||||||
rtrim(text *string)
|
|
||||||
{
|
|
||||||
text *ret;
|
|
||||||
char *ptr, *ptr_ret;
|
|
||||||
int m;
|
|
||||||
|
|
||||||
m = VARSIZE(string) - VARHDRSZ;
|
|
||||||
|
|
||||||
if (m <= 0) {
|
|
||||||
return string;
|
|
||||||
}
|
|
||||||
|
|
||||||
ptr = VARDATA(string) + VARSIZE(string) - VARHDRSZ - 1;
|
|
||||||
|
|
||||||
while (m--) {
|
|
||||||
if (*ptr != ' ') {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
--ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
++m;
|
|
||||||
|
|
||||||
ret = (text *)malloc(VARHDRSZ + m);
|
|
||||||
VARSIZE(ret) = VARHDRSZ + m;
|
VARSIZE(ret) = VARHDRSZ + m;
|
||||||
|
|
||||||
ptr_ret = VARDATA(ret) + m - 1;
|
ptr_ret = VARDATA(ret) + m - 1;
|
||||||
@ -662,17 +381,17 @@ rtrim(text *string)
|
|||||||
*
|
*
|
||||||
* Syntax:
|
* Syntax:
|
||||||
*
|
*
|
||||||
* text *substr(text *string, int4 m)
|
* text *substr(text *string, int4 m, int4 n)
|
||||||
*
|
*
|
||||||
* Purpose:
|
* Purpose:
|
||||||
*
|
*
|
||||||
* Returns a portion of string, beginning at character m, up to
|
* Returns a portion of string, beginning at character m, n
|
||||||
* the end of string. The first position of string is 1.
|
* characters long. The first position of string is 1.
|
||||||
*
|
*
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
|
|
||||||
text *
|
text *
|
||||||
substr(text *string, int4 m)
|
substr(text *string, int4 m, int4 n)
|
||||||
{
|
{
|
||||||
text *ret;
|
text *ret;
|
||||||
char *ptr, *ptr_ret;
|
char *ptr, *ptr_ret;
|
||||||
@ -680,17 +399,17 @@ substr(text *string, int4 m)
|
|||||||
|
|
||||||
len = VARSIZE(string) - VARHDRSZ - m;
|
len = VARSIZE(string) - VARHDRSZ - m;
|
||||||
|
|
||||||
if (m <= 0 || len <= 0) {
|
if (m <= 0 || n <= 0 || len <= 0) {
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
len = len + 1;
|
len = len + 1 < n ? len + 1 : n;
|
||||||
|
|
||||||
ret = (text *)malloc(VARHDRSZ + len);
|
ret = (text *)palloc(VARHDRSZ + len);
|
||||||
VARSIZE(ret) = VARHDRSZ + len;
|
VARSIZE(ret) = VARHDRSZ + len;
|
||||||
|
|
||||||
ptr = VARDATA(string) + m - 1;
|
ptr = VARDATA(string) + m - 1;
|
||||||
ptr_ret = VARDATA(ret);
|
ptr_ret = VARDATA(ret);
|
||||||
|
|
||||||
while (len--) {
|
while (len--) {
|
||||||
*ptr_ret++ = *ptr++;
|
*ptr_ret++ = *ptr++;
|
||||||
@ -699,6 +418,49 @@ substr(text *string, int4 m)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
/********************************************************************
|
||||||
|
*
|
||||||
|
* translate
|
||||||
|
*
|
||||||
|
* Syntax:
|
||||||
|
*
|
||||||
|
* text *translate(text *string, char from, char to)
|
||||||
|
*
|
||||||
|
* Purpose:
|
||||||
|
*
|
||||||
|
* Returns string after replacing all occurences of from with
|
||||||
|
* the corresponding character in to. TRANSLATE will not remove
|
||||||
|
* characters.
|
||||||
|
*
|
||||||
|
********************************************************************/
|
||||||
|
|
||||||
|
text *
|
||||||
|
translate(text *string, char from, char to)
|
||||||
|
{
|
||||||
|
text *ret;
|
||||||
|
char *ptr, *ptr_ret;
|
||||||
|
int m;
|
||||||
|
|
||||||
|
m = VARSIZE(string) - VARHDRSZ;
|
||||||
|
|
||||||
|
if (m <= 0) {
|
||||||
|
return string;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = (text *)palloc(VARSIZE(string));
|
||||||
|
VARSIZE(ret) = VARSIZE(string);
|
||||||
|
|
||||||
|
ptr = VARDATA(string);
|
||||||
|
ptr_ret = VARDATA(ret);
|
||||||
|
|
||||||
|
while (m--) {
|
||||||
|
*ptr_ret++ = *ptr == from ? to : *ptr;
|
||||||
|
ptr++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 1994, Regents of the University of California
|
* Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $Id: pg_proc.h,v 1.11 1997/03/16 01:16:31 scrappy Exp $
|
* $Id: pg_proc.h,v 1.12 1997/03/16 20:40:52 scrappy Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* The script catalog/genbki.sh reads this file and generates .bki
|
* The script catalog/genbki.sh reads this file and generates .bki
|
||||||
@ -768,15 +768,20 @@ DATA(insert OID = 1310 ( timestample PGUID 11 f t f 2 f 16 "1296 1296" 10
|
|||||||
DATA(insert OID = 1311 ( timestampge PGUID 11 f t f 2 f 16 "1296 1296" 100 0 0 100 foo bar ));
|
DATA(insert OID = 1311 ( timestampge PGUID 11 f t f 2 f 16 "1296 1296" 100 0 0 100 foo bar ));
|
||||||
|
|
||||||
/* Oracle Compatibility Related Functions - By Edmund Mergl <E.Mergl@bawue.de> */
|
/* Oracle Compatibility Related Functions - By Edmund Mergl <E.Mergl@bawue.de> */
|
||||||
DATA(insert OID = 870 ( LOWER PGUID 11 f t f 1 f 25 "25" 100 0 0 100 foo bar ));
|
DATA(insert OID = 870 ( lower PGUID 11 f t f 1 f 25 "25" 100 0 0 100 foo bar ));
|
||||||
DATA(insert OID = 871 ( UPPER PGUID 11 f t f 1 f 25 "25" 100 0 0 100 foo bar ));
|
DATA(insert OID = 871 ( upper PGUID 11 f t f 1 f 25 "25" 100 0 0 100 foo bar ));
|
||||||
DATA(insert OID = 872 ( INITCAP PGUID 11 f t f 1 f 25 "25" 100 0 0 100 foo bar ));
|
DATA(insert OID = 872 ( initcap PGUID 11 f t f 1 f 25 "25" 100 0 0 100 foo bar ));
|
||||||
DATA(insert OID = 873 ( LPAD PGUID 11 f t f 3 f 25 "25 23 25" 100 0 0 100 foo bar ));
|
DATA(insert OID = 873 ( lpad PGUID 11 f t f 3 f 25 "25 23 25" 100 0 0 100 foo bar ));
|
||||||
DATA(insert OID = 874 ( RPAD PGUID 11 f t f 3 f 25 "25 23 25" 100 0 0 100 foo bar ));
|
DATA(insert OID = 874 ( rpad PGUID 11 f t f 3 f 25 "25 23 25" 100 0 0 100 foo bar ));
|
||||||
DATA(insert OID = 875 ( LTRIM PGUID 11 f t f 2 f 25 "25 25" 100 0 0 100 foo bar ));
|
DATA(insert OID = 875 ( ltrim PGUID 11 f t f 2 f 25 "25 25" 100 0 0 100 foo bar ));
|
||||||
DATA(insert OID = 876 ( RTRIM PGUID 11 f t f 2 f 25 "25 25" 100 0 0 100 foo bar ));
|
DATA(insert OID = 876 ( rtrim PGUID 11 f t f 2 f 25 "25 25" 100 0 0 100 foo bar ));
|
||||||
DATA(insert OID = 877 ( SUBSTR PGUID 11 f t f 3 f 25 "25 23 23" 100 0 0 100 foo bar ));
|
DATA(insert OID = 877 ( substr PGUID 11 f t f 3 f 25 "25 23 23" 100 0 0 100 foo bar ));
|
||||||
DATA(insert OID = 878 ( TRANSLATE PGUID 11 f t f 3 f 25 "25 18 18" 100 0 0 100 foo bar ));
|
DATA(insert OID = 878 ( translate PGUID 11 f t f 3 f 25 "25 18 18" 100 0 0 100 foo bar ));
|
||||||
|
DATA(insert OID = 879 ( lpad PGUID 14 f t f 2 f 25 "25 23" 100 0 0 100 "select lpad($1, $2, \' \')" - ));
|
||||||
|
DATA(insert OID = 880 ( rpad PGUID 14 f t f 2 f 25 "25 23" 100 0 0 100 "select rpad($1, $2, \' \')" - ));
|
||||||
|
DATA(insert OID = 881 ( ltrim PGUID 14 f t f 1 f 25 "25" 100 0 0 100 "select ltrim($1, \' \')" - ));
|
||||||
|
DATA(insert OID = 882 ( rtrim PGUID 14 f t f 1 f 25 "25" 100 0 0 100 "select rtrim($1, \' \')" - ));
|
||||||
|
DATA(insert OID = 883 ( substr PGUID 14 f t f 2 f 25 "25 23" 100 0 0 100 "select substr($1, $2, 10000)" - ));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* prototypes for functions pg_proc.c
|
* prototypes for functions pg_proc.c
|
||||||
|
Loading…
x
Reference in New Issue
Block a user