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

Overview
Comment:Fix some bugs in the code that uses sqlite4_num.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | sqlite4-num
Files: files | file ages | folders
SHA1: 598f3f02f430044c59ccc422cd0b19b965d9a9d2
User & Date: dan 2013-05-25 16:41:35.458
Context
2013-05-25
20:13
Further progress on using decimal arithmetic. check-in: f875ba1944 user: dan tags: sqlite4-num
16:41
Fix some bugs in the code that uses sqlite4_num. check-in: 598f3f02f4 user: dan tags: sqlite4-num
2013-05-24
20:28
Start using sqlite4_num to store numeric SQL values. This commit is more buggy than not. check-in: d94f6e934e user: dan tags: sqlite4-num
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/vdbe.c.
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
  flags = pIn1->flags | pIn2->flags;
  if( (flags & MEM_Null)!=0 ) goto arithmetic_result_is_null;

  switch( pOp->opcode ){
    case OP_Add: 
      pOut->u.num = sqlite4_num_add(pIn1->u.num, pIn2->u.num); break;
    case OP_Subtract: 
      pOut->u.num = sqlite4_num_sub(pIn1->u.num, pIn2->u.num); break;
    case OP_Multiply: 
      pOut->u.num = sqlite4_num_mul(pIn1->u.num, pIn2->u.num); break;
    case OP_Divide: 
      pOut->u.num = sqlite4_num_div(pIn1->u.num, pIn2->u.num); break;
    default: {
      sqlite4_num_to_int64(pIn1->u.num, &iA);
      sqlite4_num_to_int64(pIn1->u.num, &iB);







|







1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
  flags = pIn1->flags | pIn2->flags;
  if( (flags & MEM_Null)!=0 ) goto arithmetic_result_is_null;

  switch( pOp->opcode ){
    case OP_Add: 
      pOut->u.num = sqlite4_num_add(pIn1->u.num, pIn2->u.num); break;
    case OP_Subtract: 
      pOut->u.num = sqlite4_num_sub(pIn2->u.num, pIn1->u.num); break;
    case OP_Multiply: 
      pOut->u.num = sqlite4_num_mul(pIn1->u.num, pIn2->u.num); break;
    case OP_Divide: 
      pOut->u.num = sqlite4_num_div(pIn1->u.num, pIn2->u.num); break;
    default: {
      sqlite4_num_to_int64(pIn1->u.num, &iA);
      sqlite4_num_to_int64(pIn1->u.num, &iB);
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
**
** To force any register to be an integer, just add 0.
*/
case OP_AddImm: {            /* in1 */
  pIn1 = &aMem[pOp->p1];
  memAboutToChange(p, pIn1);
  sqlite4VdbeMemIntegerify(pIn1);
  pIn1->u.num = sqlite4_num_add(pIn1->u.num, sqlite4_num_from_int64(1));
  break;
}

/* Opcode: MustBeInt P1 P2 * * *
** 
** Force the value in register P1 to be an integer.  If the value
** in P1 is not an integer and cannot be converted into an integer







|







1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
**
** To force any register to be an integer, just add 0.
*/
case OP_AddImm: {            /* in1 */
  pIn1 = &aMem[pOp->p1];
  memAboutToChange(p, pIn1);
  sqlite4VdbeMemIntegerify(pIn1);
  pIn1->u.num = sqlite4_num_add(pIn1->u.num, sqlite4_num_from_int64(pOp->p2));
  break;
}

/* Opcode: MustBeInt P1 P2 * * *
** 
** Force the value in register P1 to be an integer.  If the value
** in P1 is not an integer and cannot be converted into an integer