/ Check-in [3d7434a9d8]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix the urifuncs.c extension (used for testing and debugging only) so that the sqlite3_filename_database() SQL function and its siblings correctly handle an invalid schema name passed in as the argument.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 3d7434a9d85dae9135473d1c58c22ac01a282e654807aa10be9b39f127291594
User & Date: drh 2020-01-14 16:50:09
Context
2020-01-15
16:20
Do not allow the "PRAGMA encoding" statement to change the database encoding if TEMP content exists, or content in any other attached database. Formerly, encoding changes were allowed if just the main database file was empty. Ticket [a08879a4a476eea9]. check-in: 03b003c988 user: drh tags: trunk
14:26
Merge all recent enhancements and fixes from trunk. check-in: f783917800 user: drh tags: reuse-schema
14:11
Merge recent enhancements and fixes from trunk. check-in: 35eae71a4d user: drh tags: wal2
13:48
Merge all recent enhancements and fixes from trunk. check-in: 110a081f12 user: drh tags: begin-concurrent-pnu
13:34
Merge fixes and enhancements from trunk into begin-concurrent. check-in: 95ba2f50fd user: drh tags: begin-concurrent
12:49
Merge all recent enhancements and fixes from trunk into the apple-osx branch. check-in: dadedf41c7 user: drh tags: apple-osx
2020-01-14
16:50
Fix the urifuncs.c extension (used for testing and debugging only) so that the sqlite3_filename_database() SQL function and its siblings correctly handle an invalid schema name passed in as the argument. check-in: 3d7434a9d8 user: drh tags: trunk
16:39
Remove an ALWAYS on a branch for improved database corruption detection in btree.c:freeSpace(). Test case found by dbsqlfuzz. check-in: 54bf048119 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ext/misc/urifuncs.c.

19
20
21
22
23
24
25


26
27
28
29
30
31
32
...
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
...
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
...
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
**         sqlite3_uri_key()
**         sqlite3_filename_database()
**         sqlite3_filename_journal()
**         sqlite3_filename_wal()
**         sqlite3_db_filename()
**
** These SQL functions are for testing and demonstration purposes only.


*/
#include "sqlite3ext.h"
SQLITE_EXTENSION_INIT1
#include <assert.h>
#include <string.h>

/*
................................................................................
  sqlite3_context *context,
  int argc,
  sqlite3_value **argv
){
  const char *zSchema = (const char*)sqlite3_value_text(argv[0]);
  sqlite3 *db = sqlite3_context_db_handle(context);
  const char *zFile = sqlite3_db_filename(db, zSchema);
  const char *zRes = sqlite3_filename_database(zFile);
  sqlite3_result_text(context, zRes, -1, SQLITE_TRANSIENT);
}

/*
** SQL function:    sqlite3_filename_journal(SCHEMA)
**
** Return the rollback journal filename for SCHEMA
................................................................................
  sqlite3_context *context,
  int argc,
  sqlite3_value **argv
){
  const char *zSchema = (const char*)sqlite3_value_text(argv[0]);
  sqlite3 *db = sqlite3_context_db_handle(context);
  const char *zFile = sqlite3_db_filename(db, zSchema);
  const char *zRes = sqlite3_filename_journal(zFile);
  sqlite3_result_text(context, zRes, -1, SQLITE_TRANSIENT);
}

/*
** SQL function:    sqlite3_filename_wal(SCHEMA)
**
** Return the WAL filename for SCHEMA
................................................................................
  sqlite3_context *context,
  int argc,
  sqlite3_value **argv
){
  const char *zSchema = (const char*)sqlite3_value_text(argv[0]);
  sqlite3 *db = sqlite3_context_db_handle(context);
  const char *zFile = sqlite3_db_filename(db, zSchema);
  const char *zRes = sqlite3_filename_wal(zFile);
  sqlite3_result_text(context, zRes, -1, SQLITE_TRANSIENT);
}

#ifdef _WIN32
__declspec(dllexport)
#endif
int sqlite3_urifuncs_init(







>
>







 







|







 







|







 







|







19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
...
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
...
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
...
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
**         sqlite3_uri_key()
**         sqlite3_filename_database()
**         sqlite3_filename_journal()
**         sqlite3_filename_wal()
**         sqlite3_db_filename()
**
** These SQL functions are for testing and demonstration purposes only.
**
**
*/
#include "sqlite3ext.h"
SQLITE_EXTENSION_INIT1
#include <assert.h>
#include <string.h>

/*
................................................................................
  sqlite3_context *context,
  int argc,
  sqlite3_value **argv
){
  const char *zSchema = (const char*)sqlite3_value_text(argv[0]);
  sqlite3 *db = sqlite3_context_db_handle(context);
  const char *zFile = sqlite3_db_filename(db, zSchema);
  const char *zRes = zFile ? sqlite3_filename_database(zFile) : 0;
  sqlite3_result_text(context, zRes, -1, SQLITE_TRANSIENT);
}

/*
** SQL function:    sqlite3_filename_journal(SCHEMA)
**
** Return the rollback journal filename for SCHEMA
................................................................................
  sqlite3_context *context,
  int argc,
  sqlite3_value **argv
){
  const char *zSchema = (const char*)sqlite3_value_text(argv[0]);
  sqlite3 *db = sqlite3_context_db_handle(context);
  const char *zFile = sqlite3_db_filename(db, zSchema);
  const char *zRes = zFile ? sqlite3_filename_journal(zFile) : 0;
  sqlite3_result_text(context, zRes, -1, SQLITE_TRANSIENT);
}

/*
** SQL function:    sqlite3_filename_wal(SCHEMA)
**
** Return the WAL filename for SCHEMA
................................................................................
  sqlite3_context *context,
  int argc,
  sqlite3_value **argv
){
  const char *zSchema = (const char*)sqlite3_value_text(argv[0]);
  sqlite3 *db = sqlite3_context_db_handle(context);
  const char *zFile = sqlite3_db_filename(db, zSchema);
  const char *zRes = zFile ? sqlite3_filename_wal(zFile) : 0;
  sqlite3_result_text(context, zRes, -1, SQLITE_TRANSIENT);
}

#ifdef _WIN32
__declspec(dllexport)
#endif
int sqlite3_urifuncs_init(