File: sqlite3-param-indexes.patch

package info (click to toggle)
iceape 1.1.14-1.1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 290,208 kB
  • ctags: 313,748
  • sloc: cpp: 1,767,785; ansic: 988,664; xml: 104,327; makefile: 45,924; asm: 34,989; sh: 29,843; perl: 26,861; cs: 6,232; java: 5,513; python: 3,221; lex: 306; php: 244; pascal: 230; csh: 132; objc: 97; yacc: 79; ada: 49; awk: 14; sed: 4; sql: 4
file content (80 lines) | stat: -rw-r--r-- 2,264 bytes parent folder | download | duplicates (4)
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
diff -ru orig/sqlite333/sqlite3.h sqlite333/sqlite3.h
--- orig/sqlite333/sqlite3.h	2006-01-31 08:23:57.000000000 -0800
+++ sqlite333/sqlite3.h	2006-02-08 12:12:42.156250000 -0800
@@ -1377,6 +1377,20 @@
 # undef double
 #endif
 
+/*
+** Given a wildcard parameter name, return the set of indexes of the
+** variables with that name.  If there are no variables with the given
+** name, return 0.  Otherwise, return the number of indexes returned
+** in *pIndexes.  The array should be freed with
+** sqlite3_free_parameter_indexes.
+*/
+int sqlite3_bind_parameter_indexes(
+    sqlite3_stmt *pStmt,
+    const char *zName,
+    int **pIndexes
+);
+void sqlite3_free_parameter_indexes(int *pIndexes);
+
 #ifdef __cplusplus
 }  /* End of the 'extern "C"' block */
 #endif
Only in sqlite333: sqlite3.h~
diff -ru orig/sqlite333/vdbeapi.c sqlite333/vdbeapi.c
--- orig/sqlite333/vdbeapi.c	2006-01-31 08:23:57.000000000 -0800
+++ sqlite333/vdbeapi.c	2006-02-08 12:13:46.562500000 -0800
@@ -764,6 +764,50 @@
 }
 
 /*
+** Given a wildcard parameter name, return the set of indexes of the
+** variables with that name.  If there are no variables with the given
+** name, return 0.  Otherwise, return the number of indexes returned
+** in *pIndexes.  The array should be freed with
+** sqlite3_free_parameter_indexes.
+*/
+int sqlite3_bind_parameter_indexes(
+    sqlite3_stmt *pStmt,
+    const char *zName,
+    int **pIndexes
+){
+  Vdbe *p = (Vdbe*)pStmt;
+  int i, j, nVars, *indexes;
+  if( p==0 ){
+    return 0;
+  }
+  createVarMap(p);
+  if( !zName )
+    return 0;
+  /* first count */
+  nVars = 0;
+  for(i=0; i<p->nVar; i++){
+    const char *z = p->azVar[i];
+    if( z && strcmp(z,zName)==0 ){
+      nVars++;
+    }
+  }
+  indexes = sqliteMalloc( sizeof(int) * nVars );
+  j = 0;
+  for(i=0; i<p->nVar; i++){
+    const char *z = p->azVar[i];
+    if( z && strcmp(z,zName)==0 )
+      indexes[j++] = i+1;
+  }
+  *pIndexes = indexes;
+  return nVars;
+} 
+  
+void sqlite3_free_parameter_indexes(int *pIndexes)
+{   
+  sqliteFree( pIndexes );
+} 
+
+/*
 ** Transfer all bindings from the first statement over to the second.
 ** If the two statements contain a different number of bindings, then
 ** an SQLITE_ERROR is returned.
Only in sqlite333: vdbeapi.c~