aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/odbc/convert.c
diff options
context:
space:
mode:
authorHiroshi Inoue <inoue@tpf.co.jp>2002-08-01 03:07:50 +0000
committerHiroshi Inoue <inoue@tpf.co.jp>2002-08-01 03:07:50 +0000
commit7dfc7e9e8cf7e480948b68e7fbb12577e18e84e4 (patch)
treeee67e41f0668736b54c25f45d55c46e5a7532956 /src/interfaces/odbc/convert.c
parentce7565ab91100747d250ef67d72af5c1b01150d4 (diff)
downloadpostgresql-7dfc7e9e8cf7e480948b68e7fbb12577e18e84e4.tar.gz
postgresql-7dfc7e9e8cf7e480948b68e7fbb12577e18e84e4.zip
1) Improve the handling of the queries like (select ..) union (select ..)
whose first non-space character is '('. 2) Handle Insert .. () VALUES ().
Diffstat (limited to 'src/interfaces/odbc/convert.c')
-rw-r--r--src/interfaces/odbc/convert.c44
1 files changed, 43 insertions, 1 deletions
diff --git a/src/interfaces/odbc/convert.c b/src/interfaces/odbc/convert.c
index 15a1a23c737..2b586192320 100644
--- a/src/interfaces/odbc/convert.c
+++ b/src/interfaces/odbc/convert.c
@@ -1622,6 +1622,34 @@ table_for_update(const char *stmt, int *endpos)
return !wstmt[0] || isspace((unsigned char) wstmt[0]);
}
+/*----------
+ * Check if the statement is
+ * INSERT INTO ... () VALUES ()
+ * This isn't really a strict check but ...
+ *----------
+ */
+static BOOL
+insert_without_target(const char *stmt, int *endpos)
+{
+ const char *wstmt = stmt;
+
+ while (isspace((unsigned char) *(++wstmt)));
+ if (!*wstmt)
+ return FALSE;
+ if (strnicmp(wstmt, "VALUES", 6))
+ return FALSE;
+ wstmt += 6;
+ if (!wstmt[0] || !isspace((unsigned char) wstmt[0]))
+ return FALSE;
+ while (isspace((unsigned char) *(++wstmt)));
+ if (*wstmt != '(' || *(++wstmt) != ')')
+ return FALSE;
+ wstmt++;
+ *endpos = wstmt - stmt;
+ return !wstmt[0] || isspace((unsigned char) wstmt[0])
+ || ';' == wstmt[0];
+}
+
#ifdef MULTIBYTE
#define my_strchr(conn, s1,c1) pg_mbschr(conn->ccsc, s1,c1)
#else
@@ -1963,7 +1991,7 @@ inner_process_tokens(QueryParse *qp, QueryBuild *qb)
qb->npos -= qp->declare_pos;
}
}
- if (qp->token_len == 3)
+ else if (qp->token_len == 3)
{
int endpos;
@@ -1985,6 +2013,20 @@ inner_process_tokens(QueryParse *qp, QueryBuild *qb)
}
}
}
+ else if (qp->token_len == 2)
+ {
+ int endpos;
+
+ if (STMT_TYPE_INSERT == qp->statement_type &&
+ strnicmp(qp->token_save, "()", 2) == 0 &&
+ insert_without_target(&qp->statement[qp->opos], &endpos))
+ {
+ qb->npos -= 2;
+ CVT_APPEND_STR(qb, "DEFAULT VALUES");
+ qp->opos += endpos;
+ return SQL_SUCCESS;
+ }
+ }
}
}
else if (qp->prev_token_end)