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

Function is_select_command

src/bin/psql/common.c:2121–2152  ·  view source on GitHub ↗

* Check whether the specified command is a SELECT (or VALUES). */

Source from the content-addressed store, hash-verified

2119 * Check whether the specified command is a SELECT (or VALUES).
2120 */
2121static bool
2122is_select_command(const char *query)
2123{
2124 int wordlen;
2125
2126 /*
2127 * First advance over any whitespace, comments and left parentheses.
2128 */
2129 for (;;)
2130 {
2131 query = skip_white_space(query);
2132 if (query[0] == '(')
2133 query++;
2134 else
2135 break;
2136 }
2137
2138 /*
2139 * Check word length (since "selectx" is not "select").
2140 */
2141 wordlen = 0;
2142 while (isalpha((unsigned char) query[wordlen]))
2143 wordlen += PQmblenBounded(&query[wordlen], pset.encoding);
2144
2145 if (wordlen == 6 && pg_strncasecmp(query, "select", 6) == 0)
2146 return true;
2147
2148 if (wordlen == 6 && pg_strncasecmp(query, "values", 6) == 0)
2149 return true;
2150
2151 return false;
2152}
2153
2154
2155/*

Callers 1

SendQueryFunction · 0.85

Calls 3

skip_white_spaceFunction · 0.85
PQmblenBoundedFunction · 0.85
pg_strncasecmpFunction · 0.85

Tested by

no test coverage detected