PostgreSQL Source Code git master
scansup.c File Reference
#include "postgres.h"
#include <ctype.h>
#include "mb/pg_wchar.h"
#include "parser/scansup.h"
#include "utils/pg_locale.h"
Include dependency graph for scansup.c:

Go to the source code of this file.

Functions

char * downcase_truncate_identifier (const char *ident, int len, bool warn)
 
char * downcase_identifier (const char *ident, int len, bool warn, bool truncate)
 
void truncate_identifier (char *ident, int len, bool warn)
 
bool scanner_isspace (char ch)
 

Function Documentation

◆ downcase_identifier()

char * downcase_identifier ( const char *  ident,
int  len,
bool  warn,
bool  truncate 
)

Definition at line 47 of file scansup.c.

48{
49 char *result;
50 size_t needed pg_attribute_unused();
51
52 /*
53 * Preserves string length.
54 *
55 * NB: if we decide to support Unicode-aware identifier case folding, then
56 * we need to account for a change in string length.
57 */
58 result = palloc(len + 1);
59
60 needed = pg_downcase_ident(result, len + 1, ident, len);
61 Assert(needed == len);
62 Assert(result[len] == '\0');
63
64 if (len >= NAMEDATALEN && truncate)
66
67 return result;
68}
#define pg_attribute_unused()
Definition: c.h:138
Assert(PointerIsAligned(start, uint64))
#define ident
Definition: indent_codes.h:47
void * palloc(Size size)
Definition: mcxt.c:1387
#define NAMEDATALEN
const void size_t len
size_t pg_downcase_ident(char *dst, size_t dstsize, const char *src, ssize_t srclen)
Definition: pg_locale.c:1366
void truncate_identifier(char *ident, int len, bool warn)
Definition: scansup.c:81
warn
Definition: strftime.c:110

References Assert(), ident, len, NAMEDATALEN, palloc(), pg_attribute_unused, pg_downcase_ident(), and truncate_identifier().

Referenced by downcase_truncate_identifier(), and parse_ident().

◆ downcase_truncate_identifier()

char * downcase_truncate_identifier ( const char *  ident,
int  len,
bool  warn 
)

◆ scanner_isspace()

bool scanner_isspace ( char  ch)

Definition at line 105 of file scansup.c.

106{
107 /* This must match scan.l's list of {space} characters */
108 if (ch == ' ' ||
109 ch == '\t' ||
110 ch == '\n' ||
111 ch == '\r' ||
112 ch == '\v' ||
113 ch == '\f')
114 return true;
115 return false;
116}

Referenced by array_in(), array_out(), check_uescapechar(), CleanQuerytext(), CreateSchemaCommand(), from_char_seq_search(), get_val(), parse_hstore(), parse_ident(), parseNameAndArgTypes(), ReadArrayDimensions(), ReadArrayToken(), SplitDirectoriesString(), SplitGUCList(), and SplitIdentifierString().

◆ truncate_identifier()

void truncate_identifier ( char *  ident,
int  len,
bool  warn 
)

Definition at line 81 of file scansup.c.

82{
83 if (len >= NAMEDATALEN)
84 {
86 if (warn)
88 (errcode(ERRCODE_NAME_TOO_LONG),
89 errmsg("identifier \"%s\" will be truncated to \"%.*s\"",
90 ident, len, ident)));
91 ident[len] = '\0';
92 }
93}
int errcode(int sqlerrcode)
Definition: elog.c:863
int errmsg(const char *fmt,...)
Definition: elog.c:1080
#define NOTICE
Definition: elog.h:35
#define ereport(elevel,...)
Definition: elog.h:150
int pg_mbcliplen(const char *mbstr, int len, int limit)
Definition: mbutils.c:1086

References ereport, errcode(), errmsg(), ident, len, NAMEDATALEN, NOTICE, and pg_mbcliplen().

Referenced by base_yylex(), createNewConnection(), deleteConnection(), downcase_identifier(), get_connect_string(), getConnectionByName(), parse_and_validate_value(), and SplitIdentifierString().