Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6316f4d

Browse files
author
Thomas G. Lockhart
committed
Define text, varchar, and bpchar string length functions.
1 parent6873af5 commit6316f4d

File tree

2 files changed

+25
-13
lines changed

2 files changed

+25
-13
lines changed

‎src/backend/utils/adt/varchar.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.12 1997/12/06 22:57:14 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.13 1997/12/16 15:59:09 thomas Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -121,7 +121,7 @@ bpcharout(char *s)
121121
* len is the length specified in () plus VARHDRSZ bytes. (XXX dummy is here
122122
* because we pass typelem as the second argument for array_in.)
123123
*/
124-
char*
124+
char*
125125
varcharin(char*s,intdummy,inttyplen)
126126
{
127127
char*result;
@@ -191,6 +191,15 @@ bcTruelen(char *arg)
191191
return (i+1);
192192
}
193193

194+
int32
195+
bpcharlen(char*arg)
196+
{
197+
if (!PointerIsValid(arg))
198+
elog(WARN,"Bad (null) char() external representation",NULL);
199+
200+
return(bcTruelen(arg));
201+
}/* bpcharlen() */
202+
194203
bool
195204
bpchareq(char*arg1,char*arg2)
196205
{
@@ -338,6 +347,15 @@ vcTruelen(char *arg)
338347
returni;
339348
}
340349

350+
int32
351+
varcharlen(char*arg)
352+
{
353+
if (!PointerIsValid(arg))
354+
elog(WARN,"Bad (null) varchar() external representation",NULL);
355+
356+
return(vcTruelen(arg));
357+
}/* vclen() */
358+
341359
bool
342360
varchareq(char*arg1,char*arg2)
343361
{

‎src/backend/utils/adt/varlena.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.24 1997/12/08 04:42:48 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.25 1997/12/16 15:59:11 thomas Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -210,20 +210,14 @@ textout(struct varlena * vlena)
210210
* returns the actual length of a text* (which may be less than
211211
* the VARSIZE of the text*)
212212
*/
213-
#ifdefNOT_USED
214213
int
215214
textlen(text*t)
216215
{
217-
inti=0;
218-
intmax=VARSIZE(t)-VARHDRSZ;
219-
char*ptr=VARDATA(t);
220-
221-
while (i<max&&*ptr++)
222-
i++;
223-
returni;
224-
}
216+
if (!PointerIsValid(t))
217+
elog(WARN,"Null input to textlen");
225218

226-
#endif
219+
return (VARSIZE(t)-VARHDRSZ);
220+
}/* textlen() */
227221

228222
/*
229223
* textcat -

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp