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

Function create_sql_command

src/bin/pgbench/pgbench.c:4800–4823  ·  view source on GitHub ↗

* Parse a SQL command; return a Command struct, or NULL if it's a comment * * On entry, psqlscan.l has collected the command into "buf", so we don't * really need to do much here except check for comments and set up a Command * struct. */

Source from the content-addressed store, hash-verified

4798 * struct.
4799 */
4800static Command *
4801create_sql_command(PQExpBuffer buf, const char *source)
4802{
4803 Command *my_command;
4804 char *p = skip_sql_comments(buf->data);
4805
4806 if (p == NULL)
4807 return NULL;
4808
4809 /* Allocate and initialize Command structure */
4810 my_command = (Command *) pg_malloc(sizeof(Command));
4811 initPQExpBuffer(&my_command->lines);
4812 appendPQExpBufferStr(&my_command->lines, p);
4813 my_command->first_line = NULL; /* this is set later */
4814 my_command->type = SQL_COMMAND;
4815 my_command->meta = META_NONE;
4816 my_command->argc = 0;
4817 memset(my_command->argv, 0, sizeof(my_command->argv));
4818 my_command->varprefix = NULL; /* allocated later, if needed */
4819 my_command->expr = NULL;
4820 initSimpleStats(&my_command->stats);
4821
4822 return my_command;
4823}
4824
4825/* Free a Command structure and associated data */
4826static void

Callers 1

ParseScriptFunction · 0.85

Calls 5

skip_sql_commentsFunction · 0.85
pg_mallocFunction · 0.85
initPQExpBufferFunction · 0.85
appendPQExpBufferStrFunction · 0.85
initSimpleStatsFunction · 0.85

Tested by

no test coverage detected