MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / preprocess

Method preprocess

src/jrd/extds/ExtDS.cpp:2092–2231  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2090}
2091
2092void Statement::preprocess(const string& sql, string& ret)
2093{
2094 bool passAsIs = true, execBlock = false;
2095 const char* p = sql.begin(), *end = sql.end();
2096 const char* start = p;
2097 TokenType tok = getToken(&p, end);
2098
2099 const char* i = start;
2100 while (p < end && (tok == ttComment || tok == ttWhite))
2101 {
2102 i = p;
2103 tok = getToken(&p, end);
2104 }
2105
2106 if (p >= end || tok != ttIdent)
2107 {
2108 // Execute statement preprocess SQL error
2109 // Statement expected
2110 ERR_post(Arg::Gds(isc_eds_preprocess) <<
2111 Arg::Gds(isc_eds_stmt_expected));
2112 }
2113
2114 start = i; // skip leading comments ??
2115 string ident(i, p - i);
2116 ident.upper();
2117
2118 if (ident == "EXECUTE")
2119 {
2120 const char* i2 = p;
2121 tok = getToken(&p, end);
2122 while (p < end && (tok == ttComment || tok == ttWhite))
2123 {
2124 i2 = p;
2125 tok = getToken(&p, end);
2126 }
2127 if (p >= end || tok != ttIdent)
2128 {
2129 // Execute statement preprocess SQL error
2130 // Statement expected
2131 ERR_post(Arg::Gds(isc_eds_preprocess) <<
2132 Arg::Gds(isc_eds_stmt_expected));
2133 }
2134 string ident2(i2, p - i2);
2135 ident2.upper();
2136
2137 execBlock = (ident2 == "BLOCK");
2138 passAsIs = false;
2139 }
2140 else
2141 {
2142 passAsIs = !(ident == "INSERT" || ident == "UPDATE" || ident == "DELETE" ||
2143 ident == "MERGE" || ident == "SELECT" || ident == "WITH");
2144 }
2145
2146 if (passAsIs)
2147 {
2148 ret = sql;
2149 return;

Callers

nothing calls this directly

Calls 12

GdsClass · 0.85
StrClass · 0.85
upperMethod · 0.80
getTokenFunction · 0.70
ERR_postFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
appendMethod · 0.45
assignMethod · 0.45
lengthMethod · 0.45
findMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected