mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-30 19:03:16 +03:00
Enhance the ".import" command of the CLI so that it is able to insert into a
view that has an instead-of trigger. [forum:/info/3e03c73150f8b9f8|Forum post 3e03c73150f8b9f8]. FossilOrigin-Name: 7dcc3731a9057a91f1b173fbab2841d8a666a945d9bc61d4c20f8a2a279d5ff1
This commit is contained in:
13
manifest
13
manifest
@ -1,5 +1,5 @@
|
|||||||
C Add\sNEVER()\saround\sbranches\sthat\sseems\sto\shave\sbeen\smade\sobsolete\sby\n[a350ea7c6b89725b].
|
C Enhance\sthe\s".import"\scommand\sof\sthe\sCLI\sso\sthat\sit\sis\sable\sto\sinsert\sinto\sa\nview\sthat\shas\san\sinstead-of\strigger.\n[forum:/info/3e03c73150f8b9f8|Forum\spost\s3e03c73150f8b9f8].
|
||||||
D 2024-12-09T13:02:13.294
|
D 2024-12-09T20:37:18.846
|
||||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||||
F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d
|
F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d
|
||||||
@ -778,7 +778,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c
|
|||||||
F src/resolve.c c8a5372b97b2a2e972a280676f06ddb5b74e885d3b1f5ce383f839907b57ef68
|
F src/resolve.c c8a5372b97b2a2e972a280676f06ddb5b74e885d3b1f5ce383f839907b57ef68
|
||||||
F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97
|
F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97
|
||||||
F src/select.c 1c2b2321e1658e02f96da96d3071abcaa6839a1d75edd960a75a0ab11b6041bb
|
F src/select.c 1c2b2321e1658e02f96da96d3071abcaa6839a1d75edd960a75a0ab11b6041bb
|
||||||
F src/shell.c.in 883d1470893d15b65724a42a865a25f12e02ee865ab252480d04d467881f87e4
|
F src/shell.c.in ee54de10e9bd5572f689a6bc0c8e6fa58a8870e1670978ded44412d2715fd908
|
||||||
F src/sqlite.h.in 6afbcaae44140216704a6c82e4c4ea4118c46d5f6573d6c5fa4fc901ed9d369e
|
F src/sqlite.h.in 6afbcaae44140216704a6c82e4c4ea4118c46d5f6573d6c5fa4fc901ed9d369e
|
||||||
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
|
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
|
||||||
F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54
|
F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54
|
||||||
@ -2202,8 +2202,9 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350
|
|||||||
F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7
|
F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7
|
||||||
F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139
|
F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139
|
||||||
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
||||||
P 453c949914770e8f7b9b9dd882db492bf8756c212c816f87bb2e3ed98bcd64e3
|
P cb5bad5c748b7435c43f3ec051736c1cf91ced2be317b0519e5e22523c137290
|
||||||
R 0384aceb4a3c9ceb2d3aa9887b35dede
|
Q +c71acee1cf45abf0429e8b1668315c75b155d7c300d53833aeacd92c9bb3395d
|
||||||
|
R 8d63ad55d843d7344792036678b73c10
|
||||||
U drh
|
U drh
|
||||||
Z 41154152da333de7653292dbe9c04f92
|
Z 4eb938e60b80d29845130c936d5be640
|
||||||
# Remove this line to create a well-formed Fossil manifest.
|
# Remove this line to create a well-formed Fossil manifest.
|
||||||
|
@ -1 +1 @@
|
|||||||
cb5bad5c748b7435c43f3ec051736c1cf91ced2be317b0519e5e22523c137290
|
7dcc3731a9057a91f1b173fbab2841d8a666a945d9bc61d4c20f8a2a279d5ff1
|
||||||
|
@ -6501,14 +6501,20 @@ static void output_reset(ShellState *p){
|
|||||||
/*
|
/*
|
||||||
** Run an SQL command and return the single integer result.
|
** Run an SQL command and return the single integer result.
|
||||||
*/
|
*/
|
||||||
static int db_int(sqlite3 *db, const char *zSql){
|
static int db_int(sqlite3 *db, const char *zSql, ...){
|
||||||
sqlite3_stmt *pStmt;
|
sqlite3_stmt *pStmt;
|
||||||
int res = 0;
|
int res = 0;
|
||||||
sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);
|
char *z;
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, zSql);
|
||||||
|
z = sqlite3_vmprintf(zSql, ap);
|
||||||
|
va_end(ap);
|
||||||
|
sqlite3_prepare_v2(db, z, -1, &pStmt, 0);
|
||||||
if( pStmt && sqlite3_step(pStmt)==SQLITE_ROW ){
|
if( pStmt && sqlite3_step(pStmt)==SQLITE_ROW ){
|
||||||
res = sqlite3_column_int(pStmt,0);
|
res = sqlite3_column_int(pStmt,0);
|
||||||
}
|
}
|
||||||
sqlite3_finalize(pStmt);
|
sqlite3_finalize(pStmt);
|
||||||
|
sqlite3_free(z);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6611,9 +6617,7 @@ static int shell_dbinfo_command(ShellState *p, int nArg, char **azArg){
|
|||||||
zSchemaTab = sqlite3_mprintf("\"%w\".sqlite_schema", zDb);
|
zSchemaTab = sqlite3_mprintf("\"%w\".sqlite_schema", zDb);
|
||||||
}
|
}
|
||||||
for(i=0; i<ArraySize(aQuery); i++){
|
for(i=0; i<ArraySize(aQuery); i++){
|
||||||
char *zSql = sqlite3_mprintf(aQuery[i].zSql, zSchemaTab);
|
int val = db_int(p->db, aQuery[i].zSql, zSchemaTab);
|
||||||
int val = db_int(p->db, zSql);
|
|
||||||
sqlite3_free(zSql);
|
|
||||||
sqlite3_fprintf(p->out, "%-20s %d\n", aQuery[i].zName, val);
|
sqlite3_fprintf(p->out, "%-20s %d\n", aQuery[i].zName, val);
|
||||||
}
|
}
|
||||||
sqlite3_free(zSchemaTab);
|
sqlite3_free(zSchemaTab);
|
||||||
@ -8271,8 +8275,8 @@ FROM (\
|
|||||||
}else{
|
}else{
|
||||||
/* Formulate the columns spec, close the DB, zero *pDb. */
|
/* Formulate the columns spec, close the DB, zero *pDb. */
|
||||||
char *zColsSpec = 0;
|
char *zColsSpec = 0;
|
||||||
int hasDupes = db_int(*pDb, zHasDupes);
|
int hasDupes = db_int(*pDb, "%s", zHasDupes);
|
||||||
int nDigits = (hasDupes)? db_int(*pDb, zColDigits) : 0;
|
int nDigits = (hasDupes)? db_int(*pDb, "%s", zColDigits) : 0;
|
||||||
if( hasDupes ){
|
if( hasDupes ){
|
||||||
#ifdef SHELL_COLUMN_RENAME_CLEAN
|
#ifdef SHELL_COLUMN_RENAME_CLEAN
|
||||||
rc = sqlite3_exec(*pDb, zDedoctor, 0, 0, 0);
|
rc = sqlite3_exec(*pDb, zDedoctor, 0, 0, 0);
|
||||||
@ -8287,7 +8291,7 @@ FROM (\
|
|||||||
sqlite3_finalize(pStmt);
|
sqlite3_finalize(pStmt);
|
||||||
if( rc!=SQLITE_DONE ) rc_err_oom_die(SQLITE_NOMEM);
|
if( rc!=SQLITE_DONE ) rc_err_oom_die(SQLITE_NOMEM);
|
||||||
}
|
}
|
||||||
assert(db_int(*pDb, zHasDupes)==0); /* Consider: remove this */
|
assert(db_int(*pDb, "%s", zHasDupes)==0); /* Consider: remove this */
|
||||||
rc = sqlite3_prepare_v2(*pDb, zCollectVar, -1, &pStmt, 0);
|
rc = sqlite3_prepare_v2(*pDb, zCollectVar, -1, &pStmt, 0);
|
||||||
rc_err_oom_die(rc);
|
rc_err_oom_die(rc);
|
||||||
rc = sqlite3_step(pStmt);
|
rc = sqlite3_step(pStmt);
|
||||||
@ -9337,7 +9341,11 @@ static int do_meta_command(char *zLine, ShellState *p){
|
|||||||
while( xRead(&sCtx) && sCtx.cTerm==sCtx.cColSep ){}
|
while( xRead(&sCtx) && sCtx.cTerm==sCtx.cColSep ){}
|
||||||
}
|
}
|
||||||
import_append_char(&sCtx, 0); /* To ensure sCtx.z is allocated */
|
import_append_char(&sCtx, 0); /* To ensure sCtx.z is allocated */
|
||||||
if( sqlite3_table_column_metadata(p->db, zSchema, zTable,0,0,0,0,0,0) ){
|
if( sqlite3_table_column_metadata(p->db, zSchema, zTable,0,0,0,0,0,0)
|
||||||
|
&& 0==db_int(p->db, "SELECT count(*) FROM \"%w\".sqlite_schema"
|
||||||
|
" WHERE name=%Q AND type='view'",
|
||||||
|
zSchema ? zSchema : "main", zTable)
|
||||||
|
){
|
||||||
/* Table does not exist. Create it. */
|
/* Table does not exist. Create it. */
|
||||||
sqlite3 *dbCols = 0;
|
sqlite3 *dbCols = 0;
|
||||||
char *zRenames = 0;
|
char *zRenames = 0;
|
||||||
|
Reference in New Issue
Block a user