aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/odbc/parse.c
diff options
context:
space:
mode:
authorHiroshi Inoue <inoue@tpf.co.jp>2002-04-02 10:50:50 +0000
committerHiroshi Inoue <inoue@tpf.co.jp>2002-04-02 10:50:50 +0000
commitf8da3990b5437e47b7296a6770a3efd215b326d0 (patch)
tree38b031307f4048be70099ad6daf4c8a901c7a177 /src/interfaces/odbc/parse.c
parentc26a44db08677bccc04426b42973bb372e6e3046 (diff)
downloadpostgresql-f8da3990b5437e47b7296a6770a3efd215b326d0.tar.gz
postgresql-f8da3990b5437e47b7296a6770a3efd215b326d0.zip
[HACKERS] Proposed patch for ODBC driver w/ C-a-n-c-e-l
From: Bradley McLean <brad@bradm.net> Patch against 7,2 submitted for comment. This seems to work just fine; Now, when our users submit a 2 hour query with four million row sorts by accident, then cancel it 30 seconds later, it doesn't bog down the server ...
Diffstat (limited to 'src/interfaces/odbc/parse.c')
-rw-r--r--src/interfaces/odbc/parse.c56
1 files changed, 39 insertions, 17 deletions
diff --git a/src/interfaces/odbc/parse.c b/src/interfaces/odbc/parse.c
index d86e62f85bb..cb77fddd836 100644
--- a/src/interfaces/odbc/parse.c
+++ b/src/interfaces/odbc/parse.c
@@ -543,15 +543,21 @@ parse_statement(StatementClass *stmt)
*/
if (in_dot)
{
- irdflds->nfields--;
- strcpy(fi[irdflds->nfields]->dot, fi[irdflds->nfields]->name);
- strcpy(fi[irdflds->nfields]->name, token);
- irdflds->nfields++;
- in_dot = FALSE;
+ int ifld = irdflds->nfields - 1;
+
+ if (fi[ifld]->dot[0])
+ {
+ strcat(fi[ifld]->dot, ".");
+ strcat(fi[ifld]->dot, fi[ifld]->name);
+ }
+ else
+ strcpy(fi[ifld]->dot, fi[ifld]->name);
+ strcpy(fi[ifld]->name, token);
if (delim == ',')
{
mylog("in_dot: got comma\n");
+ in_dot = FALSE;
in_field = FALSE;
}
continue;
@@ -575,6 +581,7 @@ parse_statement(StatementClass *stmt)
/* Function */
if (token[0] == '(')
{
+ in_dot = FALSE;
in_func = TRUE;
blevel = 1;
fi[irdflds->nfields - 1]->func = TRUE;
@@ -594,6 +601,7 @@ parse_statement(StatementClass *stmt)
continue;
}
+ in_dot = FALSE;
if (!stricmp(token, "as"))
{
in_as = TRUE;
@@ -644,6 +652,7 @@ parse_statement(StatementClass *stmt)
return FALSE;
}
+ ti[stmt->ntab]->schema[0] = '\0';
ti[stmt->ntab]->alias[0] = '\0';
strcpy(ti[stmt->ntab]->name, token);
@@ -680,6 +689,7 @@ parse_statement(StatementClass *stmt)
in_table = TRUE;
}
stmt->ntab++;
+ in_dot = FALSE;
continue;
}
@@ -689,9 +699,21 @@ parse_statement(StatementClass *stmt)
out_table = TRUE;
continue;
}
- if (in_table && stricmp(token, "as"))
+ if (in_table)
{
- if (!dquote)
+ if (in_dot)
+ {
+ strcpy(ti[stmt->ntab - 1]->schema, ti[stmt->ntab - 1]->name);
+ strcpy(ti[stmt->ntab - 1]->name, token);
+ in_dot = FALSE;
+ continue;
+ }
+ if (strcmp(token, ".") == 0)
+ {
+ in_dot = TRUE;
+ continue;
+ }
+ if (!dquote && stricmp(token, "as"))
{
if (stricmp(token, "LEFT") == 0 ||
stricmp(token, "RIGHT") == 0 ||
@@ -702,14 +724,14 @@ parse_statement(StatementClass *stmt)
in_table = FALSE;
continue;
}
- }
- strcpy(ti[stmt->ntab - 1]->alias, token);
- mylog("alias for table '%s' is '%s'\n", ti[stmt->ntab - 1]->name, ti[stmt->ntab - 1]->alias);
- in_table = FALSE;
- if (delim == ',')
- {
- out_table = TRUE;
- mylog("more than 1 tables\n");
+ strcpy(ti[stmt->ntab - 1]->alias, token);
+ mylog("alias for table '%s' is '%s'\n", ti[stmt->ntab - 1]->name, ti[stmt->ntab - 1]->alias);
+ in_table = FALSE;
+ if (delim == ',')
+ {
+ out_table = TRUE;
+ mylog("more than 1 tables\n");
+ }
}
}
} /* in_from */
@@ -823,8 +845,8 @@ parse_statement(StatementClass *stmt)
col_stmt = (StatementClass *) hcol_stmt;
col_stmt->internal = TRUE;
- result = PGAPI_Columns(hcol_stmt, "", 0, "", 0,
- ti[i]->name, (SWORD) strlen(ti[i]->name), "", 0, PODBC_NOT_SEARCH_PATTERN);
+ result = PGAPI_Columns(hcol_stmt, "", 0, ti[i]->schema,
+ SQL_NTS, ti[i]->name, SQL_NTS, "", 0, PODBC_NOT_SEARCH_PATTERN);
mylog(" Past PG_Columns\n");
if (result == SQL_SUCCESS)