Re: sqlcmd stackdump
Posted in 2010
Mike, you are right! That's not the place where it dumps. It's the free statement of the Sqlda stucture. See source snipped down. It's at the end of the sql_command(..). I think Marco Greco ist right to that there are problems under Windows when using MVC libraries (from Client SDK) with GNU-C. I shoud try to get an MVC compiler. Or any other suggestions? TIA Dirk /* Execute internal or SQL command */ void sql_command(char *str) { EXEC SQL BEGIN DECLARE SECTION; char *cmd; /* SQL statement */ EXEC SQL END DECLARE SECTION; Sqlda *idesc; int stmt_code; cmd = str; /* This is a one-cycle loop that simplifies error handling */ do { /* Compile RDSQL statement */ printf("sql_command 0.0\\n"); EXEC SQL PREPARE s_statement FROM :cmd; printf("sql_command 0.1\\n"); if (sqlca.sqlcode < 0) break; printf("sql_command 0.2\\n"); EXEC SQL DESCRIBE s_statement INTO idesc; printf("sql_command 0.3\\n"); if (sqlca.sqlcode < 0) break; printf("sql_command 0.4\\n"); stmt_code = sqlca.sqlcode; printf("sql_command 0.5\\n"); if (stmt_code == 0) { stmt_code = SQ_SELECT; printf("sql_command 0\\n"); sql_select(idesc, stmt_code); printf("sql_command 1\\n"); } #ifdef SQLREAD else if (sqlread_allowed(stmt_code)) sql_execute(stmt_code); else cmd_resume(E_CMDNOTALLOWED, sql_stmttype(stmt_code)); #else #ifdef SQ_EXECPROC /* Handle stored procedures which return data as SELECT statements */ else if (stmt_code == SQ_EXECPROC && idesc->sqld > 0) { printf("sql_command 3\\n"); sql_select(idesc, stmt_code); printf("sql_command 4\\n"); } #endif /* SQ_EXECPROC */ else sql_execute(stmt_code); #endif /* SQLREAD */ printf("sql_command 5\\n"); sqlca.sqlcode = 0; EXEC SQL FREE s_statement; printf("sql_command 6\\n"); if (sqlca.sqlcode < 0) break; printf("sql_command 7\\n"); free(idesc); <<< --- here it dumps!!!! } while (0); printf("sql_command 8\\n"); if (sqlca.sqlcode < 0) sql_error(); printf("sql_command 9\\n"); } Mike Aubury schrieb: > Just for completeness - the error might *not* be in the reading of > sqlca.sqlcode after the FETCH.. > > You say : > > static void sql_select(Sqlda *idesc, int stmt_code) > ... > count = 0; > while (sqlca.sqlcode == 0) > { > printf("sql_select 5\\n"); > EXEC SQL FETCH c_statement USING DESCRIPTOR idesc; > printf("sql_select 5.1\\n"); > if (sqlca.sqlcode != 0) > break; > printf("sql_select 5.2\\n"); > if (qlimit > 0 && count++ >= qlimit) > { > printf("sql_select 5.3\\n"); > fflush(ctxt_output()); > break; > } > printf("sql_select 6\\n"); > if (print_record(idesc) != 0) > break; > printf("sql_select 7\\n"); > } > > > So - if sqlca.sqlcode!=0 - it will break out of the while, after printing the > 5.1 - but we can't see any printf's after the while indicating that its done > that... > > This might just be a c&p issue - but it might be worth adding something like : > printf("sql_select 5\\n"); > EXEC SQL FETCH c_statement USING DESCRIPTOR idesc; > printf("sql_select 5.1\\n"); > printf("sql_select 5.15 - sqlcode now : \\n",sqlca.sqlcode); > > and see if you get that second printf. > > > > > > > > >