* 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. */
| 4798 | * struct. |
| 4799 | */ |
| 4800 | static Command * |
| 4801 | create_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 */ |
| 4826 | static void |
no test coverage detected