Boost logo

Boost Users :

From: eydelber (eydelber_at_[hidden])
Date: 2002-11-29 13:45:55


Sorry, I didn't qualify my problem correctly. The problem comes in
when the column list is too long, opposite of what you tested.
Also, I doubt the problem is duplicable in such certain conditions,
so if you want to try the full program, it will take about 5 minutes
to download and test and then try the same test, except with the
gibberish in the first ()'s and not the second ()'s.

Code is here:

http://www.myplaceonline.com/code/code.htm

Just compile everything together and run ./try.cgi, and from there
enter an sql string similar to (you'll also have to create a table
first like this: "create table test (one int)"):

insert into test (lkfsdjlkafdjklfsdajflkjfdklsjfsdlkjsfldkjfskldaj)
values (1);

When you go to download the code, the links are all to .htm files,
so just take of the .htm, and you will get just the .cpp or .h files.

This is the compile string I used:

g++ tdbsql.cpp textdb.cpp textdbut.cpp
$HOME/boost_1_29_0/libs/regex/build/gcc/libboost_regex.a /usr/lib/lib
expat.a -I$HOME/boost_1_29_0 -o try.cgi -Wall

You might just be able to take out both the .a files and the -I flag
if everything is setup right on your Linux/Unix, but mine isn't.

It is a very interesting problem, because essentially the create
table syntax is almost the same, and when I try long delimited lists
there, it works fine, but it randomly occurs for the insert syntax.
I've tried everything to narrow down the problem, but it just makes
no sense. It definitely occurs on RegeEx.Match(), but I can't
figure out what is going wrong, that is why I posted here. It is
something to do with RegEx, whether implicitly or explicitly is what
I'm not sure of. The problem is just really confusing, and running
gdb, like I said backtraces to a weird spot. It doesn't backtrace
to c_str like I said below, what I meant by that is that if I run
the gdb by stepping through each line, then right after the call is
made to RegEx.Match() (then again, only in the case of the insert
syntax does it fail), then there it goes into c_str and somewhere
around there the abortion occurs.

Hopefully you can help me with this.

Thank you VERY MUCH for all your time and help,
Kevin Grigorenko

--- In Boost-Users_at_y..., "John Maddock" <john_maddock_at_c...> wrote:
> > I am running the latest version of boost regex++, and I am
running
> > g++ 2.96 on Linux. I ran gdb, and I seemed to have narrowed down
the
> > problem to c_str(), but this is not logical. Here is the part
of my
> > program:
>
> I tried testing using the program below and it checked out fine
with VC6,
> can you verify that this reproduces the problem? If not can you
please
> submit one that does? If the issue is occuring in a call to c_str
() can you
> verify that the argument is actually a valid string, and/or get a
stack
> backtrace?
>
> John Maddock
> http://ourworld.compuserve.com/homepages/john_maddock/index.htm
>
> Here's my test code:
>
>
> #include <iostream>
> #include "boost/cregex.hpp"
>
> int main(int, char**) {
> std::string checks[] = {
> /* 0 */ "create table (_ID_) (\\(((\\s*,?\\s*(_ID_) (_TYPES_)(
not
> null)?( unique)?( default ((\\d+(\\.\\d+)?)|(\"[^\"]*\")))?(
> unique)?\\s*)+)\\))",
> /* 1 */ "show tables",
> /* 2 */ "drop table (_ID_)",
> /* 3 */ "show tdb\\.xml",
> /* 4 */ "desc( table)? (_ID_)",
> /* 5 */ "alter table (_ID_) add( column)? ((_ID_) (_TYPES_)(
not
> null)?( unique)?( default ((\\d+(\\.\\d+)?)|(\"[^\"]*\")))?(
unique)?(
> first| after (_ID_))?)",
> /* 6 */ "alter table (_ID_) drop( column)? (_ID_)",
> /* 7 */ "alter table (_ID_) add( column)? \\(((\\s*,?\\s*(_ID_)
> (_TYPES_)( not null)?( unique)?( default
> ((\\d+(\\.\\d+)?)|(\"[^\"]*\")))?( unique)?( first| after
> (_ID_))?\\s*)+)\\)",/* 8 */ "rename table (_ID_) (to|as)
(_ID_)",/* 9 */
> "alter table (_ID_) alter( column)? (_ID_) (set default
> ((\\d+(\\.\\d+)?)|(\"[^\"]*\"))|drop default)",
> /* 10 */ "alter table (_ID_) modify( column)? ((_ID_) (_TYPES_)
( not
> null)?( unique)?( default ((\\d+(\\.\\d+)?)|(\"[^\"]*\")))?(
unique)?(
> first| after (_ID_))?)",
> /* 11 */ "alter table (_ID_) change( column)? (_ID_) ((_ID_)
(_TYPES_)(
> not null)?( unique)?( default ((\\d+(\\.\\d+)?)|(\"[^\"]*\")))?(
unique)?(
> first| after (_ID_))?)",
> /* 12 */ "alter table (_ID_) rename( to| as) (_ID_)",
> /* 13 */ "insert( into)? (_ID_)( \\(((\\s*,?\\s*(_ID_)\\s*)+)
\\))? values
> \\(\\)"
> };
>
> int checksLength = sizeof checks / sizeof *checks;
> int i;
>
> std::string sql = "insert into test (one,two,three) values (
> aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
> bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ,
> cccccccccccccccccccccccccccccccccccccc)";
>
> boost::RegEx sqlRegex;
> for(i=0;i<checksLength;i++)
> {
> sqlRegex.SetExpression(checks[i],true);
> if(sqlRegex.Match(sql))
> {
> break;
> }
> }
> return 0;
> }


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net