forked from 4D-JP/code-audit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_key_index_stats.txt
54 lines (43 loc) · 1.78 KB
/
get_key_index_stats.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
$indexTypeMap:=New collection
$indexTypeMap[1]:="b-tree"
$indexTypeMap[3]:="cluster"
$indexTypeMap[7]:="auto"
$indexTypeMap[8]:="object"
ARRAY LONGINT($types;0)
//1-field
Begin SQL
SELECT DISTINCT(_USER_INDEXES.INDEX_TYPE)
FROM _USER_CONS_COLUMNS,_USER_COLUMNS,_USER_CONSTRAINTS,_USER_INDEXES,_USER_IND_COLUMNS
WHERE _USER_CONSTRAINTS.CONSTRAINT_TYPE= '4DR'
AND _USER_CONSTRAINTS.CONSTRAINT_ID = _USER_CONS_COLUMNS.CONSTRAINT_ID
AND _USER_COLUMNS.TABLE_ID = _USER_CONSTRAINTS.RELATED_TABLE_ID
AND _USER_COLUMNS.COLUMN_ID = _USER_CONS_COLUMNS.RELATED_COLUMN_ID
AND _USER_COLUMNS.TABLE_ID = _USER_IND_COLUMNS.TABLE_ID
AND _USER_COLUMNS.COLUMN_ID = _USER_IND_COLUMNS.COLUMN_ID
AND _USER_INDEXES.INDEX_ID = _USER_IND_COLUMNS.INDEX_ID
INTO :$types;
End SQL
$types1:=New collection
ARRAY TO COLLECTION($types1;$types)
C_LONGINT($type)
ARRAY TEXT($fields;0)
$results:=New collection
For each ($type;$types1)
Begin SQL
SELECT DISTINCT(CONCAT(CONCAT(CONCAT('[:',_USER_COLUMNS.TABLE_ID),']:'),_USER_COLUMNS.COLUMN_ID))
FROM _USER_CONS_COLUMNS,_USER_COLUMNS,_USER_CONSTRAINTS,_USER_INDEXES,_USER_IND_COLUMNS
WHERE _USER_CONSTRAINTS.CONSTRAINT_TYPE= '4DR'
AND _USER_CONSTRAINTS.CONSTRAINT_ID = _USER_CONS_COLUMNS.CONSTRAINT_ID
AND _USER_COLUMNS.TABLE_ID = _USER_CONSTRAINTS.RELATED_TABLE_ID
AND _USER_COLUMNS.COLUMN_ID = _USER_CONS_COLUMNS.RELATED_COLUMN_ID
AND _USER_COLUMNS.TABLE_ID = _USER_IND_COLUMNS.TABLE_ID
AND _USER_COLUMNS.COLUMN_ID = _USER_IND_COLUMNS.COLUMN_ID
AND _USER_INDEXES.INDEX_ID = _USER_IND_COLUMNS.INDEX_ID
AND _USER_INDEXES.KEYWORD = FALSE
AND _USER_INDEXES.INDEX_TYPE = :$type
INTO :$fields;
End SQL
$results.push(New collection(\
$indexTypeMap[$type];String(Size of array($fields))).join("\t"))
End for each
SET TEXT TO PASTEBOARD($results.join("\r"))