* Check whether the specified command is a SELECT (or VALUES). */
| 2119 | * Check whether the specified command is a SELECT (or VALUES). |
| 2120 | */ |
| 2121 | static bool |
| 2122 | is_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 | /* |
no test coverage detected