@@ -94,14 +94,22 @@ int codec_pragma(sqlite3* db, int iDb, Parse *pParse, const char *zLeft, const c
9494 if ( sqlite3StrICmp (zLeft , "cipher_version" )== 0 && !zRight ){
9595 codec_vdbe_return_static_string (pParse , "cipher_version" , codec_get_cipher_version ());
9696 }else
97- if ( sqlite3StrICmp (zLeft , "cipher" )== 0 && zRight ){
98- if (ctx ) sqlcipher_codec_ctx_set_cipher (ctx , zRight , 2 ); // change cipher for both
97+ if ( sqlite3StrICmp (zLeft , "cipher" )== 0 ){
98+ if ( zRight ) {
99+ if (ctx ) sqlcipher_codec_ctx_set_cipher (ctx , zRight , 2 ); // change cipher for both
100+ }else {
101+ if (ctx ) sqlcipher_codec_ctx_get_cipher (pParse , ctx , 2 );
102+ }
99103 }else
100104 if ( sqlite3StrICmp (zLeft , "rekey_cipher" )== 0 && zRight ){
101105 if (ctx ) sqlcipher_codec_ctx_set_cipher (ctx , zRight , 1 ); // change write cipher only
102106 }else
103- if ( sqlite3StrICmp (zLeft , "kdf_iter" )== 0 && zRight ){
104- if (ctx ) sqlcipher_codec_ctx_set_kdf_iter (ctx , atoi (zRight ), 2 ); // change of RW PBKDF2 iteration
107+ if ( sqlite3StrICmp (zLeft , "kdf_iter" )== 0 ){
108+ if ( zRight ) {
109+ if (ctx ) sqlcipher_codec_ctx_set_kdf_iter (ctx , atoi (zRight ), 2 ); // change of RW PBKDF2 iteration
110+ } else {
111+ if (ctx ) sqlcipher_codec_ctx_get_kdf_iter (pParse , ctx , 2 );
112+ }
105113 }else
106114 if ( sqlite3StrICmp (zLeft , "fast_kdf_iter" )== 0 && zRight ){
107115 if (ctx ) sqlcipher_codec_ctx_set_fast_kdf_iter (ctx , atoi (zRight ), 2 ); // change of RW PBKDF2 iteration
@@ -111,23 +119,36 @@ int codec_pragma(sqlite3* db, int iDb, Parse *pParse, const char *zLeft, const c
111119 }else
112120 if ( sqlite3StrICmp (zLeft ,"cipher_page_size" )== 0 ){
113121 if (ctx ) {
114- int size = atoi (zRight );
115- rc = sqlcipher_codec_ctx_set_pagesize (ctx , size );
116- if (rc != SQLITE_OK ) sqlcipher_codec_ctx_set_error (ctx , rc );
117- rc = codec_set_btree_to_codec_pagesize (db , pDb , ctx );
118- if (rc != SQLITE_OK ) sqlcipher_codec_ctx_set_error (ctx , rc );
122+ if ( zRight ) {
123+ int size = atoi (zRight );
124+ rc = sqlcipher_codec_ctx_set_pagesize (ctx , size );
125+ if (rc != SQLITE_OK ) sqlcipher_codec_ctx_set_error (ctx , rc );
126+ rc = codec_set_btree_to_codec_pagesize (db , pDb , ctx );
127+ if (rc != SQLITE_OK ) sqlcipher_codec_ctx_set_error (ctx , rc );
128+ } else {
129+ sqlcipher_codec_ctx_get_cipher_pagesize (pParse , ctx );
130+ }
119131 }
120132 }else
121133 if ( sqlite3StrICmp (zLeft ,"cipher_default_use_hmac" )== 0 ){
122- sqlcipher_set_default_use_hmac (sqlite3GetBoolean (zRight ,1 ));
134+ if ( zRight ) {
135+ sqlcipher_set_default_use_hmac (sqlite3GetBoolean (zRight ,1 ));
136+ } else {
137+ sqlcipher_get_default_use_hmac (pParse );
138+ }
123139 }else
124140 if ( sqlite3StrICmp (zLeft ,"cipher_use_hmac" )== 0 ){
125- if (ctx ) {
126- rc = sqlcipher_codec_ctx_set_use_hmac (ctx , sqlite3GetBoolean (zRight ,1 ));
127- if (rc != SQLITE_OK ) sqlcipher_codec_ctx_set_error (ctx , rc );
128- /* since the use of hmac has changed, the page size may also change */
129- rc = codec_set_btree_to_codec_pagesize (db , pDb , ctx );
130- if (rc != SQLITE_OK ) sqlcipher_codec_ctx_set_error (ctx , rc );
141+
142+ if ( zRight ) {
143+ if (ctx ) {
144+ rc = sqlcipher_codec_ctx_set_use_hmac (ctx , sqlite3GetBoolean (zRight ,1 ));
145+ if (rc != SQLITE_OK ) sqlcipher_codec_ctx_set_error (ctx , rc );
146+ /* since the use of hmac has changed, the page size may also change */
147+ rc = codec_set_btree_to_codec_pagesize (db , pDb , ctx );
148+ if (rc != SQLITE_OK ) sqlcipher_codec_ctx_set_error (ctx , rc );
149+ }
150+ } else {
151+ if (ctx ) sqlcipher_codec_ctx_get_use_hmac (pParse , ctx , 2 );
131152 }
132153 }else
133154 if ( sqlite3StrICmp (zLeft ,"cipher_hmac_pgno" )== 0 ){
0 commit comments