Update of /cvsroot/perfparse/_perfparse/db_tools
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18434/db_tools
Modified Files:
convert.c
Log Message:
start db conversion program
Index: convert.c
===================================================================
RCS file: /cvsroot/perfparse/_perfparse/db_tools/convert.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** convert.c 2 Dec 2006 21:31:09 -0000 1.5
--- convert.c 5 Dec 2006 22:17:10 -0000 1.6
***************
*** 138,162 ****
GString *querystr=g_string_new("");
char *resultstr;
! regex_t *preg;
char regex[512];
! size_t nmatch;
regmatch_t pmatch[10];
int i;
g_string_printf(querystr,"show create table %s",TableName);
query(querystr->str);
- #ifdef USE_DB_MYSQL
while ((result_row = mysql_fetch_row(query_result))) {
! #elif defined USE_DB_POSTGRESQL
! numberOfRows = rows();
! for (currentRow=0;currentRow<numberOfRows;currentRow++){
! #endif
! resultstr=result_row[0];
printf("Resultstring: %s\n",resultstr);
! snprintf(regex,511,"CONSTRAINT `(\\S+)` FOREIGN KEY \\S+ REFERENCES `%s`",ForeignTableName);
printf("Using regex to find FK: %s\n",regex);
! regcomp(preg, regex,REG_EXTENDED|REG_ICASE);
! regexec(preg,resultstr,nmatch,pmatch,0);
! for (i=0;i<=nmatch;i++) {
printf("Match %d so: %d, eo:%d\n",i,pmatch[i].rm_so,pmatch[i].rm_eo);
}
--- 138,161 ----
GString *querystr=g_string_new("");
char *resultstr;
! regex_t preg_struct;
! regex_t *preg=&preg_struct;
char regex[512];
! size_t nmatch=0;
regmatch_t pmatch[10];
int i;
+
g_string_printf(querystr,"show create table %s",TableName);
query(querystr->str);
while ((result_row = mysql_fetch_row(query_result))) {
! resultstr=result_row[1];
printf("Resultstring: %s\n",resultstr);
! snprintf(regex,511,".*CONSTRAINT `(\\S+)` FOREIGN KEY \\S+ REFERENCES `%s`.*",ForeignTableName);
printf("Using regex to find FK: %s\n",regex);
! i=regcomp(preg, regex,REG_EXTENDED|REG_ICASE);
! printf("Returncode compiling the pattern is %d\n",i);
! i=regexec(preg,resultstr,nmatch,pmatch,REG_NOTEOL);
! printf("Returncode matching the pattern is %d\n",i);
! for (i=0;i<nmatch;i++) {
printf("Match %d so: %d, eo:%d\n",i,pmatch[i].rm_so,pmatch[i].rm_eo);
}
|