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

Function validateSQLNamePattern

src/bin/psql/describe.c:7368–7409  ·  view source on GitHub ↗

* validateSQLNamePattern * * Wrapper around string_utils's processSQLNamePattern which also checks the * pattern's validity. In addition to that function's parameters, takes a * 'maxparts' parameter specifying the maximum number of dotted names the * pattern is allowed to have, and a 'added_clause' parameter that returns by * reference whether a clause was added to 'buf'. Returns whether t

Source from the content-addressed store, hash-verified

7366 * passed validation, after logging any errors.
7367 */
7368static bool
7369validateSQLNamePattern(PQExpBuffer buf, const char *pattern, bool have_where,
7370 bool force_escape, const char *schemavar,
7371 const char *namevar, const char *altnamevar,
7372 const char *visibilityrule, bool *added_clause,
7373 int maxparts)
7374{
7375 PQExpBufferData dbbuf;
7376 int dotcnt;
7377 bool added;
7378
7379 initPQExpBuffer(&dbbuf);
7380 added = processSQLNamePattern(pset.db, buf, pattern, have_where, force_escape,
7381 schemavar, namevar, altnamevar,
7382 visibilityrule, &dbbuf, &dotcnt);
7383 if (added_clause != NULL)
7384 *added_clause = added;
7385
7386 if (dotcnt >= maxparts)
7387 {
7388 pg_log_error("improper qualified name (too many dotted names): %s",
7389 pattern);
7390 termPQExpBuffer(&dbbuf);
7391 return false;
7392 }
7393
7394 if (maxparts > 1 && dotcnt == maxparts-1)
7395 {
7396 if (PQdb(pset.db) == NULL)
7397 {
7398 pg_log_error("You are currently not connected to a database.");
7399 return false;
7400 }
7401 if (strcmp(PQdb(pset.db), dbbuf.data) != 0)
7402 {
7403 pg_log_error("cross-database references are not implemented: %s",
7404 pattern);
7405 return false;
7406 }
7407 }
7408 return true;
7409}
7410
7411/*
7412 * \dRp

Callers 15

describeAggregatesFunction · 0.85
describeAccessMethodsFunction · 0.85
describeTablespacesFunction · 0.85
describeFunctionsFunction · 0.85
describeTypesFunction · 0.85
describeOperatorsFunction · 0.85
listAllDbsFunction · 0.85
permissionsListFunction · 0.85
listDefaultACLsFunction · 0.85
objectDescriptionFunction · 0.85
describeTableDetailsFunction · 0.85
describeRolesFunction · 0.85

Calls 4

initPQExpBufferFunction · 0.85
processSQLNamePatternFunction · 0.85
termPQExpBufferFunction · 0.85
PQdbFunction · 0.85

Tested by

no test coverage detected