Lines Matching refs:zSql
882 char *zSql; in shellFakeSchema() local
888 zSql = sqlite3_mprintf("PRAGMA \"%w\".table_info=%Q;", in shellFakeSchema()
890 sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0); in shellFakeSchema()
891 sqlite3_free(zSql); in shellFakeSchema()
1963 const char *zSql = (const char*)sqlite3_value_text(argv[0]); in sha3QueryFunc() local
1983 if( zSql==0 ) return; in sha3QueryFunc()
1985 while( zSql[0] ){ in sha3QueryFunc()
1986 rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, &zSql); in sha3QueryFunc()
1989 zSql, sqlite3_errmsg(db)); in sha3QueryFunc()
3326 char *zSql = 0; in completionNext() local
3331 zSql = sqlite3_mprintf( in completionNext()
3334 zSql, zSep, zDb in completionNext()
3336 if( zSql==0 ) return SQLITE_NOMEM; in completionNext()
3340 sqlite3_prepare_v2(pCur->db, zSql, -1, &pCur->pStmt, 0); in completionNext()
3341 sqlite3_free(zSql); in completionNext()
3350 char *zSql = 0; in completionNext() local
3355 zSql = sqlite3_mprintf( in completionNext()
3360 zSql, zSep, zDb, zDb in completionNext()
3362 if( zSql==0 ) return SQLITE_NOMEM; in completionNext()
3366 sqlite3_prepare_v2(pCur->db, zSql, -1, &pCur->pStmt, 0); in completionNext()
3367 sqlite3_free(zSql); in completionNext()
6787 const char *zSql, /* SQL statement(s) to add */
6976 char *zSql; /* SQL statement */ member
7184 const char *zSql /* SQL statement to compile */ in idxPrepareStmt() argument
7186 int rc = sqlite3_prepare_v2(db, zSql, -1, ppStmt, 0); in idxPrepareStmt()
7206 char *zSql; in idxPrintfPrepareStmt() local
7208 zSql = sqlite3_vmprintf(zFmt, ap); in idxPrintfPrepareStmt()
7209 if( zSql==0 ){ in idxPrintfPrepareStmt()
7212 rc = idxPrepareStmt(db, ppStmt, pzErrmsg, zSql); in idxPrintfPrepareStmt()
7213 sqlite3_free(zSql); in idxPrintfPrepareStmt()
7997 "EXPLAIN QUERY PLAN %s", pStmt->zSql in idxFindIndexes()
8020 const char *zSql; in idxFindIndexes() local
8025 zSql = idxHashSearch(&p->hIdx, zIdx, nIdx); in idxFindIndexes()
8026 if( zSql ){ in idxFindIndexes()
8027 idxHashAdd(&rc, &hIdx, zSql, 0); in idxFindIndexes()
8098 const char *zSql = in idxProcessOneTrigger() local
8107 rc = idxPrintfPrepareStmt(p->db, &pSelect, pzErr, zSql, zTab, zTab); in idxProcessOneTrigger()
8210 const char *zSql = (const char*)sqlite3_column_text(pSchema, 2); in idxCreateVtabSchema() local
8213 rc = sqlite3_exec(p->dbv, zSql, 0, 0, pzErrmsg); in idxCreateVtabSchema()
8492 char *zSql; in idxBuildSampleTable() local
8497 zSql = sqlite3_mprintf( in idxBuildSampleTable()
8500 if( zSql==0 ) return SQLITE_NOMEM; in idxBuildSampleTable()
8501 rc = sqlite3_exec(p->dbv, zSql, 0, 0, 0); in idxBuildSampleTable()
8502 sqlite3_free(zSql); in idxBuildSampleTable()
8644 const char *zSql = (const char*)sqlite3_column_text(pSql, 0); in sqlite3_expert_new() local
8645 rc = sqlite3_exec(pNew->dbm, zSql, 0, 0, pzErrmsg); in sqlite3_expert_new()
8698 const char *zSql, /* SQL statement to add */ in sqlite3_expert_sql() argument
8704 const char *zStmt = zSql; in sqlite3_expert_sql()
8718 pNew->zSql = (char*)&pNew[1]; in sqlite3_expert_sql()
8719 memcpy(pNew->zSql, z, n+1); in sqlite3_expert_sql()
8799 if( pStmt ) zRet = pStmt->zSql; in sqlite3_expert_report()
9507 char *zSql = 0; in dbdataDbsize() local
9511 zSql = sqlite3_mprintf("PRAGMA %Q.page_count", zSchema); in dbdataDbsize()
9512 if( zSql==0 ) return SQLITE_NOMEM; in dbdataDbsize()
9513 rc = sqlite3_prepare_v2(pTab->db, zSql, -1, &pStmt, 0); in dbdataDbsize()
9514 sqlite3_free(zSql); in dbdataDbsize()
11377 const char *zSql; /* The text of the SQL statement */ in explain_data_prepare() local
11394 zSql = sqlite3_sql(pSql); in explain_data_prepare()
11395 if( zSql==0 ) return; in explain_data_prepare()
11396 for(z=zSql; *z==' ' || *z=='\t' || *z=='\n' || *z=='\f' || *z=='\r'; z++); in explain_data_prepare()
11633 const char *zSql, in expertHandleSQL() argument
11638 return sqlite3_expert_sql(pState->expert.pExpert, zSql, pzErr); in expertHandleSQL()
11675 const char *zSql = sqlite3_expert_report(p, i, EXPERT_REPORT_SQL); in expertFinish() local
11681 raw_printf(out, "%s\n\n", zSql); in expertFinish()
11762 const char *zSql, /* SQL to be evaluated */ in shell_exec() argument
11777 rc = expertHandleSQL(pArg, zSql, pzErrMsg); in shell_exec()
11782 while( zSql[0] && (SQLITE_OK == rc) ){ in shell_exec()
11784 rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, &zLeftover); in shell_exec()
11792 zSql = zLeftover; in shell_exec()
11793 while( IsSpace(zSql[0]) ) zSql++; in shell_exec()
11808 utf8_printf(pArg->out, "%s\n", zStmtSql ? zStmtSql : zSql); in shell_exec()
11853 sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0); in shell_exec()
11898 zSql = zLeftover; in shell_exec()
11899 while( IsSpace(zSql[0]) ) zSql++; in shell_exec()
11942 char *zSql; in tableColumnList() local
11950 zSql = sqlite3_mprintf("PRAGMA table_info=%Q", zTab); in tableColumnList()
11951 rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0); in tableColumnList()
11952 sqlite3_free(zSql); in tableColumnList()
11992 zSql = sqlite3_mprintf("SELECT 1 FROM pragma_index_list(%Q)" in tableColumnList()
11994 rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0); in tableColumnList()
11995 sqlite3_free(zSql); in tableColumnList()
12054 const char *zSql; in dump_callback() local
12061 zSql = azArg[2]; in dump_callback()
12069 }else if( strncmp(zSql, "CREATE VIRTUAL TABLE", 20)==0 ){ in dump_callback()
12078 zTable, zTable, zSql); in dump_callback()
12083 printSchemaLine(p->out, zSql, ";\n"); in dump_callback()
12961 char *zSql = sqlite3_mprintf( in open_db() local
12963 sqlite3_exec(p->db, zSql, 0, 0, 0); in open_db()
12964 sqlite3_free(zSql); in open_db()
13013 char *zSql; in readline_completion_generator() local
13015 zSql = sqlite3_mprintf("SELECT DISTINCT candidate COLLATE nocase" in readline_completion_generator()
13017 sqlite3_prepare_v2(globalDb, zSql, -1, &pStmt, 0); in readline_completion_generator()
13018 sqlite3_free(zSql); in readline_completion_generator()
13042 char *zSql; in linenoise_completion() local
13051 zSql = sqlite3_mprintf("SELECT DISTINCT candidate COLLATE nocase" in linenoise_completion()
13054 sqlite3_prepare_v2(globalDb, zSql, -1, &pStmt, 0); in linenoise_completion()
13055 sqlite3_free(zSql); in linenoise_completion()
13204 const char *zSql; in sql_trace_callback() local
13212 zSql = (const char*)pX; in sql_trace_callback()
13217 zSql = sqlite3_expanded_sql(pStmt); in sql_trace_callback()
13222 zSql = sqlite3_normalized_sql(pStmt); in sql_trace_callback()
13227 zSql = sqlite3_sql(pStmt); in sql_trace_callback()
13232 if( zSql==0 ) return 0; in sql_trace_callback()
13233 nSql = strlen30(zSql); in sql_trace_callback()
13234 while( nSql>0 && zSql[nSql-1]==';' ){ nSql--; } in sql_trace_callback()
13238 utf8_printf(p->traceOut, "%.*s;\n", nSql, zSql); in sql_trace_callback()
13243 utf8_printf(p->traceOut, "%.*s; -- %lld ns\n", nSql, zSql, nNanosec); in sql_trace_callback()
13539 const unsigned char *zSql; in tryToCloneSchema() local
13553 zSql = sqlite3_column_text(pQuery, 1); in tryToCloneSchema()
13555 sqlite3_exec(newDb, (const char*)zSql, 0, 0, &zErrMsg); in tryToCloneSchema()
13557 utf8_printf(stderr, "Error: %s\nSQL: [%s]\n", zErrMsg, zSql); in tryToCloneSchema()
13580 zSql = sqlite3_column_text(pQuery, 1); in tryToCloneSchema()
13582 sqlite3_exec(newDb, (const char*)zSql, 0, 0, &zErrMsg); in tryToCloneSchema()
13584 utf8_printf(stderr, "Error: %s\nSQL: [%s]\n", zErrMsg, zSql); in tryToCloneSchema()
13673 static int db_int(ShellState *p, const char *zSql){ in db_int() argument
13676 sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0); in db_int()
13714 static const struct { const char *zName; const char *zSql; } aQuery[] = { in shell_dbinfo_command() member
13780 char *zSql = sqlite3_mprintf(aQuery[i].zSql, zSchemaTab); in shell_dbinfo_command() local
13781 int val = db_int(p, zSql); in shell_dbinfo_command()
13782 sqlite3_free(zSql); in shell_dbinfo_command()
14077 const char *zSql = in lintFkeyIndexes() local
14130 rc = sqlite3_prepare_v2(db, zSql, -1, &pSql, 0); in lintFkeyIndexes()
14225 const char *zSql, in shellPrepare() argument
14230 int rc = sqlite3_prepare_v2(db, zSql, -1, ppStmt, 0); in shellPrepare()
14644 const char *zSql = "SELECT %s FROM %s WHERE %s"; in arListCommand() local
14657 shellPreparePrintf(pAr->db, &rc, &pSql, zSql, azCols[pAr->bVerbose], in arListCommand()
14756 static int arExecSql(ArCommand *pAr, const char *zSql){ in arExecSql() argument
14759 utf8_printf(pAr->p->out, "%s\n", zSql); in arExecSql()
14763 rc = sqlite3_exec(pAr->db, zSql, 0, 0, &zErr); in arExecSql()
14831 char *zSql; in arCreateOrUpdateCommand() local
14846 zSql = sqlite3_mprintf( in arCreateOrUpdateCommand()
14850 rc = arExecSql(pAr, zSql); in arCreateOrUpdateCommand()
14851 sqlite3_free(zSql); in arCreateOrUpdateCommand()
14888 zSql = sqlite3_mprintf("DROP TABLE %s", zTemp); in arCreateOrUpdateCommand()
14889 arExecSql(pAr, zSql); in arCreateOrUpdateCommand()
14890 sqlite3_free(zSql); in arCreateOrUpdateCommand()
15014 static void shellExec(sqlite3 *db, int *pRc, const char *zSql){ in shellExec() argument
15018 rc = sqlite3_exec(db, zSql, 0, 0, &zErr); in shellExec()
15130 const char *zSql, /* CREATE TABLE statement */ in recoverNewTable() argument
15153 rc = sqlite3_exec(dbtmp, zSql, 0, 0, 0); in recoverNewTable()
15270 const char *zSql = 0; in recoverFindTable() local
15285 zSql = (const char*)sqlite3_column_text(pStmt, 2); in recoverFindTable()
15286 pRet = recoverNewTable(pRc, zName, zSql, bIntkey, nCol); in recoverFindTable()
15657 const char *zSql = (const char*)sqlite3_column_text(pStmt, 0); in recoverDatabaseCmd() local
15658 if( sqlite3_strnicmp(zSql, "create virt", 11)==0 ){ in recoverDatabaseCmd()
15662 zName, zName, zSql in recoverDatabaseCmd()
15667 raw_printf(pState->out, "%s;\n", zSql); in recoverDatabaseCmd()
15986 char *zSql; in do_meta_command() local
16036 zSql = sqlite3_mprintf( in do_meta_command()
16043 run_schema_dump_query(p,zSql); in do_meta_command()
16044 sqlite3_free(zSql); in do_meta_command()
16045 zSql = sqlite3_mprintf( in do_meta_command()
16051 run_table_dump_query(p, zSql); in do_meta_command()
16052 sqlite3_free(zSql); in do_meta_command()
16365 char *zSql; /* An SQL statement */ in do_meta_command() local
16500 zSql = sqlite3_mprintf("SELECT * FROM %s", zTable); in do_meta_command()
16501 if( zSql==0 ){ in do_meta_command()
16505 nByte = strlen30(zSql); in do_meta_command()
16506 rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0); in do_meta_command()
16538 rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0); in do_meta_command()
16540 sqlite3_free(zSql); in do_meta_command()
16552 zSql = sqlite3_malloc64( nByte*2 + 20 + nCol*2 ); in do_meta_command()
16553 if( zSql==0 ){ in do_meta_command()
16557 sqlite3_snprintf(nByte+20, zSql, "INSERT INTO \"%w\" VALUES(?", zTable); in do_meta_command()
16558 j = strlen30(zSql); in do_meta_command()
16560 zSql[j++] = ','; in do_meta_command()
16561 zSql[j++] = '?'; in do_meta_command()
16563 zSql[j++] = ')'; in do_meta_command()
16564 zSql[j] = 0; in do_meta_command()
16566 utf8_printf(p->out, "Insert using: %s\n", zSql); in do_meta_command()
16568 rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0); in do_meta_command()
16569 sqlite3_free(zSql); in do_meta_command()
16638 char *zSql; in do_meta_command() local
16663 zSql = sqlite3_mprintf( in do_meta_command()
16672 sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0); in do_meta_command()
16673 sqlite3_free(zSql); in do_meta_command()
16679 zSql = sqlite3_mprintf("PRAGMA index_xinfo='%q'", azArg[1]); in do_meta_command()
16680 rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0); in do_meta_command()
16681 sqlite3_free(zSql); in do_meta_command()
16712 zSql = sqlite3_mprintf( in do_meta_command()
16718 rc = sqlite3_exec(p->db, zSql, 0, 0, 0); in do_meta_command()
16721 utf8_printf(stderr, "Error in [%s]: %s\n", zSql, sqlite3_errmsg(p->db)); in do_meta_command()
16723 utf8_printf(stdout, "%s;\n", zSql); in do_meta_command()
16733 sqlite3_free(zSql); in do_meta_command()
17160 char *zSql; in do_meta_command() local
17165 zSql = sqlite3_mprintf( in do_meta_command()
17168 if( zSql==0 ) shell_out_of_memory(); in do_meta_command()
17170 rx = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0); in do_meta_command()
17171 sqlite3_free(zSql); in do_meta_command()
17175 zSql = sqlite3_mprintf( in do_meta_command()
17178 if( zSql==0 ) shell_out_of_memory(); in do_meta_command()
17179 rx = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0); in do_meta_command()
17180 sqlite3_free(zSql); in do_meta_command()
17197 char *zSql = sqlite3_mprintf( in do_meta_command() local
17199 if( zSql==0 ) shell_out_of_memory(); in do_meta_command()
17200 sqlite3_exec(p->db, zSql, 0, 0, 0); in do_meta_command()
17201 sqlite3_free(zSql); in do_meta_command()
17772 const char *zSql = (const char*)sqlite3_column_text(pStmt, 2); in do_meta_command() local
17777 char *zQuote = sqlite3_mprintf("%q", zSql); in do_meta_command()
17778 printf("%d: %s %s\n", tno, zOp, zSql); in do_meta_command()
17782 utf8_printf(p->out, "%s\n", zSql); in do_meta_command()
17788 rc = sqlite3_exec(p->db, zSql, captureOutputCallback, &str, &zErrMsg); in do_meta_command()
17841 char *zSql; /* SQL to be run */ in do_meta_command() local
17880 zSql = "SELECT lower(name) FROM sqlite_master" in do_meta_command()
17885 zSql = "SELECT lower(name) FROM sqlite_master" in do_meta_command()
17890 sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0); in do_meta_command()
17925 zSql = sqlite3_mprintf( in do_meta_command()
17931 zSql = sqlite3_mprintf( in do_meta_command()
17940 utf8_printf(p->out, "%s\n", zSql); in do_meta_command()
17942 shell_exec(p, zSql, 0); in do_meta_command()
17944 sqlite3_free(zSql); in do_meta_command()
18630 static int line_is_complete(char *zSql, int nSql){ in line_is_complete() argument
18632 if( zSql==0 ) return 1; in line_is_complete()
18633 zSql[nSql] = ';'; in line_is_complete()
18634 zSql[nSql+1] = 0; in line_is_complete()
18635 rc = sqlite3_complete(zSql); in line_is_complete()
18636 zSql[nSql] = 0; in line_is_complete()
18643 static int runOneSqlLine(ShellState *p, char *zSql, FILE *in, int startline){ in runOneSqlLine() argument
18648 if( ShellHasFlag(p,SHFLG_Backslash) ) resolve_backslashes(zSql); in runOneSqlLine()
18651 rc = shell_exec(p, zSql, &zErrMsg); in runOneSqlLine()
18688 char *zSql = 0; /* Accumulated SQL text */ in process_input() local
18727 if( line_is_command_terminator(zLine) && line_is_complete(zSql, nSql) ){ in process_input()
18733 zSql = realloc(zSql, nAlloc); in process_input()
18734 if( zSql==0 ) shell_out_of_memory(); in process_input()
18740 assert( nAlloc>0 && zSql!=0 ); in process_input()
18741 memcpy(zSql, zLine+i, nLine+1-i); in process_input()
18745 zSql[nSql++] = '\n'; in process_input()
18746 memcpy(zSql+nSql, zLine, nLine+1); in process_input()
18749 if( nSql && line_contains_semicolon(&zSql[nSqlPrior], nSql-nSqlPrior) in process_input()
18750 && sqlite3_complete(zSql) ){ in process_input()
18751 errCnt += runOneSqlLine(p, zSql, p->in, startline); in process_input()
18759 }else if( nSql && _all_whitespace(zSql) ){ in process_input()
18760 if( ShellHasFlag(p, SHFLG_Echo) ) printf("%s\n", zSql); in process_input()
18764 if( nSql && !_all_whitespace(zSql) ){ in process_input()
18765 errCnt += runOneSqlLine(p, zSql, p->in, startline); in process_input()
18767 free(zSql); in process_input()