pgbench: handring empty lines in external scripts

Поиск
Список
Период
Сортировка
От ITAGAKI Takahiro
Тема pgbench: handring empty lines in external scripts
Дата
Msg-id 20060815170804.5806.ITAGAKI.TAKAHIRO@oss.ntt.co.jp
обсуждение исходный текст
Ответы Re: pgbench: handring empty lines in external scripts  (Tatsuo Ishii <ishii@sraoss.co.jp>)
Список pgsql-patches
Hi Tatsuo-san and folks,

This is a fix in pgbench to handle empty lines in external scripts.
The manual says
| Empty lines and lines begging with "--" will be ignored.
but AFAICS, it cannot accept empty lines and exit with error.


The cause seems to be the usage of isspace(). The characters assumed
spaces are not only ' ' and '\t' but also '\n'. So the empty-lines-test
should be the below:


*** pgbench.orig.c    Tue Aug 15 17:04:58 2006
--- pgbench.c    Tue Aug 15 17:06:38 2006
*************** process_file(char *filename)
*** 1006,1012 ****
          while (isspace((unsigned char) buf[i]))
              i++;

!         if (strncmp(&buf[i], "\n", 1) != 0 && strncmp(&buf[i], "--", 2) != 0) {
              commands = process_commands(&buf[i]);
              if (commands == NULL)
              {
--- 1006,1012 ----
          while (isspace((unsigned char) buf[i]))
              i++;

!         if (buf[i] != '\0' && strncmp(&buf[i], "--", 2) != 0) {
              commands = process_commands(&buf[i]);
              if (commands == NULL)
              {

Regards,
---
ITAGAKI Takahiro
NTT Open Source Software Center


В списке pgsql-patches по дате отправления:

Предыдущее
От: "dror"
Дата:
Сообщение: Re: [Patch] - Fix for bug #2558, InitDB failed to run
Следующее
От: Andreas Pflug
Дата:
Сообщение: Re: [Patch] - Fix for bug #2558, InitDB failed to run