-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
table_meta_cache_test.go
76 lines (62 loc) · 2.04 KB
/
table_meta_cache_test.go
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package oci8
import (
"database/sql"
"fmt"
"log"
"testing"
)
func TestFetchInfo(t *testing.T) {
db, err := sql.Open("oci8", "C##STUDENT/[email protected]:1521/ORCL")
if err != nil {
log.Fatal(err)
}
defer db.Close()
// s := "SELECT OWNER, TABLE_NAME, COLUMN_NAME, DATA_TYPE, CHAR_LENGTH, DATA_PRECISION, " +
// "DATA_SCALE, NULLABLE, DATA_DEFAULT, DATA_LENGTH, COLUMN_ID FROM ALL_TAB_COLUMNS WHERE TABLE_NAME = "
// tablename := "AAASWPAAHAAAAIEAAC"
// s := "SELECT OWNER, TABLE_NAME FROM ALL_TAB_COLUMNS WHERE TABLE_NAME = :1 "
// s := "SELECT CON.INDEX_NAME, COL.COLUMN_NAME, IDX.UNIQUENESS " +
// "FROM USER_CONSTRAINTS CON, USER_CONS_COLUMNS COL, ALL_INDEXES IDX " +
// "WHERE CON.CONSTRAINT_NAME = COL.CONSTRAINT_NAME " +
// "AND idx.INDEX_NAME = con.INDEX_NAME " +
// "AND CON.CONSTRAINT_TYPE='P' AND COL.TABLE_NAME = "
// s = fmt.Sprintf(s, tablename)
// s := "SELECT OWNER, TABLE_NAME FROM ALL_TAB_COLUMNS WHERE TABLE_NAME = "
// s := "SELECT COL1,COL2 FROM test WHERE \"ROWID\" IN (:1)"
rows, err := db.Query(SelectUndoLogSql, testXID, testBranchID)
// fmt.Println(s)
if err != nil {
t.Errorf("Query Error")
}
for rows.Next() {
var (
retXID string
retBranchID int64
retContext string
retRollbackInfo []byte
retState int64
)
// var f3 string
rows.Scan(&retBranchID, &retXID, &retContext, &retRollbackInfo, &retState)
// rows.Scan(&f1)
fmt.Printf("XID:%s, branchID:%d, Context:%s, State:%d \n", retXID, retBranchID, retContext, retState)
fmt.Printf("RollbackInfo: %x\n", retRollbackInfo)
}
rows.Close()
}
func TestInsertUndologManager(t *testing.T) {
db, err := sql.Open("oci8", "C##STUDENT/[email protected]:1521/ORCL")
// testundoLogID := int64(1234)
testBranchID := int64(12345)
testXID := "123.123:123456"
testctx := "dfjjajaf"
testRollbackInfo := []byte("adbdfbadf")
testLogStatus := int64(1)
if err != nil {
log.Fatal(err)
}
_, err = db.Exec(InsertUndoLogSql, testBranchID, testXID, testctx, testRollbackInfo, testLogStatus)
if err != nil {
log.Fatal(err)
}
}