1/*-------------------------------------------------------------------------
4 * Functions for quoting identifiers and literals
6 * Portions Copyright (c) 2000-2025, PostgreSQL Global Development Group
10 * src/backend/utils/adt/quote.c
12 *-------------------------------------------------------------------------
22 * returns a properly quoted identifier
37 * quote_literal_internal -
38 * helper function for quote_literal and quote_literal_cstr
40 * NOTE: think not to make this function's behavior change with
41 * standard_conforming_strings. We don't know where the result
42 * literal will be used, and so we must generate a result that
43 * will work with either setting. Take a look at what dblink
44 * uses this for before thinking you know better.
52 for (s = src; s < src +
len; s++)
75 * returns a properly quoted literal
87 /* We make a worst-case result area; wasting a little space is OK */
99 * quote_literal_cstr -
100 * returns a properly quoted literal
109 len = strlen(rawstr);
110 /* We make a worst-case result area; wasting a little space is OK */
112 (
len * 2)
/* doubling for every character if each one is
114 + 3
/* two outer quotes + possibly 'E' if needed */
115 + 1
/* null terminator */
119 result[newlen] =
'0円';
126 * Returns a properly quoted literal, with null values returned
127 * as the text string 'NULL'.
#define ESCAPE_STRING_SYNTAX
#define SQL_STR_DOUBLE(ch, escape_backslash)
#define PG_GETARG_TEXT_PP(n)
#define DirectFunctionCall1(func, arg1)
#define PG_GETARG_DATUM(n)
#define PG_RETURN_TEXT_P(x)
#define PG_RETURN_DATUM(x)
static size_t quote_literal_internal(char *dst, const char *src, size_t len)
char * quote_literal_cstr(const char *rawstr)
Datum quote_ident(PG_FUNCTION_ARGS)
Datum quote_nullable(PG_FUNCTION_ARGS)
Datum quote_literal(PG_FUNCTION_ARGS)
const char * quote_identifier(const char *ident)
static Size VARSIZE_ANY_EXHDR(const void *PTR)
static char * VARDATA(const void *PTR)
static char * VARDATA_ANY(const void *PTR)
static void SET_VARSIZE(void *PTR, Size len)
text * cstring_to_text(const char *s)
char * text_to_cstring(const text *t)