MCPcopy Create free account
hub / github.com/apache/cloudberry / pset_quoted_string

Function pset_quoted_string

src/bin/psql/command.c:4748–4776  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4746
4747
4748static char *
4749pset_quoted_string(const char *str)
4750{
4751 char *ret = pg_malloc(strlen(str) * 2 + 3);
4752 char *r = ret;
4753
4754 *r++ = '\'';
4755
4756 for (; *str; str++)
4757 {
4758 if (*str == '\n')
4759 {
4760 *r++ = '\\';
4761 *r++ = 'n';
4762 }
4763 else if (*str == '\'')
4764 {
4765 *r++ = '\\';
4766 *r++ = '\'';
4767 }
4768 else
4769 *r++ = *str;
4770 }
4771
4772 *r++ = '\'';
4773 *r = '\0';
4774
4775 return ret;
4776}
4777
4778
4779/*

Callers 1

pset_value_stringFunction · 0.85

Calls 1

pg_mallocFunction · 0.85

Tested by

no test coverage detected