|
- to_ascii(text [,name|int])
+ ascii(text)
+ int
+ returns the decimal representation of the first character from text
+ ascii('x')
+
+ |
+ btrim(text,set)
text
- convert text from multibyte encoding to ASCII
- to_ascii('Karel')
+ both (left and right) trim characters from text
+ btrim('xxxtrimxxx','x')
|
char(text)
char(varchar 'varchar string')
|
+ |
+ chr(int)
+ text
+ returns the character having the binary equivalent to int
+ chr(65)
+
initcap(text)
text
first letter of each word to upper case
ltrim('xxxxtrim','x')
|
- textpos(text,text)
+ repeat(text,int)
text
- locate specified substring
- position('high','ig')
+ repeat text by int
+ repeat('Pg', 4)
|
rpad(text,int,text)
convert varchar to text type
text(varchar 'varchar string')
+ |
+ textpos(text,text)
+ text
+ locate specified substring
+ position('high','ig')
+
+ |
+ to_ascii(text [,name|int])
+ text
+ convert text from multibyte encoding to ASCII
+ to_ascii('Karel')
+
|
translate(text,from,to)
text
convert character in string
translate('12345', '1', 'a')
-
+
|
varchar(char)
varchar
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: analyze.c,v 1.157 2000/09/12 21:07:00 tgl Exp $
+ * $Id: analyze.c,v 1.158 2000/09/25 12:58:46 momjian Exp $
*
*-------------------------------------------------------------------------
*/
foreach(fkattrs, fkconstraint->fk_attrs) {
found=0;
fkattr=lfirst(fkattrs);
- foreach(cols, columns) {
+ foreach(cols, stmt->tableElts) {
col=lfirst(cols);
if (strcmp(col->colname, fkattr->name)==0) {
found=1;
/* -----------------------------------------------------------------------
* 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
break;
case DCH_tz:
case DCH_TZ:
- if (flag == TO_CHAR)
+ if (flag == TO_CHAR && tzn)
{
int siz = strlen(tzn);
len = VARSIZE(fmt) - VARHDRSZ;
if (len <= 0 || TIMESTAMP_NOT_FINITE(dt))
- return DirectFunctionCall1(textin, CStringGetDatum(""));
+ PG_RETURN_NULL();
ZERO_tm(tm);
tzn = NULL;
* 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);
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); \
\
/*
* Edmund Mergl
*
- * $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 $
*
*/
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)
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;
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;
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_proc.h,v 1.167 2000/09/19 18:18:01 petere Exp $
+ * $Id: pg_proc.h,v 1.168 2000/09/25 12:58:47 momjian Exp $
*
* NOTES
* The script catalog/genbki.sh reads this file and generates .bki
DATA(insert OID = 1620 ( ascii PGUID 12 f t t t 1 f 23 "25" 100 0 0 100 ascii - ));
DESCR("convert first char to int4");
-DATA(insert OID = 1621 ( ichar PGUID 12 f t t t 1 f 25 "23" 100 0 0 100 ichar - ));
+DATA(insert OID = 1621 ( chr PGUID 12 f t t t 1 f 25 "23" 100 0 0 100 chr - ));
DESCR("convert int4 to char");
DATA(insert OID = 1622 ( repeat PGUID 12 f t t t 2 f 25 "25 23" 100 0 0 100 repeat - ));
DESCR("replicate string int4 times");