PostgreSQL Source Code
git master
Toggle main menu visibility
Main Page
Related Pages
Namespaces
Namespace List
Namespace Members
All
a
c
d
g
h
i
k
l
m
p
r
s
t
Functions
Variables
Data Structures
Data Structures
Data Structure Index
Class Hierarchy
Data Fields
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
_
a
c
d
f
h
i
n
o
p
r
s
t
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Enumerations
Files
File List
Globals
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Enumerations
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
Enumerator
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Macros
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
•
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
quotes.c
Go to the documentation of this file.
1
/*-------------------------------------------------------------------------
2
*
3
* quotes.c
4
* string quoting and escaping functions
5
*
6
* Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
7
* Portions Copyright (c) 1994, Regents of the University of California
8
*
9
*
10
* IDENTIFICATION
11
* src/port/quotes.c
12
*
13
*-------------------------------------------------------------------------
14
*/
15
16
#include "
c.h
"
17
18
/*
19
* Escape (by doubling) any single quotes or backslashes in given string
20
*
21
* Note: this is used to process postgresql.conf entries and to quote
22
* string literals in pg_basebackup for writing the recovery configuration.
23
* Since postgresql.conf strings are defined to treat backslashes as escapes,
24
* we have to double backslashes here.
25
*
26
* Since this function is only used for parsing or creating configuration
27
* files, we do not care about encoding considerations.
28
*
29
* Returns a malloced() string that it's the responsibility of the caller
30
* to free.
31
*/
32
char
*
33
escape_single_quotes_ascii
(
const
char
*src)
34
{
35
int
len
= strlen(src),
36
i
,
37
j
;
38
char
*result =
malloc
(
len
* 2 + 1);
39
40
if
(!result)
41
return
NULL;
42
43
for
(
i
= 0,
j
= 0;
i
<
len
;
i
++)
44
{
45
if
(
SQL_STR_DOUBLE
(src[
i
],
true
))
46
result[
j
++] = src[
i
];
47
result[
j
++] = src[
i
];
48
}
49
result[
j
] =
'\0'
;
50
return
result;
51
}
c.h
SQL_STR_DOUBLE
#define SQL_STR_DOUBLE(ch, escape_backslash)
Definition:
c.h:1134
malloc
#define malloc(a)
Definition:
header.h:50
j
int j
Definition:
isn.c:78
i
int i
Definition:
isn.c:77
len
const void size_t len
Definition:
pg_crc32c_sse42.c:28
escape_single_quotes_ascii
char * escape_single_quotes_ascii(const char *src)
Definition:
quotes.c:33
src
port
quotes.c
Generated on Mon Apr 21 2025 06:13:28 for PostgreSQL Source Code by
1.9.4