Skip to content

Commit 902f9d5

Browse files
committed
Upgrade bundled library to 2.8.14 + misc fixes
(http://www.sqlite.org/cvstrac/chngview?cn=1742)
1 parent 1da45c2 commit 902f9d5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+5989
-5395
lines changed

ext/sqlite/config.m4

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,21 @@ if test "$PHP_SQLITE" != "no"; then
6868
PHP_ADD_BUILD_DIR($ext_builddir/libsqlite/src)
6969
AC_CHECK_SIZEOF(char *,4)
7070
AC_DEFINE(SQLITE_PTR_SZ, SIZEOF_CHAR_P, [Size of a pointer])
71-
dnl use latin 1 for now; the utf-8 handling in funcs.c uses assert(),
72-
dnl which is a bit silly and something we want to avoid
73-
SQLITE_ENCODING="ISO8859"
74-
dnl SQLITE_ENCODING="UTF-8"
75-
dnl AC_DEFINE(SQLITE_UTF8,1,[if SQLite should use utf-8 encoding])
71+
dnl use latin 1 for SQLite older than 2.8.9; the utf-8 handling
72+
dnl in funcs.c uses assert(), which is a bit silly and something
73+
dnl we want to avoid. This assert() was removed in SQLite 2.8.9.
74+
if test "$PHP_SQLITE_UTF8" = "yes"; then
75+
SQLITE_ENCODING="UTF8"
76+
AC_DEFINE(SQLITE_UTF8, 1, [ ])
77+
else
78+
SQLITE_ENCODING="ISO8859"
79+
fi
7680
PHP_SUBST(SQLITE_ENCODING)
7781

78-
AC_PATH_PROG(LEMON,lemon,no)
79-
PHP_SUBST(LEMON)
80-
8182
SQLITE_VERSION=`cat $ext_srcdir/libsqlite/VERSION`
8283
PHP_SUBST(SQLITE_VERSION)
84+
85+
sed -e s/--VERS--/$SQLITE_VERSION/ -e s/--ENCODING--/$SQLITE_ENCODING/ $ext_srcdir/libsqlite/src/sqlite.h.in >$ext_srcdir/libsqlite/src/sqlite.h
8386

8487
if test "$ext_shared" = "no"; then
8588
echo '#include "php_config.h"' > $ext_srcdir/libsqlite/src/config.h
@@ -96,8 +99,6 @@ if test "$PHP_SQLITE" != "no"; then
9699
#endif
97100
EOF
98101

99-
PHP_ADD_MAKEFILE_FRAGMENT
100-
101102
fi
102103

103104
AC_CHECK_FUNCS(usleep nanosleep)

ext/sqlite/libsqlite/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.8.11
1+
2.8.14

ext/sqlite/libsqlite/src/attach.c

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,15 @@
2323
** The pFilename and pDbname arguments are the tokens that define the
2424
** filename and dbname in the ATTACH statement.
2525
*/
26-
void sqliteAttach(Parse *pParse, Token *pFilename, Token *pDbname){
26+
void sqliteAttach(Parse *pParse, Token *pFilename, Token *pDbname, Token *pKey){
2727
Db *aNew;
2828
int rc, i;
2929
char *zFile, *zName;
3030
sqlite *db;
31+
Vdbe *v;
3132

33+
v = sqliteGetVdbe(pParse);
34+
sqliteVdbeAddOp(v, OP_Halt, 0, 0);
3235
if( pParse->explain ) return;
3336
db = pParse->db;
3437
if( db->file_format<4 ){
@@ -88,6 +91,22 @@ void sqliteAttach(Parse *pParse, Token *pFilename, Token *pDbname){
8891
if( rc ){
8992
sqliteErrorMsg(pParse, "unable to open database: %s", zFile);
9093
}
94+
#if SQLITE_HAS_CODEC
95+
{
96+
extern int sqliteCodecAttach(sqlite*, int, void*, int);
97+
char *zKey = 0;
98+
int nKey;
99+
if( pKey && pKey->z && pKey->n ){
100+
sqliteSetNString(&zKey, pKey->z, pKey->n, 0);
101+
sqliteDequote(zKey);
102+
nKey = strlen(zKey);
103+
}else{
104+
zKey = 0;
105+
nKey = 0;
106+
}
107+
sqliteCodecAttach(db, db->nDb-1, zKey, nKey);
108+
}
109+
#endif
91110
sqliteFree(zFile);
92111
db->flags &= ~SQLITE_Initialized;
93112
if( pParse->nErr ) return;
@@ -117,13 +136,18 @@ void sqliteAttach(Parse *pParse, Token *pFilename, Token *pDbname){
117136
void sqliteDetach(Parse *pParse, Token *pDbname){
118137
int i;
119138
sqlite *db;
139+
Vdbe *v;
140+
Db *pDb;
120141

142+
v = sqliteGetVdbe(pParse);
143+
sqliteVdbeAddOp(v, OP_Halt, 0, 0);
121144
if( pParse->explain ) return;
122145
db = pParse->db;
123146
for(i=0; i<db->nDb; i++){
124-
if( db->aDb[i].pBt==0 || db->aDb[i].zName==0 ) continue;
125-
if( strlen(db->aDb[i].zName)!=pDbname->n ) continue;
126-
if( sqliteStrNICmp(db->aDb[i].zName, pDbname->z, pDbname->n)==0 ) break;
147+
pDb = &db->aDb[i];
148+
if( pDb->pBt==0 || pDb->zName==0 ) continue;
149+
if( strlen(pDb->zName)!=pDbname->n ) continue;
150+
if( sqliteStrNICmp(pDb->zName, pDbname->z, pDbname->n)==0 ) break;
127151
}
128152
if( i>=db->nDb ){
129153
sqliteErrorMsg(pParse, "no such database: %T", pDbname);
@@ -138,10 +162,11 @@ void sqliteDetach(Parse *pParse, Token *pDbname){
138162
return;
139163
}
140164
#endif /* SQLITE_OMIT_AUTHORIZATION */
141-
sqliteBtreeClose(db->aDb[i].pBt);
142-
db->aDb[i].pBt = 0;
143-
sqliteFree(db->aDb[i].zName);
165+
sqliteBtreeClose(pDb->pBt);
166+
pDb->pBt = 0;
167+
sqliteFree(pDb->zName);
144168
sqliteResetInternalSchema(db, i);
169+
if( pDb->pAux && pDb->xFreeAux ) pDb->xFreeAux(pDb->pAux);
145170
db->nDb--;
146171
if( i<db->nDb ){
147172
db->aDb[i] = db->aDb[db->nDb];

ext/sqlite/libsqlite/src/auth.c

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,9 @@ int sqlite_set_authorizer(
8585
** user-supplied authorization function returned an illegal value.
8686
*/
8787
static void sqliteAuthBadReturnCode(Parse *pParse, int rc){
88-
char zBuf[20];
89-
sprintf(zBuf, "(%d)", rc);
90-
sqliteSetString(&pParse->zErrMsg, "illegal return value ", zBuf,
91-
" from the authorization function - should be SQLITE_OK, "
92-
"SQLITE_IGNORE, or SQLITE_DENY", (char*)0);
93-
pParse->nErr++;
88+
sqliteErrorMsg(pParse, "illegal return value (%d) from the "
89+
"authorization function - should be SQLITE_OK, SQLITE_IGNORE, "
90+
"or SQLITE_DENY", rc);
9491
pParse->rc = SQLITE_MISUSE;
9592
}
9693

@@ -150,13 +147,11 @@ void sqliteAuthRead(
150147
pExpr->op = TK_NULL;
151148
}else if( rc==SQLITE_DENY ){
152149
if( db->nDb>2 || pExpr->iDb!=0 ){
153-
sqliteSetString(&pParse->zErrMsg,"access to ", zDBase, ".",
154-
pTab->zName, ".", zCol, " is prohibited", (char*)0);
150+
sqliteErrorMsg(pParse, "access to %s.%s.%s is prohibited",
151+
zDBase, pTab->zName, zCol);
155152
}else{
156-
sqliteSetString(&pParse->zErrMsg,"access to ", pTab->zName, ".",
157-
zCol, " is prohibited", (char*)0);
153+
sqliteErrorMsg(pParse, "access to %s.%s is prohibited", pTab->zName,zCol);
158154
}
159-
pParse->nErr++;
160155
pParse->rc = SQLITE_AUTH;
161156
}else if( rc!=SQLITE_OK ){
162157
sqliteAuthBadReturnCode(pParse, rc);
@@ -179,14 +174,13 @@ int sqliteAuthCheck(
179174
sqlite *db = pParse->db;
180175
int rc;
181176

182-
if( db->xAuth==0 ){
177+
if( db->init.busy || db->xAuth==0 ){
183178
return SQLITE_OK;
184179
}
185180
rc = db->xAuth(db->pAuthArg, code, zArg1, zArg2, zArg3, pParse->zAuthContext);
186181
if( rc==SQLITE_DENY ){
187-
sqliteSetString(&pParse->zErrMsg, "not authorized", (char*)0);
182+
sqliteErrorMsg(pParse, "not authorized");
188183
pParse->rc = SQLITE_AUTH;
189-
pParse->nErr++;
190184
}else if( rc!=SQLITE_OK && rc!=SQLITE_IGNORE ){
191185
rc = SQLITE_DENY;
192186
sqliteAuthBadReturnCode(pParse, rc);

0 commit comments

Comments
 (0)