update postgresReservedWords

This commit is contained in:
Nash Tsai 2014-09-22 09:47:30 +08:00
parent d0f8fb545b
commit 614db2ac9e
1 changed files with 592 additions and 160 deletions

View File

@ -12,6 +12,7 @@ import (
// func init() {
// RegisterDialect("postgres", &postgres{})
// }
// from http://www.postgresql.org/docs/current/static/sql-keywords-appendix.html
var (
postgresReservedWords = map[string]bool{
"A": true,
@ -329,6 +330,437 @@ var (
"INSTANTIABLE": true,
"INSTEAD": true,
"INT": true,
"INTEGER": true,
"INTEGRITY": true,
"INTERSECT": true,
"INTERSECTION": true,
"INTERVAL": true,
"INTO": true,
"INVOKER": true,
"IS": true,
"ISNULL": true,
"ISOLATION": true,
"JOIN": true,
"K": true,
"KEY": true,
"KEY_MEMBER": true,
"KEY_TYPE": true,
"LABEL": true,
"LAG": true,
"LANGUAGE": true,
"LARGE": true,
"LAST": true,
"LAST_VALUE": true,
"LATERAL": true,
"LC_COLLATE": true,
"LC_CTYPE": true,
"LEAD": true,
"LEADING": true,
"LEAKPROOF": true,
"LEAST": true,
"LEFT": true,
"LENGTH": true,
"LEVEL": true,
"LIBRARY": true,
"LIKE": true,
"LIKE_REGEX": true,
"LIMIT": true,
"LINK": true,
"LISTEN": true,
"LN": true,
"LOAD": true,
"LOCAL": true,
"LOCALTIME": true,
"LOCALTIMESTAMP": true,
"LOCATION": true,
"LOCATOR": true,
"LOCK": true,
"LOWER": true,
"M": true,
"MAP": true,
"MAPPING": true,
"MATCH": true,
"MATCHED": true,
"MATERIALIZED": true,
"MAX": true,
"MAXVALUE": true,
"MAX_CARDINALITY": true,
"MEMBER": true,
"MERGE": true,
"MESSAGE_LENGTH": true,
"MESSAGE_OCTET_LENGTH": true,
"MESSAGE_TEXT": true,
"METHOD": true,
"MIN": true,
"MINUTE": true,
"MINVALUE": true,
"MOD": true,
"MODE": true,
"MODIFIES": true,
"MODULE": true,
"MONTH": true,
"MORE": true,
"MOVE": true,
"MULTISET": true,
"MUMPS": true,
"NAME": true,
"NAMES": true,
"NAMESPACE": true,
"NATIONAL": true,
"NATURAL": true,
"NCHAR": true,
"NCLOB": true,
"NESTING": true,
"NEW": true,
"NEXT": true,
"NFC": true,
"NFD": true,
"NFKC": true,
"NFKD": true,
"NIL": true,
"NO": true,
"NONE": true,
"NORMALIZE": true,
"NORMALIZED": true,
"NOT": true,
"NOTHING": true,
"NOTIFY": true,
"NOTNULL": true,
"NOWAIT": true,
"NTH_VALUE": true,
"NTILE": true,
"NULL": true,
"NULLABLE": true,
"NULLIF": true,
"NULLS": true,
"NUMBER": true,
"NUMERIC": true,
"OBJECT": true,
"OCCURRENCES_REGEX": true,
"OCTETS": true,
"OCTET_LENGTH": true,
"OF": true,
"OFF": true,
"OFFSET": true,
"OIDS": true,
"OLD": true,
"ON": true,
"ONLY": true,
"OPEN": true,
"OPERATOR": true,
"OPTION": true,
"OPTIONS": true,
"OR": true,
"ORDER": true,
"ORDERING": true,
"ORDINALITY": true,
"OTHERS": true,
"OUT": true,
"OUTER": true,
"OUTPUT": true,
"OVER": true,
"OVERLAPS": true,
"OVERLAY": true,
"OVERRIDING": true,
"OWNED": true,
"OWNER": true,
"P": true,
"PAD": true,
"PARAMETER": true,
"PARAMETER_MODE": true,
"PARAMETER_NAME": true,
"PARAMETER_ORDINAL_POSITION": true,
"PARAMETER_SPECIFIC_CATALOG": true,
"PARAMETER_SPECIFIC_NAME": true,
"PARAMETER_SPECIFIC_SCHEMA": true,
"PARSER": true,
"PARTIAL": true,
"PARTITION": true,
"PASCAL": true,
"PASSING": true,
"PASSTHROUGH": true,
"PASSWORD": true,
"PATH": true,
"PERCENT": true,
"PERCENTILE_CONT": true,
"PERCENTILE_DISC": true,
"PERCENT_RANK": true,
"PERIOD": true,
"PERMISSION": true,
"PLACING": true,
"PLANS": true,
"PLI": true,
"PORTION": true,
"POSITION": true,
"POSITION_REGEX": true,
"POWER": true,
"PRECEDES": true,
"PRECEDING": true,
"PRECISION": true,
"PREPARE": true,
"PREPARED": true,
"PRESERVE": true,
"PRIMARY": true,
"PRIOR": true,
"PRIVILEGES": true,
"PROCEDURAL": true,
"PROCEDURE": true,
"PROGRAM": true,
"PUBLIC": true,
"QUOTE": true,
"RANGE": true,
"RANK": true,
"READ": true,
"READS": true,
"REAL": true,
"REASSIGN": true,
"RECHECK": true,
"RECOVERY": true,
"RECURSIVE": true,
"REF": true,
"REFERENCES": true,
"REFERENCING": true,
"REFRESH": true,
"REGR_AVGX": true,
"REGR_AVGY": true,
"REGR_COUNT": true,
"REGR_INTERCEPT": true,
"REGR_R2": true,
"REGR_SLOPE": true,
"REGR_SXX": true,
"REGR_SXY": true,
"REGR_SYY": true,
"REINDEX": true,
"RELATIVE": true,
"RELEASE": true,
"RENAME": true,
"REPEATABLE": true,
"REPLACE": true,
"REPLICA": true,
"REQUIRING": true,
"RESET": true,
"RESPECT": true,
"RESTART": true,
"RESTORE": true,
"RESTRICT": true,
"RESULT": true,
"RETURN": true,
"RETURNED_CARDINALITY": true,
"RETURNED_LENGTH": true,
"RETURNED_OCTET_LENGTH": true,
"RETURNED_SQLSTATE": true,
"RETURNING": true,
"RETURNS": true,
"REVOKE": true,
"RIGHT": true,
"ROLE": true,
"ROLLBACK": true,
"ROLLUP": true,
"ROUTINE": true,
"ROUTINE_CATALOG": true,
"ROUTINE_NAME": true,
"ROUTINE_SCHEMA": true,
"ROW": true,
"ROWS": true,
"ROW_COUNT": true,
"ROW_NUMBER": true,
"RULE": true,
"SAVEPOINT": true,
"SCALE": true,
"SCHEMA": true,
"SCHEMA_NAME": true,
"SCOPE": true,
"SCOPE_CATALOG": true,
"SCOPE_NAME": true,
"SCOPE_SCHEMA": true,
"SCROLL": true,
"SEARCH": true,
"SECOND": true,
"SECTION": true,
"SECURITY": true,
"SELECT": true,
"SELECTIVE": true,
"SELF": true,
"SENSITIVE": true,
"SEQUENCE": true,
"SEQUENCES": true,
"SERIALIZABLE": true,
"SERVER": true,
"SERVER_NAME": true,
"SESSION": true,
"SESSION_USER": true,
"SET": true,
"SETOF": true,
"SETS": true,
"SHARE": true,
"SHOW": true,
"SIMILAR": true,
"SIMPLE": true,
"SIZE": true,
"SMALLINT": true,
"SNAPSHOT": true,
"SOME": true,
"SOURCE": true,
"SPACE": true,
"SPECIFIC": true,
"SPECIFICTYPE": true,
"SPECIFIC_NAME": true,
"SQL": true,
"SQLCODE": true,
"SQLERROR": true,
"SQLEXCEPTION": true,
"SQLSTATE": true,
"SQLWARNING": true,
"SQRT": true,
"STABLE": true,
"STANDALONE": true,
"START": true,
"STATE": true,
"STATEMENT": true,
"STATIC": true,
"STATISTICS": true,
"STDDEV_POP": true,
"STDDEV_SAMP": true,
"STDIN": true,
"STDOUT": true,
"STORAGE": true,
"STRICT": true,
"STRIP": true,
"STRUCTURE": true,
"STYLE": true,
"SUBCLASS_ORIGIN": true,
"SUBMULTISET": true,
"SUBSTRING": true,
"SUBSTRING_REGEX": true,
"SUCCEEDS": true,
"SUM": true,
"SYMMETRIC": true,
"SYSID": true,
"SYSTEM": true,
"SYSTEM_TIME": true,
"SYSTEM_USER": true,
"T": true,
"TABLE": true,
"TABLES": true,
"TABLESAMPLE": true,
"TABLESPACE": true,
"TABLE_NAME": true,
"TEMP": true,
"TEMPLATE": true,
"TEMPORARY": true,
"TEXT": true,
"THEN": true,
"TIES": true,
"TIME": true,
"TIMESTAMP": true,
"TIMEZONE_HOUR": true,
"TIMEZONE_MINUTE": true,
"TO": true,
"TOKEN": true,
"TOP_LEVEL_COUNT": true,
"TRAILING": true,
"TRANSACTION": true,
"TRANSACTIONS_COMMITTED": true,
"TRANSACTIONS_ROLLED_BACK": true,
"TRANSACTION_ACTIVE": true,
"TRANSFORM": true,
"TRANSFORMS": true,
"TRANSLATE": true,
"TRANSLATE_REGEX": true,
"TRANSLATION": true,
"TREAT": true,
"TRIGGER": true,
"TRIGGER_CATALOG": true,
"TRIGGER_NAME": true,
"TRIGGER_SCHEMA": true,
"TRIM": true,
"TRIM_ARRAY": true,
"TRUE": true,
"TRUNCATE": true,
"TRUSTED": true,
"TYPE": true,
"TYPES": true,
"UESCAPE": true,
"UNBOUNDED": true,
"UNCOMMITTED": true,
"UNDER": true,
"UNENCRYPTED": true,
"UNION": true,
"UNIQUE": true,
"UNKNOWN": true,
"UNLINK": true,
"UNLISTEN": true,
"UNLOGGED": true,
"UNNAMED": true,
"UNNEST": true,
"UNTIL": true,
"UNTYPED": true,
"UPDATE": true,
"UPPER": true,
"URI": true,
"USAGE": true,
"USER": true,
"USER_DEFINED_TYPE_CATALOG": true,
"USER_DEFINED_TYPE_CODE": true,
"USER_DEFINED_TYPE_NAME": true,
"USER_DEFINED_TYPE_SCHEMA": true,
"USING": true,
"VACUUM": true,
"VALID": true,
"VALIDATE": true,
"VALIDATOR": true,
"VALUE": true,
"VALUES": true,
"VALUE_OF": true,
"VARBINARY": true,
"VARCHAR": true,
"VARIADIC": true,
"VARYING": true,
"VAR_POP": true,
"VAR_SAMP": true,
"VERBOSE": true,
"VERSION": true,
"VERSIONING": true,
"VIEW": true,
"VOLATILE": true,
"WHEN": true,
"WHENEVER": true,
"WHERE": true,
"WHITESPACE": true,
"WIDTH_BUCKET": true,
"WINDOW": true,
"WITH": true,
"WITHIN": true,
"WITHOUT": true,
"WORK": true,
"WRAPPER": true,
"WRITE": true,
"XML": true,
"XMLAGG": true,
"XMLATTRIBUTES": true,
"XMLBINARY": true,
"XMLCAST": true,
"XMLCOMMENT": true,
"XMLCONCAT": true,
"XMLDECLARATION": true,
"XMLDOCUMENT": true,
"XMLELEMENT": true,
"XMLEXISTS": true,
"XMLFOREST": true,
"XMLITERATE": true,
"XMLNAMESPACES": true,
"XMLPARSE": true,
"XMLPI": true,
"XMLQUERY": true,
"XMLROOT": true,
"XMLSCHEMA": true,
"XMLSERIALIZE": true,
"XMLTABLE": true,
"XMLTEXT": true,
"XMLVALIDATE": true,
"YEAR": true,
"YES": true,
"ZONE": true,
}
)
@ -595,7 +1027,7 @@ func (db *postgres) GetTables() ([]*core.Table, error) {
func (db *postgres) GetIndexes(tableName string) (map[string]*core.Index, error) {
args := []interface{}{tableName}
s := "SELECT indexname, indexdef FROM pg_indexes WHERE schemaname = 'public' and tablename = $1"
s := "SELECT indexname, indexdef FROM pg_indexes WHERE schemaname='public' AND tablename=$1"
rows, err := db.DB().Query(s, args...)
if err != nil {