aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/oracle_compat.c
diff options
context:
space:
mode:
authorThomas G. Lockhart <lockhart@fourpalms.org>2000-04-07 13:40:45 +0000
committerThomas G. Lockhart <lockhart@fourpalms.org>2000-04-07 13:40:45 +0000
commita349733bbbeaca5aa5b0b3520963b01a455c9ff8 (patch)
tree75b3222de81890c5fafb91eee0b0f920716d6df4 /src/backend/utils/adt/oracle_compat.c
parent1b992b468bc5fef62f5a1470f382c70311e9d162 (diff)
downloadpostgresql-a349733bbbeaca5aa5b0b3520963b01a455c9ff8.tar.gz
postgresql-a349733bbbeaca5aa5b0b3520963b01a455c9ff8.zip
Add transcendental math functions (sine, cosine, etc)
Add a random number generator and seed setter (random(), SET SEED) Fix up the interval*float8 math to carry partial months into the time field. Add float8*interval so we have symmetry in the available math. Fix the parser and define.c to accept SQL92 types as field arguments. Fix the parser to accept SQL92 types for CREATE TYPE, etc. This is necessary to allow... Bit/varbit support in contrib/bit cleaned up to compile and load cleanly. Still needs some work before final release. Implement the "SOME" keyword as a synonym for "ANY" per SQL92. Implement ascii(text), ichar(int4), repeat(text,int4) to help support the ODBC driver. Enable the TRUNCATE() function mapping in the ODBC driver.
Diffstat (limited to 'src/backend/utils/adt/oracle_compat.c')
-rw-r--r--src/backend/utils/adt/oracle_compat.c101
1 files changed, 56 insertions, 45 deletions
diff --git a/src/backend/utils/adt/oracle_compat.c b/src/backend/utils/adt/oracle_compat.c
index 36524798823..41e2563f3b0 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>
*
- * $Id: oracle_compat.c,v 1.22 2000/03/15 17:24:18 tgl Exp $
+ * $Id: oracle_compat.c,v 1.23 2000/04/07 13:39:41 thomas Exp $
*
*/
@@ -448,50 +448,6 @@ rtrim(text *string, text *set)
/********************************************************************
*
- * 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.
- *
- ********************************************************************/
-
-#ifdef NOT_USED
-text *
-substr(text *string, int4 m, int4 n)
-{
- text *ret;
- char *ptr,
- *ptr_ret;
- int len;
-
- if ((string == (text *) NULL) ||
- (m <= 0) || (n <= 0) ||
- ((len = VARSIZE(string) - VARHDRSZ - m + 1) <= 0))
- return string;
-
- len = len + 1 < n ? len + 1 : n;
-
- ret = (text *) palloc(VARHDRSZ + len);
- VARSIZE(ret) = VARHDRSZ + len;
-
- ptr = VARDATA(string) + m - 1;
- ptr_ret = VARDATA(ret);
-
- while (len--)
- *ptr_ret++ = *ptr++;
-
- return ret;
-}
-#endif
-
-/********************************************************************
- *
* translate
*
* Syntax:
@@ -573,3 +529,58 @@ translate(text *string, text *from, text *to)
return result;
}
+
+
+int4
+ascii(text *string)
+{
+ if (!PointerIsValid(string))
+ return 0;
+
+ if (VARSIZE(string) <= VARHDRSZ)
+ return 0;
+
+ return ((int) *(VARDATA(string)));
+} /* ascii() */
+
+
+text *
+ichar(int4 cvalue)
+{
+ text *result;
+
+ result = (text *) palloc(VARHDRSZ + 1);
+ VARSIZE(result) = VARHDRSZ + 1;
+ *VARDATA(result) = (char) cvalue;
+
+ return result;
+} /* ichar() */
+
+
+text *
+repeat(text *string, int4 count)
+{
+ text *result;
+ int slen, tlen;
+ int i;
+ char *cp;
+
+ if (count < 0)
+ count = 0;
+
+ slen = (VARSIZE(string)-VARHDRSZ);
+ tlen = (VARHDRSZ + (count * slen));
+
+ result = (text *) palloc(tlen);
+
+ VARSIZE(result) = tlen;
+ cp = VARDATA(result);
+ for (i = 0; i < count; i++)
+ {
+ memcpy(cp, VARDATA(string), slen);
+ cp += slen;
+ }
+
+ return result;
+} /* repeat() */
+