Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(183)

Side by Side Diff: third_party/sqlite/sqlite-src-3100200/src/table.c

Issue 1610543003: [sql] Import reference version of SQLite 3.10.2. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 ** 2001 September 15 2 ** 2001 September 15
3 ** 3 **
4 ** The author disclaims copyright to this source code. In place of 4 ** The author disclaims copyright to this source code. In place of
5 ** a legal notice, here is a blessing: 5 ** a legal notice, here is a blessing:
6 ** 6 **
7 ** May you do good and not evil. 7 ** May you do good and not evil.
8 ** May you find forgiveness for yourself and forgive others. 8 ** May you find forgiveness for yourself and forgive others.
9 ** May you share freely, never taking more than you give. 9 ** May you share freely, never taking more than you give.
10 ** 10 **
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 } 83 }
84 84
85 /* Copy over the row data 85 /* Copy over the row data
86 */ 86 */
87 if( argv!=0 ){ 87 if( argv!=0 ){
88 for(i=0; i<nCol; i++){ 88 for(i=0; i<nCol; i++){
89 if( argv[i]==0 ){ 89 if( argv[i]==0 ){
90 z = 0; 90 z = 0;
91 }else{ 91 }else{
92 int n = sqlite3Strlen30(argv[i])+1; 92 int n = sqlite3Strlen30(argv[i])+1;
93 z = sqlite3_malloc( n ); 93 z = sqlite3_malloc64( n );
94 if( z==0 ) goto malloc_failed; 94 if( z==0 ) goto malloc_failed;
95 memcpy(z, argv[i], n); 95 memcpy(z, argv[i], n);
96 } 96 }
97 p->azResult[p->nData++] = z; 97 p->azResult[p->nData++] = z;
98 } 98 }
99 p->nRow++; 99 p->nRow++;
100 } 100 }
101 return 0; 101 return 0;
102 102
103 malloc_failed: 103 malloc_failed:
(...skipping 15 matching lines...) Expand all
119 sqlite3 *db, /* The database on which the SQL executes */ 119 sqlite3 *db, /* The database on which the SQL executes */
120 const char *zSql, /* The SQL to be executed */ 120 const char *zSql, /* The SQL to be executed */
121 char ***pazResult, /* Write the result table here */ 121 char ***pazResult, /* Write the result table here */
122 int *pnRow, /* Write the number of rows in the result here */ 122 int *pnRow, /* Write the number of rows in the result here */
123 int *pnColumn, /* Write the number of columns of result here */ 123 int *pnColumn, /* Write the number of columns of result here */
124 char **pzErrMsg /* Write error messages here */ 124 char **pzErrMsg /* Write error messages here */
125 ){ 125 ){
126 int rc; 126 int rc;
127 TabResult res; 127 TabResult res;
128 128
129 #ifdef SQLITE_ENABLE_API_ARMOR
130 if( !sqlite3SafetyCheckOk(db) || pazResult==0 ) return SQLITE_MISUSE_BKPT;
131 #endif
129 *pazResult = 0; 132 *pazResult = 0;
130 if( pnColumn ) *pnColumn = 0; 133 if( pnColumn ) *pnColumn = 0;
131 if( pnRow ) *pnRow = 0; 134 if( pnRow ) *pnRow = 0;
132 if( pzErrMsg ) *pzErrMsg = 0; 135 if( pzErrMsg ) *pzErrMsg = 0;
133 res.zErrMsg = 0; 136 res.zErrMsg = 0;
134 res.nRow = 0; 137 res.nRow = 0;
135 res.nColumn = 0; 138 res.nColumn = 0;
136 res.nData = 1; 139 res.nData = 1;
137 res.nAlloc = 20; 140 res.nAlloc = 20;
138 res.rc = SQLITE_OK; 141 res.rc = SQLITE_OK;
139 res.azResult = sqlite3_malloc(sizeof(char*)*res.nAlloc ); 142 res.azResult = sqlite3_malloc64(sizeof(char*)*res.nAlloc );
140 if( res.azResult==0 ){ 143 if( res.azResult==0 ){
141 db->errCode = SQLITE_NOMEM; 144 db->errCode = SQLITE_NOMEM;
142 return SQLITE_NOMEM; 145 return SQLITE_NOMEM;
143 } 146 }
144 res.azResult[0] = 0; 147 res.azResult[0] = 0;
145 rc = sqlite3_exec(db, zSql, sqlite3_get_table_cb, &res, pzErrMsg); 148 rc = sqlite3_exec(db, zSql, sqlite3_get_table_cb, &res, pzErrMsg);
146 assert( sizeof(res.azResult[0])>= sizeof(res.nData) ); 149 assert( sizeof(res.azResult[0])>= sizeof(res.nData) );
147 res.azResult[0] = SQLITE_INT_TO_PTR(res.nData); 150 res.azResult[0] = SQLITE_INT_TO_PTR(res.nData);
148 if( (rc&0xff)==SQLITE_ABORT ){ 151 if( (rc&0xff)==SQLITE_ABORT ){
149 sqlite3_free_table(&res.azResult[1]); 152 sqlite3_free_table(&res.azResult[1]);
150 if( res.zErrMsg ){ 153 if( res.zErrMsg ){
151 if( pzErrMsg ){ 154 if( pzErrMsg ){
152 sqlite3_free(*pzErrMsg); 155 sqlite3_free(*pzErrMsg);
153 *pzErrMsg = sqlite3_mprintf("%s",res.zErrMsg); 156 *pzErrMsg = sqlite3_mprintf("%s",res.zErrMsg);
154 } 157 }
155 sqlite3_free(res.zErrMsg); 158 sqlite3_free(res.zErrMsg);
156 } 159 }
157 db->errCode = res.rc; /* Assume 32-bit assignment is atomic */ 160 db->errCode = res.rc; /* Assume 32-bit assignment is atomic */
158 return res.rc; 161 return res.rc;
159 } 162 }
160 sqlite3_free(res.zErrMsg); 163 sqlite3_free(res.zErrMsg);
161 if( rc!=SQLITE_OK ){ 164 if( rc!=SQLITE_OK ){
162 sqlite3_free_table(&res.azResult[1]); 165 sqlite3_free_table(&res.azResult[1]);
163 return rc; 166 return rc;
164 } 167 }
165 if( res.nAlloc>res.nData ){ 168 if( res.nAlloc>res.nData ){
166 char **azNew; 169 char **azNew;
167 azNew = sqlite3_realloc( res.azResult, sizeof(char*)*res.nData ); 170 azNew = sqlite3_realloc64( res.azResult, sizeof(char*)*res.nData );
168 if( azNew==0 ){ 171 if( azNew==0 ){
169 sqlite3_free_table(&res.azResult[1]); 172 sqlite3_free_table(&res.azResult[1]);
170 db->errCode = SQLITE_NOMEM; 173 db->errCode = SQLITE_NOMEM;
171 return SQLITE_NOMEM; 174 return SQLITE_NOMEM;
172 } 175 }
173 res.azResult = azNew; 176 res.azResult = azNew;
174 } 177 }
175 *pazResult = &res.azResult[1]; 178 *pazResult = &res.azResult[1];
176 if( pnColumn ) *pnColumn = res.nColumn; 179 if( pnColumn ) *pnColumn = res.nColumn;
177 if( pnRow ) *pnRow = res.nRow; 180 if( pnRow ) *pnRow = res.nRow;
(...skipping 10 matching lines...) Expand all
188 int i, n; 191 int i, n;
189 azResult--; 192 azResult--;
190 assert( azResult!=0 ); 193 assert( azResult!=0 );
191 n = SQLITE_PTR_TO_INT(azResult[0]); 194 n = SQLITE_PTR_TO_INT(azResult[0]);
192 for(i=1; i<n; i++){ if( azResult[i] ) sqlite3_free(azResult[i]); } 195 for(i=1; i<n; i++){ if( azResult[i] ) sqlite3_free(azResult[i]); }
193 sqlite3_free(azResult); 196 sqlite3_free(azResult);
194 } 197 }
195 } 198 }
196 199
197 #endif /* SQLITE_OMIT_GET_TABLE */ 200 #endif /* SQLITE_OMIT_GET_TABLE */
OLDNEW
« no previous file with comments | « third_party/sqlite/sqlite-src-3100200/src/status.c ('k') | third_party/sqlite/sqlite-src-3100200/src/tclsqlite.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698