Обсуждение: ecpg enhance patch
Here is a patch that would enhance the efficiency in that skip strings which have been already checked. The patch was made by Kazuko Nakagawa. Michael, can you comment on this? *** ecpglib.c.orig Wed Dec 22 13:13:21 1999 --- ecpglib.c Wed Dec 22 13:37:32 1999 *************** *** 398,403 **** --- 398,404 ---- PGresult *results; PGnotify *notify; struct variable *var; + int hostvarl = 0; copiedquery = ecpg_strdup(stmt->command, stmt->lineno); *************** *** 569,575 **** return false; strcpy(newcopy, copiedquery); ! if ((p = next_insert(newcopy)) == NULL) { /* --- 570,576 ---- return false; strcpy(newcopy, copiedquery); ! if ((p = next_insert(newcopy+hostvarl)) == NULL) { /* *************** *** 582,587 **** --- 583,589 ---- else { strcpy(p, tobeinserted); + hostvarl = strlen(newcopy); /* * The strange thing in the second argument is therest of the
On Mon, Dec 27, 1999 at 04:49:19PM +0900, Tatsuo Ishii wrote: > Here is a patch that would enhance the efficiency in that skip strings > which have been already checked. The patch was made by Kazuko > Nakagawa. Michael, can you comment on this? The problem is that the current system allows insertions of placeholders which are later replaced by values. After applying this patch this will no longer work. But with some changes we might get almost the same result. After the p = next_insert(...) p-newcopy characters are already clean. This should be used. I just noticed that there is a ugly hack in there anyway, namely the string length calculation via substraction of two pointers. I wonder if this works with multibyte strings. Michael -- Michael Meskes | Go SF 49ers! Th.-Heuss-Str. 61, D-41812 Erkelenz | Go Rhein Fire! Tel.: (+49) 2431/72651 | Use Debian GNU/Linux! Email: Michael@Fam-Meskes.De | Use PostgreSQL!
> On Mon, Dec 27, 1999 at 04:49:19PM +0900, Tatsuo Ishii wrote: > > Here is a patch that would enhance the efficiency in that skip strings > > which have been already checked. The patch was made by Kazuko > > Nakagawa. Michael, can you comment on this? > > The problem is that the current system allows insertions of placeholders > which are later replaced by values. After applying this patch this will no > longer work. But with some changes we might get almost the same result. > > After the p = next_insert(...) p-newcopy characters are already clean. This > should be used. I just noticed that there is a ugly hack in there anyway, > namely the string length calculation via substraction of two pointers. I Thank you for your comment. I'll foward it to the author of the patch. > wonder if this works with multibyte strings. Should be no problem. -- Tatsuo Ishii
Can I get a comment on this? It has not been applied. It appears to apply to an older release. New new file name is interfaces/ecpg/lib/execute.c. > Here is a patch that would enhance the efficiency in that skip strings > which have been already checked. The patch was made by Kazuko > Nakagawa. Michael, can you comment on this? > > *** ecpglib.c.orig Wed Dec 22 13:13:21 1999 > --- ecpglib.c Wed Dec 22 13:37:32 1999 > *************** > *** 398,403 **** > --- 398,404 ---- > PGresult *results; > PGnotify *notify; > struct variable *var; > + int hostvarl = 0; > > copiedquery = ecpg_strdup(stmt->command, stmt->lineno); > > *************** > *** 569,575 **** > return false; > > strcpy(newcopy, copiedquery); > ! if ((p = next_insert(newcopy)) == NULL) > { > > /* > --- 570,576 ---- > return false; > > strcpy(newcopy, copiedquery); > ! if ((p = next_insert(newcopy+hostvarl)) == NULL) > { > > /* > *************** > *** 582,587 **** > --- 583,589 ---- > else > { > strcpy(p, tobeinserted); > + hostvarl = strlen(newcopy); > > /* > * The strange thing in the second argument is the rest of the > > > ************ > -- Bruce Momjian | http://www.op.net/~candle pgman@candle.pha.pa.us | (610) 853-3000+ If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania19026
On Thu, Jun 01, 2000 at 06:03:17PM -0400, Bruce Momjian wrote: > Can I get a comment on this? It has not been applied. It appears to > apply to an older release. New new file name is > interfaces/ecpg/lib/execute.c. Hmm, I'm not sure but I've seen this before. I think there was a reason for not including it, wasn't there? But then I fail to remember what we discussed back then. Michael -- Michael Meskes Michael@Fam-Meskes.De Go SF 49ers! Go Rhein Fire! Use Debian GNU/Linux! Use PostgreSQL!
> On Thu, Jun 01, 2000 at 06:03:17PM -0400, Bruce Momjian wrote: > > Can I get a comment on this? It has not been applied. It appears to > > apply to an older release. New new file name is > > interfaces/ecpg/lib/execute.c. > > Hmm, I'm not sure but I've seen this before. I think there was a reason for > not including it, wasn't there? > > But then I fail to remember what we discussed back then. Well, if someone shot it down, I usually delete the email. Please review it and tell us if it makes any sense. Seems like some kind of optimization. -- Bruce Momjian | http://www.op.net/~candle pgman@candle.pha.pa.us | (610) 853-3000+ If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania19026
Bruce Momjian <pgman@candle.pha.pa.us> wrote: > Can I get a comment on this? It has not been applied. It appears to > apply to an older release. New new file name is > interfaces/ecpg/lib/execute.c. The following patch could solve the next error cases in 6.5.3-ecpglib. case 1. strcpy(str, "T''EST'TEST"); exec sql insert into ecpg_test values ( 11, :str, 'kobe' ) ; error(-201)(Too manyarguments line 1025. case 2. str( str, "T'''?'ESTTEST"); exec sql insert into ecpg_test values ( 11, :str, 'kobe' ) ; error(-202)(Too few arguments line 1024.) However, these problems seems to be solved in 7.0-ecpglib. > > Here is a patch that would enhance the efficiency in that skip strings > > which have been already checked. The patch was made by Kazuko > > Nakagawa. Michael, can you comment on this? > > > > *** ecpglib.c.orig Wed Dec 22 13:13:21 1999 > > --- ecpglib.c Wed Dec 22 13:37:32 1999 > > *************** > > *** 398,403 **** > > --- 398,404 ---- > > PGresult *results; > > PGnotify *notify; > > struct variable *var; > > + int hostvarl = 0; > > > > copiedquery = ecpg_strdup(stmt->command, stmt->lineno); > > > > *************** > > *** 569,575 **** > > return false; > > > > strcpy(newcopy, copiedquery); > > ! if ((p = next_insert(newcopy)) == NULL) > > { > > > > /* > > --- 570,576 ---- > > return false; > > > > strcpy(newcopy, copiedquery); > > ! if ((p = next_insert(newcopy+hostvarl)) == NULL) > > { > > > > /* > > *************** > > *** 582,587 **** > > --- 583,589 ---- > > else > > { > > strcpy(p, tobeinserted); > > + hostvarl = strlen(newcopy); > > > > /* > > * The strange thing in the second argument is the rest of the > > > > > > ************ -- Regards, SAKAIDA Masaaki -- Osaka, Japan
On Sat, Jun 03, 2000 at 11:22:19AM +0900, SAKAIDA Masaaki wrote: > The following patch could solve the next error cases in 6.5.3-ecpglib. > > case 1. > strcpy(str, "T''EST'TEST"); > exec sql insert into ecpg_test values ( 11, :str, 'kobe' ) ; > > error(-201)(Too many arguments line 1025. > > case 2. > str( str, "T'''?'ESTTEST"); > exec sql insert into ecpg_test values ( 11, :str, 'kobe' ) ; > > error(-202)(Too few arguments line 1024.) > > > However, these problems seems to be solved in 7.0-ecpglib. So that means the patch is not needed anymore? Michael -- Michael Meskes Michael@Fam-Meskes.De Go SF 49ers! Go Rhein Fire! Use Debian GNU/Linux! Use PostgreSQL!
Michael Meskes <meskes@postgresql.org> wrote: > On Sat, Jun 03, 2000 at 11:22:19AM +0900, SAKAIDA Masaaki wrote: > > The following patch could solve the next error cases in 6.5.3-ecpglib. > > > > case 1. > > strcpy(str, "T''EST'TEST"); > > exec sql insert into ecpg_test values ( 11, :str, 'kobe' ) ; > > > > error(-201)(Too many arguments line 1025. > > > > case 2. > > str( str, "T'''?'ESTTEST"); > > exec sql insert into ecpg_test values ( 11, :str, 'kobe' ) ; > > > > error(-202)(Too few arguments line 1024.) > > > > > > However, these problems seems to be solved in 7.0-ecpglib. > > So that means the patch is not needed anymore? In the meaning of bug-fix, the patch is not needed. Because you have already modified "next_insert()" in 7.0-ecpglib. However in the meaning of speed-up, the patch will be needed. -- Regards, SAKAIDA Masaaki -- Osaka, Japan *** postgresql-7.0.1/src/interfaces/ecpg/lib/execute.c.orig Tue Jun 6 15:02:34 2000 --- postgresql-7.0.1/src/interfaces/ecpg/lib/execute.c Tue Jun 6 15:02:05 2000 *************** *** 278,283 **** --- 278,284 ---- char *tobeinserted = NULL; char *p; char buff[20]; + int hostvarl = 0; /* * Some special treatment is needed for records since we want *************** *** 559,565 **** return false; strcpy(newcopy, copiedquery); ! if ((p = next_insert(newcopy)) == NULL) { /* --- 560,566 ---- return false; strcpy(newcopy, copiedquery); ! if ((p = next_insert(newcopy + hostvarl)) == NULL) { /* *************** *** 572,577 **** --- 573,579 ---- else { strcpy(p, tobeinserted); + hostvarl = strlen(newcopy); /* * The strange thing in the second argument is therest of the
I have committed this patch. It offers a speed up to ecpg. > > Michael Meskes <meskes@postgresql.org> wrote: > > > On Sat, Jun 03, 2000 at 11:22:19AM +0900, SAKAIDA Masaaki wrote: > > > The following patch could solve the next error cases in 6.5.3-ecpglib. > > > > > > case 1. > > > strcpy(str, "T''EST'TEST"); > > > exec sql insert into ecpg_test values ( 11, :str, 'kobe' ) ; > > > > > > error(-201)(Too many arguments line 1025. > > > > > > case 2. > > > str( str, "T'''?'ESTTEST"); > > > exec sql insert into ecpg_test values ( 11, :str, 'kobe' ) ; > > > > > > error(-202)(Too few arguments line 1024.) > > > > > > > > > However, these problems seems to be solved in 7.0-ecpglib. > > > > So that means the patch is not needed anymore? > > In the meaning of bug-fix, the patch is not needed. Because you > have already modified "next_insert()" in 7.0-ecpglib. However > in the meaning of speed-up, the patch will be needed. > -- > Regards, > SAKAIDA Masaaki -- Osaka, Japan > > > *** postgresql-7.0.1/src/interfaces/ecpg/lib/execute.c.orig Tue Jun > 6 15:02:34 2000 > --- postgresql-7.0.1/src/interfaces/ecpg/lib/execute.c Tue Jun 6 15:02:05 2000 > *************** > *** 278,283 **** > --- 278,284 ---- > char *tobeinserted = NULL; > char *p; > char buff[20]; > + int hostvarl = 0; > > /* > * Some special treatment is needed for records since we want > *************** > *** 559,565 **** > return false; > > strcpy(newcopy, copiedquery); > ! if ((p = next_insert(newcopy)) == NULL) > { > > /* > --- 560,566 ---- > return false; > > strcpy(newcopy, copiedquery); > ! if ((p = next_insert(newcopy + hostvarl)) == NULL) > { > > /* > *************** > *** 572,577 **** > --- 573,579 ---- > else > { > strcpy(p, tobeinserted); > + hostvarl = strlen(newcopy); > > /* > * The strange thing in the second argument is the rest of the > > > > -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000+ If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania19026
On Mon, Oct 02, 2000 at 12:00:46PM -0400, Bruce Momjian wrote: > I have committed this patch. It offers a speed up to ecpg. Thanks. I haven't found the time to do it so far. But since I wanted to this is good news. :-) Michael -- Michael Meskes Michael@Fam-Meskes.De Go SF 49ers! Go Rhein Fire! Use Debian GNU/Linux! Use PostgreSQL!