Index: parse.c =================================================================== RCS file: /usr/local/cvsroot/psqlodbc/psqlodbc/parse.c,v retrieving revision 1.47 diff -u -r1.47 parse.c --- parse.c 21 Jul 2004 12:29:58 -0000 1.47 +++ parse.c 9 Feb 2005 14:32:58 -0000 @@ -334,6 +334,7 @@ char in_field = FALSE, in_expr = FALSE, in_func = FALSE, + out_func = FALSE, in_dot = FALSE, in_as = FALSE; int j, @@ -677,14 +678,33 @@ out_table = TRUE; continue; } - if (out_table && !in_table) /* new table */ + if (out_table && !in_table && !in_func) /* new table */ { if (!dquote) { if (token[0] == '(' || - token[0] == ')') + token[0] == ')') continue; + + /* + * Detect a function call that looks like a table, eg. + * SELECT * FROM version() + * + * This needs work to properly handle functions found in the from + * clause, but this at least prevents nasty errors for now. + * + * DJP, 2005-01-08 + */ + if (ptr[0] == '(') + { + in_func = TRUE; + mylog("**** got function = '%s'\n", token); + mylog("FIXME: functions in the FROM clause are currently ignored!!\n"); + continue; + } } + + if (!(stmt->ntab % TAB_INCR)) { ti = (TABLE_INFO **) realloc(ti, (stmt->ntab + TAB_INCR) * sizeof(TABLE_INFO *)); @@ -725,6 +745,35 @@ continue; } + if (out_table && !in_table && in_func) /* old function */ + { + /* Just skipped a function alias */ + if (out_func) + { + in_func = FALSE; + out_func = FALSE; + mylog("leaving func (and ignoring alias)\n"); + continue; + } + + /* Normal function, no alias */ + if (token[0] == ')' && (ptr[0] == ',' || strlen(ptr) == 0)) + { + in_func = FALSE; + mylog("leaving func.\n"); + continue; + } + + /* Function with following alias */ + if (token[0] == ')') + { + out_func = TRUE; + continue; + } + + + } + if (!dquote && stricmp(token, "JOIN") == 0) { in_table = FALSE;