1#' @include connection.R
2NULL
3
4#' Make R/S-Plus identifiers into legal SQL identifiers
5#'
6#' These methods are straight-forward implementations of the corresponding
7#' generic functions.
8#'
9#' @param dbObj any MySQL object (e.g., \code{MySQLDriver}).
10#' @param snames a character vector of R/S-Plus
11#'   identifiers (symbols) from which we need to make SQL identifiers.
12#' @param name a character vector of SQL identifiers we want to check against
13#'   keywords from the DBMS.
14#' @param unique logical describing whether the resulting set of SQL names
15#'   should be unique.  Its default is \code{TRUE}. Following the SQL 92
16#'   standard, uniqueness of SQL identifiers is determined regardless of whether
17#'   letters are upper or lower case.
18#' @param allow.keywords logical describing whether SQL keywords should be
19#'   allowed in the resulting set of SQL names.  Its default is \code{TRUE}
20#' @param keywords a character vector with SQL keywords, by default it is
21#'   \code{.MySQLKeywords} define in \code{RMySQL}. This may be overriden by
22#'   users.
23#' @param case a character string specifying whether to make the
24#'   comparison as lower case, upper case, or any of the two.  it defaults to
25#'   \code{any}.
26#' @param ... Unused, needed for compatibility with generic.
27#' @export
28setMethod("make.db.names", c("MySQLConnection", "character"),
29  function(dbObj, snames, keywords, unique, allow.keywords, ...) {
30    make.db.names.default(snames, .MySQLKeywords, unique, allow.keywords)
31  }
32)
33
34#' @export
35#' @rdname make.db.names-MySQLConnection-character-method
36setMethod("SQLKeywords", "MySQLConnection", def = function(dbObj, ...) {
37  .MySQLKeywords
38})
39
40#' @export
41#' @rdname make.db.names-MySQLConnection-character-method
42setMethod("isSQLKeyword", c("MySQLConnection", "character"),
43  function(dbObj, name, keywords = .MySQLKeywords, case, ...) {
44    isSQLKeyword.default(name, keywords = .MySQLKeywords, case = case)
45  }
46)
47
48## the following reserved words were taken from Section 6.1.7
49## of the MySQL Manual, Version 4.1.1-alpha, html format.
50.MySQLKeywords <- c("ADD", "ALL", "ALTER", "ANALYZE", "AND", "AS", "ASC",
51  "ASENSITIVE", "AUTO_INCREMENT", "BDB", "BEFORE", "BERKELEYDB", "BETWEEN",
52  "BIGINT", "BINARY", "BLOB", "BOTH", "BY", "CALL", "CASCADE", "CASE", "CHANGE",
53  "CHAR", "CHARACTER", "CHECK", "COLLATE", "COLUMN", "COLUMNS",
54  "CONDITION", "CONNECTION", "CONSTRAINT", "CONTINUE", "CREATE",
55  "CROSS", "CURRENT_DATE", "CURRENT_TIME", "CURRENT_TIMESTAMP",
56  "CURSOR", "DATABASE", "DATABASES", "DAY_HOUR", "DAY_MICROSECOND",
57  "DAY_MINUTE", "DAY_SECOND", "DEC", "DECIMAL", "DECLARE", "DEFAULT",
58  "DELAYED", "DELETE", "DESC", "DESCRIBE", "DISTINCT", "DISTINCTROW",
59  "DIV", "DOUBLE", "DROP", "ELSE", "ELSEIF", "ENCLOSED", "ESCAPED",
60  "EXISTS", "EXIT", "EXPLAIN", "FALSE", "FETCH", "FIELDS", "FLOAT",
61  "FOR", "FORCE", "FOREIGN", "FOUND", "FROM", "FULLTEXT", "GRANT",
62  "GROUP", "HAVING", "HIGH_PRIORITY", "HOUR_MICROSECOND", "HOUR_MINUTE",
63  "HOUR_SECOND", "IF", "IGNORE", "IN", "INDEX", "INFILE", "INNER",
64  "INNODB", "INOUT", "INSENSITIVE", "INSERT", "INT", "INTEGER",
65  "INTERVAL", "INTO", "IO_THREAD", "IS", "ITERATE", "JOIN", "KEY",
66  "KEYS", "KILL", "LEADING", "LEAVE", "LEFT", "LIKE", "LIMIT",
67  "LINES", "LOAD", "LOCALTIME", "LOCALTIMESTAMP", "LOCK", "LONG",
68  "LONGBLOB", "LONGTEXT", "LOOP", "LOW_PRIORITY", "MASTER_SERVER_ID",
69  "MATCH", "MEDIUMBLOB", "MEDIUMINT", "MEDIUMTEXT", "MIDDLEINT",
70  "MINUTE_MICROSECOND", "MINUTE_SECOND", "MOD", "NATURAL", "NOT",
71  "NO_WRITE_TO_BINLOG", "NULL", "NUMERIC", "ON", "OPTIMIZE", "OPTION",
72  "OPTIONALLY", "OR", "ORDER", "OUT", "OUTER", "OUTFILE", "PRECISION",
73  "PRIMARY", "PRIVILEGES", "PROCEDURE", "PURGE", "READ", "REAL",
74  "REFERENCES", "REGEXP", "RENAME", "REPEAT", "REPLACE", "REQUIRE",
75  "RESTRICT", "RETURN", "RETURNS", "REVOKE", "RIGHT", "RLIKE",
76  "SECOND_MICROSECOND", "SELECT", "SENSITIVE", "SEPARATOR", "SET",
77  "SHOW", "SMALLINT", "SOME", "SONAME", "SPATIAL", "SPECIFIC",
78  "SQL", "SQLEXCEPTION", "SQLSTATE", "SQLWARNING", "SQL_BIG_RESULT",
79  "SQL_CALC_FOUND_ROWS", "SQL_SMALL_RESULT", "SSL", "STARTING",
80  "STRAIGHT_JOIN", "STRIPED", "TABLE", "TABLES", "TERMINATED",
81  "THEN", "TINYBLOB", "TINYINT", "TINYTEXT", "TO", "TRAILING",
82  "TRUE", "TYPES", "UNDO", "UNION", "UNIQUE", "UNLOCK", "UNSIGNED",
83  "UPDATE", "USAGE", "USE", "USER_RESOURCES", "USING", "UTC_DATE",
84  "UTC_TIME", "UTC_TIMESTAMP", "VALUES", "VARBINARY", "VARCHAR",
85  "VARCHARACTER", "VARYING", "WHEN", "WHERE", "WHILE", "WITH",
86  "WRITE", "XOR", "YEAR_MONTH", "ZEROFILL"
87)
88