/ Changes On Branch automatic-index-affinity
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Changes In Branch automatic-index-affinity Excluding Merge-Ins

This is equivalent to a diff from 97914266cb to 0613665274

2017-01-16
18:10
Back out check-in [0b3174e0b1364c] and replace it with a better fix for \ticket [91e2e8ba6ff2e2] - a fix that does not cause the problem identified by ticket [7ffd1ca1d2ad4ec]. Add new test cases for both tickets. (check-in: 9b64af7b52 user: drh tags: trunk)
16:43
Back out check-in [0b3174e0b1364c] and replace it with a better fix for ticket [91e2e8ba6ff2e2] - a fix that does not cause the problem identified by ticket [7ffd1ca1d2ad4ec]. (Closed-Leaf check-in: 0613665274 user: drh tags: automatic-index-affinity)
16:01
Add test cases for tickets [91e2e8ba6ff2e2] and [7ffd1ca1d2ad4ec]. (check-in: 9d0dfe0b08 user: drh tags: automatic-index-affinity)
11:54
An example showing how to improve performance of sqlite3VdbeSerialPut() using the GCC intrinsic function __builtin_bswap64(). (Leaf check-in: e42ed9b4ad user: drh tags: builtin-bswap64)
2017-01-13
22:21
Merge updates from trunk. (check-in: 8b42b8e31a user: mistachkin tags: winSectorSize)
18:24
Fix a problem preventing resumption of RBU operations after recovering from a process or system failure that occurs during the incremental-checkpoint phase. (check-in: 97914266cb user: dan tags: trunk)
12:53
Fix the build for SQLITE_ENABLE_MEMORY_MANAGEMENT. (check-in: 8c85b8fdd7 user: drh tags: trunk)

Changes to src/delete.c.

869
870
871
872
873
874
875




876
877
878
879
880
881
882
    ** But we are getting ready to store this value back into an index, where
    ** it should be converted by to INTEGER again.  So omit the OP_RealAffinity
    ** opcode if it is present */
    sqlite3VdbeDeletePriorOpcode(v, OP_RealAffinity);
  }
  if( regOut ){
    sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase, nCol, regOut);




  }
  sqlite3ReleaseTempRange(pParse, regBase, nCol);
  return regBase;
}

/*
** If a prior call to sqlite3GenerateIndexKey() generated a jump-over label







>
>
>
>







869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
    ** But we are getting ready to store this value back into an index, where
    ** it should be converted by to INTEGER again.  So omit the OP_RealAffinity
    ** opcode if it is present */
    sqlite3VdbeDeletePriorOpcode(v, OP_RealAffinity);
  }
  if( regOut ){
    sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase, nCol, regOut);
    if( pIdx->pTable->pSelect ){
      const char *zAff = sqlite3IndexAffinityStr(pParse->db, pIdx);
      sqlite3VdbeChangeP4(v, -1, zAff, P4_TRANSIENT);
    }
  }
  sqlite3ReleaseTempRange(pParse, regBase, nCol);
  return regBase;
}

/*
** If a prior call to sqlite3GenerateIndexKey() generated a jump-over label

Changes to src/update.c.

67
68
69
70
71
72
73

74
75
76
77
78
79
80
81
82
83
84
85
86
    VdbeComment((v, "%s.%s", pTab->zName, pCol->zName));
    assert( i<pTab->nCol );
    sqlite3ValueFromExpr(sqlite3VdbeDb(v), pCol->pDflt, enc, 
                         pCol->affinity, &pValue);
    if( pValue ){
      sqlite3VdbeAppendP4(v, pValue, P4_MEM);
    }

#ifndef SQLITE_OMIT_FLOATING_POINT
    if( pTab->aCol[i].affinity==SQLITE_AFF_REAL ){
      sqlite3VdbeAddOp1(v, OP_RealAffinity, iReg);
    }
#endif
  }
}

/*
** Process an UPDATE statement.
**
**   UPDATE OR IGNORE table_wxyz SET a=b, c=d WHERE e<5 AND f NOT NULL;
**          \_______/ \________/     \______/       \________________/







>

|
|
|

<







67
68
69
70
71
72
73
74
75
76
77
78
79

80
81
82
83
84
85
86
    VdbeComment((v, "%s.%s", pTab->zName, pCol->zName));
    assert( i<pTab->nCol );
    sqlite3ValueFromExpr(sqlite3VdbeDb(v), pCol->pDflt, enc, 
                         pCol->affinity, &pValue);
    if( pValue ){
      sqlite3VdbeAppendP4(v, pValue, P4_MEM);
    }
  }
#ifndef SQLITE_OMIT_FLOATING_POINT
  if( pTab->aCol[i].affinity==SQLITE_AFF_REAL ){
    sqlite3VdbeAddOp1(v, OP_RealAffinity, iReg);
  }
#endif

}

/*
** Process an UPDATE statement.
**
**   UPDATE OR IGNORE table_wxyz SET a=b, c=d WHERE e<5 AND f NOT NULL;
**          \_______/ \________/     \______/       \________________/

Added test/affinity3.test.























































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# 2017-01-16
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
#
# Test cases for bugs:
#
#    https://www.sqlite.org/src/info/91e2e8ba6ff2e2
#    https://www.sqlite.org/src/info/7ffd1ca1d2ad4ecf
#

set testdir [file dirname $argv0]
source $testdir/tester.tcl

# Ticket https://www.sqlite.org/src/info/91e2e8ba6ff2e2 (2011-09-19)
# Automatic index causes undesired type conversions
#
do_execsql_test affinity3-100 {
  CREATE TABLE customer (id INT PRIMARY KEY);
  CREATE TABLE apr (id INT PRIMARY KEY, apr REAL);
  
  CREATE VIEW v1 AS
  SELECT c.id, i.apr
  FROM customer c
  LEFT JOIN apr i ON i.id=c.id;
  
  CREATE VIEW v2 AS
  SELECT c.id, v1.apr
  FROM customer c
  LEFT JOIN v1 ON v1.id=c.id;
  
  INSERT INTO customer (id) VALUES (1);
  INSERT INTO apr (id, apr) VALUES (1, 12);
  INSERT INTO customer (id) VALUES (2);
  INSERT INTO apr (id, apr) VALUES (2, 12.01);
}
do_execsql_test affinity3-110 {
  PRAGMA automatic_index=ON;
  SELECT id, (apr / 100), typeof(apr) apr_type  FROM v1;
} {1 0.12 real 2 0.1201 real}
do_execsql_test affinity3-120 {
  SELECT id, (apr / 100), typeof(apr) apr_type  FROM v2;
} {1 0.12 real 2 0.1201 real}
do_execsql_test affinity3-130 {
  PRAGMA automatic_index=OFF;
  SELECT id, (apr / 100), typeof(apr) apr_type  FROM v1;
} {1 0.12 real 2 0.1201 real}
do_execsql_test affinity3-140 {
  SELECT id, (apr / 100), typeof(apr) apr_type  FROM v2;
} {1 0.12 real 2 0.1201 real}

# Ticket https://www.sqlite.org/src/info/7ffd1ca1d2ad4ecf  (2017-01-16)
# Incorrect affinity when using automatic indexes 
#
do_execsql_test affinity3-200 {
  CREATE TABLE map_integer (id INT, name);
  INSERT INTO map_integer VALUES(1,'a');
  CREATE TABLE map_text (id TEXT, name);
  INSERT INTO map_text VALUES('4','e');
  CREATE TABLE data (id TEXT, name);
  INSERT INTO data VALUES(1,'abc');
  INSERT INTO data VALUES('4','xyz');
  CREATE VIEW idmap as
      SELECT * FROM map_integer
      UNION SELECT * FROM map_text;
  CREATE TABLE mzed AS SELECT * FROM idmap;
}

do_execsql_test affinity3-210 {
  PRAGMA automatic_index=ON;
  SELECT * FROM data JOIN idmap USING(id);
} {1 abc a 4 xyz e}
do_execsql_test affinity3-220 {
  SELECT * FROM data JOIN mzed USING(id);
} {1 abc a 4 xyz e}

do_execsql_test affinity3-250 {
  PRAGMA automatic_index=OFF;
  SELECT * FROM data JOIN idmap USING(id);
} {1 abc a 4 xyz e}
do_execsql_test affinity3-260 {
  SELECT * FROM data JOIN mzed USING(id);
} {1 abc a 4 xyz e}

finish_test