35{
36 char *copy = NULL;
37 const char *chunk_search_start,
38 *chunk_copy_start,
39 *chunk_end;
40 int slen;
41 bool ellipsis;
42
44
45 slen = strlen(s);
46 if (maxlen >= 0 && maxlen < slen)
47 {
49
51 chunk_search_start = copy;
52 chunk_copy_start = copy;
53
54 ellipsis = true;
55 }
56 else
57 {
58 chunk_search_start = s;
59 chunk_copy_start = s;
60
61 ellipsis = false;
62 }
63
65
66 while ((chunk_end = strchr(chunk_search_start, '\'')) != NULL)
67 {
68 /* copy including the found delimiting ' */
70 chunk_copy_start,
71 chunk_end - chunk_copy_start + 1);
72
73 /* in order to double it, include this ' into the next chunk as well */
74 chunk_copy_start = chunk_end;
75 chunk_search_start = chunk_end + 1;
76 }
77
78 /* copy the last chunk and terminate */
79 if (ellipsis)
81 else
83
84 if (copy)
86}
Assert(PointerIsAligned(start, uint64))
int pg_mbcliplen(const char *mbstr, int len, int limit)
void pfree(void *pointer)
char * pnstrdup(const char *in, Size len)
void appendStringInfo(StringInfo str, const char *fmt,...)
void appendBinaryStringInfoNT(StringInfo str, const void *data, int datalen)
#define appendStringInfoCharMacro(str, ch)