Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Remove unused opcodes from the VDBE and fix a bug in the substr() function. (CVS 405) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
e8611e0c052ddac477f83df485fa5dc8 |
User & Date: | drh 2002-02-28 03:31:11.000 |
Context
2002-02-28
| ||
04:00 | Fix bugs in substr() for UTF-8. (CVS 406) (check-in: e9fd9e7b0f user: drh tags: trunk) | |
03:31 | Remove unused opcodes from the VDBE and fix a bug in the substr() function. (CVS 405) (check-in: e8611e0c05 user: drh tags: trunk) | |
03:14 | Change the IFNULL and NVL functions to COALESCE. Change MIN and MAX so that they require at least one argument. (CVS 404) (check-in: 7d86749d4a user: drh tags: trunk) | |
Changes
Changes to src/func.c.
︙ | ︙ | |||
12 13 14 15 16 17 18 | ** This file contains the C functions that implement various SQL ** functions of SQLite. ** ** There is only one exported symbol in this file - the function ** sqliteRegisterBuildinFunctions() found at the bottom of the file. ** All other code has file scope. ** | | | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | ** This file contains the C functions that implement various SQL ** functions of SQLite. ** ** There is only one exported symbol in this file - the function ** sqliteRegisterBuildinFunctions() found at the bottom of the file. ** All other code has file scope. ** ** $Id: func.c,v 1.11 2002/02/28 03:31:11 drh Exp $ */ #include <ctype.h> #include <math.h> #include <stdlib.h> #include <assert.h> #include "sqliteInt.h" |
︙ | ︙ | |||
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | #ifdef SQLITE_UTF8 for(len=0, z2=z; *z2; z2++){ if( (0xc0&*z)!=0x80 ) len++; } #else len = strlen(z); #endif if( p1<0 ){ p1 += len; }else if( p1>0 ){ p1--; } if( p1+p2>len ){ p2 = len-p1; } #ifdef SQLITE_UTF8 for(i=0; i<p1; i++){ assert( z[i] ); if( (z[i]&0xc0)!=0x80 ) p1++; } for(; i<p1+p2; i++){ assert( z[i] ); if( (z[i]&0xc0)!=0x80 ) p2++; } #endif sqlite_set_result_string(context, &z[p1], p2); } /* ** Implementation of the round() function */ static void roundFunc(sqlite_func *context, int argc, const char **argv){ | > > > > > | 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | #ifdef SQLITE_UTF8 for(len=0, z2=z; *z2; z2++){ if( (0xc0&*z)!=0x80 ) len++; } #else len = strlen(z); #endif if( p1<0 ){ p1 += len; if( p1<0 ){ p2 += p1; p1 = 0; } }else if( p1>0 ){ p1--; } if( p1+p2>len ){ p2 = len-p1; } #ifdef SQLITE_UTF8 for(i=0; i<p1; i++){ assert( z[i] ); if( (z[i]&0xc0)!=0x80 ) p1++; } for(; i<p1+p2; i++){ assert( z[i] ); if( (z[i]&0xc0)!=0x80 ) p2++; } #endif if( p2<0 ) p2 = 0; sqlite_set_result_string(context, &z[p1], p2); } /* ** Implementation of the round() function */ static void roundFunc(sqlite_func *context, int argc, const char **argv){ |
︙ | ︙ |
Changes to src/vdbe.c.
︙ | ︙ | |||
26 27 28 29 30 31 32 | ** type to the other occurs as necessary. ** ** Most of the code in this file is taken up by the sqliteVdbeExec() ** function which does the work of interpreting a VDBE program. ** But other routines are also provided to help in building up ** a program instruction by instruction. ** | | | 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | ** type to the other occurs as necessary. ** ** Most of the code in this file is taken up by the sqliteVdbeExec() ** function which does the work of interpreting a VDBE program. ** But other routines are also provided to help in building up ** a program instruction by instruction. ** ** $Id: vdbe.c,v 1.129 2002/02/28 03:31:11 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> /* ** The following global variable is incremented every time a cursor ** moves, either by the OP_MoveTo or the OP_Next opcode. The test |
︙ | ︙ | |||
1043 1044 1045 1046 1047 1048 1049 | "Last", "Rewind", "Next", "Destroy", "Clear", "CreateIndex", "CreateTable", "IntegrityCk", "IdxPut", "IdxDelete", "IdxRecno", "IdxGT", "IdxGE", "MemLoad", "MemStore", "ListWrite", "ListRewind", "ListRead", "ListReset", "SortPut", "SortMakeRec", "SortMakeKey", "Sort", "SortNext", "SortCallback", "SortReset", "FileOpen", "FileRead", | | | | | | | | | | | < | | < | 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 | "Last", "Rewind", "Next", "Destroy", "Clear", "CreateIndex", "CreateTable", "IntegrityCk", "IdxPut", "IdxDelete", "IdxRecno", "IdxGT", "IdxGE", "MemLoad", "MemStore", "ListWrite", "ListRewind", "ListRead", "ListReset", "SortPut", "SortMakeRec", "SortMakeKey", "Sort", "SortNext", "SortCallback", "SortReset", "FileOpen", "FileRead", "FileColumn", "AggReset", "AggFocus", "AggNext", "AggSet", "AggGet", "AggFunc", "AggInit", "SetInsert", "SetFound", "SetNotFound", "MakeRecord", "MakeKey", "MakeIdxKey", "IncrKey", "Goto", "If", "Halt", "ColumnCount", "ColumnName", "Callback", "NullCallback", "Integer", "String", "Pop", "Dup", "Pull", "Push", "MustBeInt", "Add", "AddImm", "Subtract", "Multiply", "Divide", "Remainder", "BitAnd", "BitOr", "BitNot", "ShiftLeft", "ShiftRight", "AbsValue", "Like", "Glob", "Eq", "Ne", "Lt", "Le", "Gt", "Ge", "IsNull", "NotNull", "Negative", "And", "Or", "Not", "Concat", "Noop", "Function", "Limit", }; /* ** Given the name of an opcode, return its number. Return 0 if ** there is no match. ** ** This routine is used for testing and debugging. |
︙ | ︙ | |||
1764 1765 1766 1767 1768 1769 1770 | divide_by_zero: PopStack(p, 2); p->tos = nos; aStack[nos].flags = STK_Null; break; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 | divide_by_zero: PopStack(p, 2); p->tos = nos; aStack[nos].flags = STK_Null; break; } /* Opcode: Function P1 * P3 ** ** Invoke a user function (P3 is a pointer to a Function structure that ** defines the function) with P1 string arguments taken from the stack. ** Pop all arguments from the stack and push back the result. ** ** See also: AggFunc |
︙ | ︙ | |||
4492 4493 4494 4495 4496 4497 4498 | AggInsert(&p->agg, zKey, nKey); if( sqlite_malloc_failed ) goto no_mem; } POPSTACK; break; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 | AggInsert(&p->agg, zKey, nKey); if( sqlite_malloc_failed ) goto no_mem; } POPSTACK; break; } /* Opcode: AggSet * P2 * ** ** Move the top of the stack into the P2-th field of the current ** aggregate. String values are duplicated into new memory. */ case OP_AggSet: { AggElem *pFocus = AggInFocus(p->agg); |
︙ | ︙ | |||
4701 4702 4703 4704 4705 4706 4707 | sqliteHashFind(&p->aSet[i].hash, zStack[tos], aStack[tos].n)==0 ){ pc = pOp->p2 - 1; } POPSTACK; break; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 | sqliteHashFind(&p->aSet[i].hash, zStack[tos], aStack[tos].n)==0 ){ pc = pOp->p2 - 1; } POPSTACK; break; } /* An other opcode is illegal... */ default: { sprintf(zBuf,"%d",pOp->opcode); sqliteSetString(pzErrMsg, "unknown opcode ", zBuf, 0); rc = SQLITE_INTERNAL; |
︙ | ︙ |
Changes to src/vdbe.h.
︙ | ︙ | |||
11 12 13 14 15 16 17 | ************************************************************************* ** Header file for the Virtual DataBase Engine (VDBE) ** ** This header defines the interface to the virtual database engine ** or VDBE. The VDBE implements an abstract machine that runs a ** simple program to access and modify the underlying database. ** | | | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | ************************************************************************* ** Header file for the Virtual DataBase Engine (VDBE) ** ** This header defines the interface to the virtual database engine ** or VDBE. The VDBE implements an abstract machine that runs a ** simple program to access and modify the underlying database. ** ** $Id: vdbe.h,v 1.49 2002/02/28 03:31:12 drh Exp $ */ #ifndef _SQLITE_VDBE_H_ #define _SQLITE_VDBE_H_ #include <stdio.h> /* ** A single VDBE is an opaque structure named "Vdbe". Only routines |
︙ | ︙ | |||
132 133 134 135 136 137 138 | #define OP_FileOpen 55 #define OP_FileRead 56 #define OP_FileColumn 57 #define OP_AggReset 58 #define OP_AggFocus 59 | < | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | < < < | | | | | | | | | | | | | | | | < < | | | | 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 | #define OP_FileOpen 55 #define OP_FileRead 56 #define OP_FileColumn 57 #define OP_AggReset 58 #define OP_AggFocus 59 #define OP_AggNext 60 #define OP_AggSet 61 #define OP_AggGet 62 #define OP_AggFunc 63 #define OP_AggInit 64 #define OP_SetInsert 65 #define OP_SetFound 66 #define OP_SetNotFound 67 #define OP_MakeRecord 68 #define OP_MakeKey 69 #define OP_MakeIdxKey 70 #define OP_IncrKey 71 #define OP_Goto 72 #define OP_If 73 #define OP_Halt 74 #define OP_ColumnCount 75 #define OP_ColumnName 76 #define OP_Callback 77 #define OP_NullCallback 78 #define OP_Integer 79 #define OP_String 80 #define OP_Pop 81 #define OP_Dup 82 #define OP_Pull 83 #define OP_Push 84 #define OP_MustBeInt 85 #define OP_Add 86 #define OP_AddImm 87 #define OP_Subtract 88 #define OP_Multiply 89 #define OP_Divide 90 #define OP_Remainder 91 #define OP_BitAnd 92 #define OP_BitOr 93 #define OP_BitNot 94 #define OP_ShiftLeft 95 #define OP_ShiftRight 96 #define OP_AbsValue 97 #define OP_Like 98 #define OP_Glob 99 #define OP_Eq 100 #define OP_Ne 101 #define OP_Lt 102 #define OP_Le 103 #define OP_Gt 104 #define OP_Ge 105 #define OP_IsNull 106 #define OP_NotNull 107 #define OP_Negative 108 #define OP_And 109 #define OP_Or 110 #define OP_Not 111 #define OP_Concat 112 #define OP_Noop 113 #define OP_Function 114 #define OP_Limit 115 #define OP_MAX 115 /* ** Prototypes for the VDBE interface. See comments on the implementation ** for a description of what each of these routines does. */ Vdbe *sqliteVdbeCreate(sqlite*); void sqliteVdbeCreateCallback(Vdbe*, int*); |
︙ | ︙ |