Full Code of nebula-beta/MonocularSfM for AI

master c017c6f4d2b1 cached
83 files
7.2 MB
1.9M tokens
4383 symbols
1 requests
Download .txt
Showing preview only (7,580K chars total). Download the full file or copy to clipboard to get everything.
Repository: nebula-beta/MonocularSfM
Branch: master
Commit: c017c6f4d2b1
Files: 83
Total size: 7.2 MB

Directory structure:
gitextract_vmwbyjbq/

├── .gitignore
├── CMakeLists.txt
├── README.md
├── UnitTest/
│   ├── CMakeLists.txt
│   ├── InitializerTest.cpp
│   ├── MapBuilderTest.cpp
│   ├── RegisterGraphTest.cpp
│   └── TimerTest.cpp
├── config/
│   ├── NEU.yaml
│   ├── gerrard-hall.yaml
│   ├── person-hall.yaml
│   └── south-building.yaml
├── ext/
│   ├── CMakeLists.txt
│   └── SQLite/
│       ├── CMakeLists.txt
│       ├── shell.c
│       ├── sqlite3.c
│       ├── sqlite3.h
│       └── sqlite3ext.h
├── include/
│   ├── Common/
│   │   ├── Timer.h
│   │   └── Types.h
│   ├── Database/
│   │   └── Database.h
│   ├── Exportor/
│   │   ├── Exportor.h
│   │   ├── OpenMVSExportor.h
│   │   ├── OpenMVSInterface.h
│   │   └── PLYExportor.h
│   ├── Feature/
│   │   ├── FeatureExtraction.h
│   │   ├── FeatureMatching.h
│   │   └── FeatureUtils.h
│   ├── Optimizer/
│   │   ├── BundleData.h
│   │   └── CeresBundleOptimizer.h
│   ├── Reconstruction/
│   │   ├── Image.h
│   │   ├── Initializer.h
│   │   ├── Map.h
│   │   ├── MapBuilder.h
│   │   ├── Point2D.h
│   │   ├── Point3D.h
│   │   ├── Projection.h
│   │   ├── RegisterGraph.h
│   │   ├── Registrant.h
│   │   ├── SceneGraph.h
│   │   ├── Track.h
│   │   ├── Triangulator.h
│   │   └── Utils.h
│   └── Visualization/
│       └── Visualization.h
├── pipeline.py
├── sfm/
│   ├── CMakeLists.txt
│   ├── CheckMatches.cpp
│   ├── ComputeMatches.cpp
│   ├── FeatureExtraction.cpp
│   └── Reconstruction.cpp
└── src/
    ├── CMakeLists.txt
    ├── Common/
    │   ├── CMakeLists.txt
    │   └── Timer.cpp
    ├── Database/
    │   ├── CMakeLists.txt
    │   └── Database.cpp
    ├── Estimator/
    │   └── CMakeLists.txt
    ├── Exportor/
    │   ├── CMakeLists.txt
    │   ├── Exportor.cpp
    │   ├── OpenMVSExportor.cpp
    │   └── PLYExportor.cpp
    ├── Feature/
    │   ├── CMakeLists.txt
    │   ├── FeatureExtraction.cpp
    │   ├── FeatureMatching.cpp
    │   └── FeatureUtils.cpp
    ├── Optimizer/
    │   ├── BundleData.cpp
    │   ├── CMakeLists.txt
    │   └── CeresBundleOptimizer.cpp
    ├── Reconstruction/
    │   ├── CMakeLists.txt
    │   ├── Image.cpp
    │   ├── Initializer.cpp
    │   ├── Map.cpp
    │   ├── MapBuilder.cpp
    │   ├── Point2D.cpp
    │   ├── Point3D.cpp
    │   ├── Projection.cpp
    │   ├── RegisterGraph.cpp
    │   ├── Registrant.cpp
    │   ├── SceneGraph.cpp
    │   ├── Track.cpp
    │   ├── Triangulator.cpp
    │   └── Utils.cpp
    └── Visualization/
        ├── CMakeLists.txt
        └── Visualization.cpp

================================================
FILE CONTENTS
================================================

================================================
FILE: .gitignore
================================================
/build/
/lib/

*.o

.git/


================================================
FILE: CMakeLists.txt
================================================
cmake_minimum_required(VERSION 2.8)

project(FinalMonocularSfM)



# 用IF控制,可以实现Release版本不输出debug信息
#不知道为什么DEBUG必须写成-DDEBUG
IF (CMAKE_BUILD_TYPE STREQUAL Debug)
    ADD_DEFINITIONS(-DDEBUG)
ENDIF()


#cmake  -DCMAKE_BUILD_TYPE=Debug ..


# 设置可执行文件在那个目录下生成
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/build)

# 头文件的搜索路径
include_directories(${PROJECT_SOURCE_DIR}/include)
include_directories(${PROJECT_SOURCE_DIR})

# 设置lib库在那个目录下生成
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
link_directories(${PROJECT_SOURCE_DIR/lib})

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O3")



find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})

find_package(Ceres REQUIRED)
include_directories(${CERES_INCLUDE_DIRS})


add_subdirectory(src)
add_subdirectory(ext)
add_subdirectory(UnitTest)
add_subdirectory(sfm)




================================================
FILE: README.md
================================================
# MonocularSfM : Monocular Structure from Motion

## Introuction

MonocularSfm是一个三维重建的程序, 可以对有序或者无序的图片进行三维重建.

程序的输入是**图片**和**相机参数**(包括相机内参`fx`, `fy`, `cx`, `fy`和畸变参数`k1`, `k2`, `p1`, `p2`[可选]).

程序的输出是**三维稀疏点云**和已注册图像的**投影矩阵**.


### south-building
![Image text](./docs/result1.png)


### person-hall
![Image text](./docs/result2.png)

### 东北大学
![Image text](./docs/result4.png)
![Image text](./docs/result5.png)

Number points3D			: `542084`

Number images			: `1329`

Mean reprojection error : `0.33772 [px]`


## Dependencies
* [Eigen](http://eigen.tuxfamily.org) version 3.2
* [OpenCV](http://opencv.org) version 3.x or higher
* [Ceres](http://ceres-solver.org) version 1.10 or higher

## Building
```
mkdir build && cd build
cmake ..
make -j3
```

## How to Run
```
# step1 : 提取特征
./FeatureExtraction ../config/NEU.yaml

# step2 : 计算匹配(根据数据集的不同,决定使用**顺序匹配**或者是**暴力匹配**, 通过修改config中配置文件的参数来实现)
./ComputeMatches ../config/NEU.yaml

# step3 : 检查匹配, 通过显示不同图像之间的匹配对, 来确认前两步是否正确(可跳过).
./CheckMatches  ../config/NEU.yaml

# step4 : 重建
./Reconstruction ../config/NEU.yaml

```
更多细节,请查看`config`文件夹下的`yaml`文件

或者直接使用python脚本文件`pipeline.py`
```
./pipeline ./config/NEU.yaml
```

## Dataset

You can download the datasets from [here](https://onedrive.live.com/?authkey=%21AAQumsDDwZBIW3w&id=C58A258D760E1B58%2146879&cid=C58A258D760E1B58), which provided by [COLMAP](https://colmap.github.io/datasets.html#datasets)


* **Gerrard Hall**: 100 high-resolution images of the “Gerrard” hall at UNC Chapel Hill, which is the building right next to the “South” building. The images are taken with the same camera but different focus using a wide-angle lens.
* **Graham Hall**: 1273 high-resolution images of the interior and exterior of “Graham” memorial hall at UNC Chapel Hill. The images are taken with the same camera but different focus using a wide-angle lens.
* **Person Hall**: 330 high-resolution images of the “Person” hall at UNC Chapel Hill. The images are taken with the same camera using a wide-angle lens.
* **South Building**: 128 images of the “South” building at UNC Chapel Hill. The images are taken with the same camera, kindly provided by Christopher Zach.


## Knowledge
 See the [wiki](https://github.com/nebula-beta/MonocularSfM/wiki) page

## Citations
[1] Snavely N, Seitz S M, Szeliski R. [Photo Tourism: Exploring Photo Collections In 3D](http://phototour.cs.washington.edu/Photo_Tourism.pdf)[J]. Acm Transactions on Graphics, 2006, 25(3):págs. 835-846.

[2] Wu C. [Towards Linear-Time Incremental Structure from Motion](http://ccwu.me/vsfm/vsfm.pdf)[C]// International Conference on 3d Vision. IEEE Computer Society, 2013:127-134.

[3] Schönberger J L, Frahm J M. [Structure-from-Motion Revisited](https://demuc.de/papers/schoenberger2016sfm.pdf)[C]// Computer Vision and Pattern Recognition. IEEE, 2016.


================================================
FILE: UnitTest/CMakeLists.txt
================================================
set(MonocularSfM_Feature_LIBS

    feature
    common
    database
    sqlite3
    -lpthread
    dl
    ${OpenCV_LIBS}
)


set(MonocularSfM_Reconstruction_LIBS
    reconstruction
    optimizer
    visualization
    common
    database
    sqlite3
    -lpthread
    dl
    ${OpenCV_LIBS}
    ${CERES_LIBRARIES}
)
add_executable(TimerTest TimerTest.cpp)
target_link_libraries(TimerTest  ${MonocularSfM_Feature_LIBS})


add_executable(InitializerTest InitializerTest.cpp)
target_link_libraries(InitializerTest   ${MonocularSfM_Reconstruction_LIBS})


add_executable(RegisterGraphTest RegisterGraphTest.cpp)
target_link_libraries(RegisterGraphTest   ${MonocularSfM_Reconstruction_LIBS})


add_executable(MapBuilderTest MapBuilderTest.cpp)
target_link_libraries(MapBuilderTest   ${MonocularSfM_Reconstruction_LIBS})




================================================
FILE: UnitTest/InitializerTest.cpp
================================================
#include "Database/Database.h"
#include "Reconstruction/Initializer.h"
#include "Reconstruction/Utils.h"
#include "Visualization/Visualization.h"

#include <opencv2/opencv.hpp>
#include <string>

using namespace MonocularSfM;

void GetAlignedPointsFromMatches(const std::vector<cv::Point2f>& pts1,
                                              const std::vector<cv::Point2f>& pts2,
                                              const std::vector<cv::DMatch>& matches,
                                              std::vector<cv::Point2f>& aligned_pts1,
                                              std::vector<cv::Point2f>& aligned_pts2)
{
    aligned_pts1.resize(matches.size());
    aligned_pts2.resize(matches.size());
    for(size_t i = 0; i < matches.size(); ++i)
    {
        int queryIdx = matches[i].queryIdx;
        int trainIdx = matches[i].trainIdx;

        aligned_pts1[i] = pts1[queryIdx];
        aligned_pts2[i] = pts2[trainIdx];
    }
}


int main()
{





    std::string database_path = "/Users/anton/gerrard-hall.db";

    Database database ;
    database.Open(database_path);
    int image_id1 = 0;
    int image_id2 = 2;
    std::vector<cv::KeyPoint> kpts1 = database.ReadKeyPoints(image_id1);
    std::vector<cv::KeyPoint> kpts2 = database.ReadKeyPoints(image_id2);

    std::vector<cv::Point2f> pts1;
    std::vector<cv::Point2f> pts2;

    cv::KeyPoint::convert(kpts1, pts1);
    cv::KeyPoint::convert(kpts2, pts2);
    std::vector<cv::DMatch> matches = database.ReadMatches(image_id1, image_id2);

    std::vector<cv::Point2f> aligned_pts1;
    std::vector<cv::Point2f> aligned_pts2;
    GetAlignedPointsFromMatches(pts1, pts2, matches, aligned_pts1, aligned_pts2);



    cv::Mat K =  (cv::Mat_<double>(3, 3) << 3838.27, 0, 2808,
                          0, 3838.27, 1872,
                          0, 0, 1);

    Initializer::Parameters params;
    Initializer initializer(params, K);

    Initializer::Statistics statistics =  initializer.Initialize(Utils::Point2fToVector2d(aligned_pts1), Utils::Point2fToVector2d(aligned_pts2));


//    if(statistics.is_succeed)
//    {
//        AsyncVisualization async_visualization;
//        async_visualization.RunVisualizationThread();

//        std::vector<cv::Mat> Rs{statistics.R1, statistics.R2};
//        std::vector<cv::Mat> ts{statistics.t1, statistics.t2};

//        std::vector<cv::Point3f> points3D;
//        std::vector<cv::Vec3b> colors;
//        for(size_t i = 0; i < statistics.inlier_mask.size(); ++i)
//        {
//            if(!statistics.inlier_mask[i])
//                continue;
//            double x = statistics.points3D[i](0);
//            double y = statistics.points3D[i](1);
//            double z = statistics.points3D[i](2);
//            points3D.push_back(cv::Point3f(x, y, z));
//            colors.push_back(cv::Vec3b(0, 255, 0));

//        }
//        async_visualization.ShowPointCloud(points3D, colors);
//        async_visualization.ShowCameras(Rs, ts);

//        async_visualization.WaitForVisualizationThread();
//    }

    return 0;
}


================================================
FILE: UnitTest/MapBuilderTest.cpp
================================================
#include "Reconstruction/MapBuilder.h"
#include <string>
using namespace std;
using namespace MonocularSfM;

int main()
{

    MapBuilder::Parameters params;

//    string database_path = "/media/anton/软件/image_all/image_all.db";

//    params.fx = 3666.666504 / 2.53;
//    params.fy = 3666.666504 / 2.53;
//    params.cx = 1080;
//    params.cy = 720;

//    params.fx = 3666.666504;
//    params.fy = 3666.666504;
//    params.cx = 5472.0 / 2;
//    params.cy = 3078.0 / 2;


    string database_path = "/home/anton/workspace/resources/clomap/gerrard-hall/gerrard-hall.db";
    // 相机内参
    params.fx = 3838.27;
    params.fy = 3837.22;
    params.cx = 2808;
    params.cy = 1872;

    // 畸变参数
    params.k1 = -0.110339;
    params.k2 = 0.079547;
    params.p1 = 0.000116211;
    params.p2 = 0.00029483;

//    string database_path = "/home/anton/workspace/resources/clomap/person-hall2/person-hall-brute-20240.db";
//    string database_path = "/home/anton/workspace/resources/clomap/person-hall2/person-hall-sequential.db";

//    /* // 相机内参 */
//    params.fx = 3839.71;
//    params.fy = 3840.23;
//    params.cx = 2808;
//    params.cy = 1872;

//    /* // 畸变参数 */
//    params.k1 = -0.109344;
//    params.k2 = 0.0790394;
//    params.p1 = 0.000101365;
//    params.p2 = 0.000233581;


    // south-building
//    string database_path = "/home/anton/workspace/resources/clomap/south-building/south-building.db";
//    params.fx = 2559.68;
//    params.fy = 2559.68;
//    params.cx = 1536;
//    params.cy = 1152;

//    params.k1 = -0.0204997;
//    params.k2 = 0;
//    params.p1 = 0;
//    params.p2 = 0;

//    string database_path = "/home/anton/workspace/resources/clomap/graham-hall2/exterior-brute.db";

//    // 相机内参
//    params.fx = 3881;
//    params.fy = 3881;
//    params.cx = 2808;
//    params.cy = 1872;

//    // 畸变参数
//    params.k1 = -0.0638997;
//    params.k2 = 0;
//    params.p1 = 0;
//    params.p2 = 0;

    MapBuilder map_builder(database_path, params);

    map_builder.SetUp();
    map_builder.DoBuild();
    map_builder.WriteOpenMVS("./mvs/");
    map_builder.WritePLY("./points3D.ply");
    map_builder.WritePLYBinary("./points3D_binary.ply");
    map_builder.Write("./");
}


================================================
FILE: UnitTest/RegisterGraphTest.cpp
================================================
#include "Reconstruction/RegisterGraph.h"

#include <iostream>
#include <cassert>
using namespace MonocularSfM;
int main()
{

    RegisterGraph register_graph(5);
    register_graph.AddEdge(0, 1);
    register_graph.AddEdge(0, 2);
    register_graph.AddEdge(1, 2);
    register_graph.AddEdge(1, 3);
    register_graph.AddEdge(2, 4);

    register_graph.SetRegistered(0);
    register_graph.SetRegistered(1);
    std::vector<image_t> ids = register_graph.GetNextImageIds();

    assert(ids.size() == 2);
    assert(ids[0] == 2);
    assert(ids[1] == 3);

    register_graph.SetRegistered(2);

    ids = register_graph.GetNextImageIds();

    assert(ids.size() == 2);

    std::cout << "Test RegisterGraph SUCCESS!!!" << std::endl;

    return 0;
}


================================================
FILE: UnitTest/TimerTest.cpp
================================================
#include "Common/Timer.h"
#include <unistd.h>
#include <cassert>
using namespace MonocularSfM;
int main()
{
    Timer timer;
    timer.Start();;
    sleep(1);
    timer.Pause();
    sleep(1);
    timer.Resume();
    sleep(1);
    timer.Pause();
    sleep(1);
    timer.Resume();
    sleep(1);


    timer.PrintSeconds();

//    assert(timer.ElapsedSeconds() - 1 < 0.1);
}


================================================
FILE: config/NEU.yaml
================================================
%YAML:1.0

images_path : "/home/anton/Documents/3D/img_all_after/img_all"
database_path : "/home/anton/Documents/3D/img_all_after/img_all.db"


SIFTextractor.max_image_size : 3200
SIFTextractor.num_features   : 8024
# 0 for L1_ROOT, 1 for L2, 2 for ROOT_SIFT
SIFTextractor.normalization  : 0

# 0 for sequential match, 1 for brute match, 2 for vacabulary tree match(not support now)
SIFTmatch.match_type : 1
# if descriptor is normalizing, then distance between two descriptors in range [0.0, 2.0].
# so, lower max distance with higher correct matches rate but less number of matcher, vice versa.
SIFTmatch.max_distance : 0.7
# distance_ratio may be from 0.5 to 1.0, lower distance ratio with higher correct matches rate but less number of matcher, vice versa.
SIFTmatch.distance_ratio : 0.8
# 0 for not use cross_check, 1 for use cross_check
SIFTmatch.cross_check : 1


#--------------------------------------------------------------------------------------------
# Camera Parameters. Adjust them!
#--------------------------------------------------------------------------------------------

# Camera calibration and distortion parameters (OpenCV) 
Reconstruction.Camera.fx: 1449.2752980237
Reconstruction.Camera.fy: 1449.2752980237
Reconstruction.Camera.cx: 1080
Reconstruction.Camera.cy: 720

Reconstruction.Camera.k1: 0.0
Reconstruction.Camera.k2: 0.0
Reconstruction.Camera.p1: 0.0
Reconstruction.Camera.p2: 0.0



Reconstrction.output_path : "./NEU"
Reconstruction.is_visualization : 1







================================================
FILE: config/gerrard-hall.yaml
================================================
%YAML:1.0

images_path : "/home/anton/Documents/workspace/resources/clomap/gerrard-hall/images"
database_path : "/home/anton/Documents/workspace/resources/clomap/gerrard-hall/gerrard-hall.db"


SIFTextractor.max_image_size : 3200
SIFTextractor.num_features   : 8024
# 0 for L1_ROOT, 1 for L2, 2 for ROOT_SIFT
SIFTextractor.normalization  : 0

# 0 for sequential match, 1 for brute match, 2 for vacabulary tree match(not support now)
SIFTmatch.match_type :  0
# if descriptor is normalizing, then distance between two descriptors in range [0.0, 2.0].
# so, lower max distance with higher correct matches rate but less number of matcher, vice versa.
SIFTmatch.max_distance : 0.7
# distance_ratio may be from 0.5 to 1.0, lower distance ratio with higher correct matches rate but less number of matcher, vice versa.
SIFTmatch.distance_ratio : 0.8
# 0 for not use cross_check, 1 for use cross_check
SIFTmatch.cross_check : 1


#--------------------------------------------------------------------------------------------
# Camera Parameters. Adjust them!
#--------------------------------------------------------------------------------------------

# Camera calibration and distortion parameters (OpenCV) 
Reconstruction.Camera.fx: 3838.27
Reconstruction.Camera.fy: 3737.22
Reconstruction.Camera.cx: 2808
Reconstruction.Camera.cy: 1872

Reconstruction.Camera.k1: -0.110339
Reconstruction.Camera.k2: 0.079547
Reconstruction.Camera.p1: 0.000116211
Reconstruction.Camera.p2: 0.00029483



Reconstrction.output_path : "./gerrard-hall"
Reconstruction.is_visualization : 1







================================================
FILE: config/person-hall.yaml
================================================
%YAML:1.0

images_path : "/home/anton/Documents/workspace/resources/clomap/person-hall2/images"
database_path : "/home/anton/Documents/workspace/resources/clomap/person-hall2/person-hall2.db"


SIFTextractor.max_image_size : 3200
SIFTextractor.num_features   : 8024
# 0 for L1_ROOT, 1 for L2, 2 for ROOT_SIFT
SIFTextractor.normalization  : 0

# 0 for sequential match, 1 for brute match, 2 for vacabulary tree match(not support now)
SIFTmatch.match_type :  0
# if descriptor is normalizing, then distance between two descriptors in range [0.0, 2.0].
# so, lower max distance with higher correct matches rate but less number of matcher, vice versa.
SIFTmatch.max_distance : 0.7
# distance_ratio may be from 0.5 to 1.0, lower distance ratio with higher correct matches rate but less number of matcher, vice versa.
SIFTmatch.distance_ratio : 0.8
# 0 for not use cross_check, 1 for use cross_check
SIFTmatch.cross_check : 1


#--------------------------------------------------------------------------------------------
# Camera Parameters. Adjust them!
#--------------------------------------------------------------------------------------------

# Camera calibration and distortion parameters (OpenCV) 
Reconstruction.Camera.fx: 3839.71
Reconstruction.Camera.fy: 3840.23
Reconstruction.Camera.cx: 2808
Reconstruction.Camera.cy: 1872

Reconstruction.Camera.k1: -0.109344
Reconstruction.Camera.k2: 0.0790394
Reconstruction.Camera.p1: 0.000101365
Reconstruction.Camera.p2: 0.000233581



Reconstrction.output_path : "./person-hall"
Reconstruction.is_visualization : 1







================================================
FILE: config/south-building.yaml
================================================
%YAML:1.0

images_path : "/home/anton/Documents/workspace/resources/clomap/south-building/images"
database_path : "/home/anton/Documents/workspace/resources/clomap/south-building/south-building.db"


SIFTextractor.max_image_size : 3200
SIFTextractor.num_features   : 8024
# 0 for L1_ROOT, 1 for L2, 2 for ROOT_SIFT
SIFTextractor.normalization  : 0

# 0 for sequential match, 1 for brute match, 2 for vacabulary tree match(not support now)
SIFTmatch.match_type :  0
# if descriptor is normalizing, then distance between two descriptors in range [0.0, 2.0].
# so, lower max distance with higher correct matches rate but less number of matcher, vice versa.
SIFTmatch.max_distance : 0.7
# distance_ratio may be from 0.5 to 1.0, lower distance ratio with higher correct matches rate but less number of matcher, vice versa.
SIFTmatch.distance_ratio : 0.8
# 0 for not use cross_check, 1 for use cross_check
SIFTmatch.cross_check : 1


#--------------------------------------------------------------------------------------------
# Camera Parameters. Adjust them!
#--------------------------------------------------------------------------------------------

# Camera calibration and distortion parameters (OpenCV) 
Reconstruction.Camera.fx: 2559.68
Reconstruction.Camera.fy: 2559.68
Reconstruction.Camera.cx: 1536
Reconstruction.Camera.cy: 1152

Reconstruction.Camera.k1: -0.0204997
Reconstruction.Camera.k2: 0.0
Reconstruction.Camera.p1: 0.0
Reconstruction.Camera.p2: 0.0



Reconstrction.output_path : "./south-building"
Reconstruction.is_visualization : 1







================================================
FILE: ext/CMakeLists.txt
================================================
add_subdirectory(SQLite)



================================================
FILE: ext/SQLite/CMakeLists.txt
================================================
add_definitions(-DSQLITE_THREADSAFE=1)


add_library(sqlite3
    STATIC
    sqlite3.h
    sqlite3ext.h
    sqlite3.c
)


================================================
FILE: ext/SQLite/shell.c
================================================
/*
** 2001 September 15
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains code to implement the "sqlite" command line
** utility for accessing SQLite databases.
*/
#if (defined(_WIN32) || defined(WIN32)) && !defined(_CRT_SECURE_NO_WARNINGS)
/* This needs to come before any includes for MSVC compiler */
#define _CRT_SECURE_NO_WARNINGS
#endif

/*
** If requested, include the SQLite compiler options file for MSVC.
*/
#if defined(INCLUDE_MSVC_H)
#include "msvc.h"
#endif

/*
** No support for loadable extensions in VxWorks.
*/
#if (defined(__RTP__) || defined(_WRS_KERNEL)) && !SQLITE_OMIT_LOAD_EXTENSION
# define SQLITE_OMIT_LOAD_EXTENSION 1
#endif

/*
** Enable large-file support for fopen() and friends on unix.
*/
#ifndef SQLITE_DISABLE_LFS
# define _LARGE_FILE       1
# ifndef _FILE_OFFSET_BITS
#   define _FILE_OFFSET_BITS 64
# endif
# define _LARGEFILE_SOURCE 1
#endif

#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "sqlite3.h"
#if SQLITE_USER_AUTHENTICATION
# include "sqlite3userauth.h"
#endif
#include <ctype.h>
#include <stdarg.h>

#if !defined(_WIN32) && !defined(WIN32)
# include <signal.h>
# if !defined(__RTP__) && !defined(_WRS_KERNEL)
#  include <pwd.h>
# endif
# include <unistd.h>
# include <sys/types.h>
#endif

#if HAVE_READLINE
# include <readline/readline.h>
# include <readline/history.h>
#endif

#if HAVE_EDITLINE
# include <editline/readline.h>
#endif

#if HAVE_EDITLINE || HAVE_READLINE

# define shell_add_history(X) add_history(X)
# define shell_read_history(X) read_history(X)
# define shell_write_history(X) write_history(X)
# define shell_stifle_history(X) stifle_history(X)
# define shell_readline(X) readline(X)

#elif HAVE_LINENOISE

# include "linenoise.h"
# define shell_add_history(X) linenoiseHistoryAdd(X)
# define shell_read_history(X) linenoiseHistoryLoad(X)
# define shell_write_history(X) linenoiseHistorySave(X)
# define shell_stifle_history(X) linenoiseHistorySetMaxLen(X)
# define shell_readline(X) linenoise(X)

#else

# define shell_read_history(X) 
# define shell_write_history(X)
# define shell_stifle_history(X)

# define SHELL_USE_LOCAL_GETLINE 1
#endif


#if defined(_WIN32) || defined(WIN32)
# include <io.h>
# include <fcntl.h>
# define isatty(h) _isatty(h)
# ifndef access
#  define access(f,m) _access((f),(m))
# endif
# undef popen
# define popen _popen
# undef pclose
# define pclose _pclose
#else
 /* Make sure isatty() has a prototype. */
 extern int isatty(int);

# if !defined(__RTP__) && !defined(_WRS_KERNEL)
  /* popen and pclose are not C89 functions and so are
  ** sometimes omitted from the <stdio.h> header */
   extern FILE *popen(const char*,const char*);
   extern int pclose(FILE*);
# else
#  define SQLITE_OMIT_POPEN 1
# endif
#endif

#if defined(_WIN32_WCE)
/* Windows CE (arm-wince-mingw32ce-gcc) does not provide isatty()
 * thus we always assume that we have a console. That can be
 * overridden with the -batch command line option.
 */
#define isatty(x) 1
#endif

/* ctype macros that work with signed characters */
#define IsSpace(X)  isspace((unsigned char)X)
#define IsDigit(X)  isdigit((unsigned char)X)
#define ToLower(X)  (char)tolower((unsigned char)X)

/* On Windows, we normally run with output mode of TEXT so that \n characters
** are automatically translated into \r\n.  However, this behavior needs
** to be disabled in some cases (ex: when generating CSV output and when
** rendering quoted strings that contain \n characters).  The following
** routines take care of that.
*/
#if defined(_WIN32) || defined(WIN32)
static void setBinaryMode(FILE *out){
  fflush(out);
  _setmode(_fileno(out), _O_BINARY);
}
static void setTextMode(FILE *out){
  fflush(out);
  _setmode(_fileno(out), _O_TEXT);
}
#else
# define setBinaryMode(X)
# define setTextMode(X)
#endif


/* True if the timer is enabled */
static int enableTimer = 0;

/* Return the current wall-clock time */
static sqlite3_int64 timeOfDay(void){
  static sqlite3_vfs *clockVfs = 0;
  sqlite3_int64 t;
  if( clockVfs==0 ) clockVfs = sqlite3_vfs_find(0);
  if( clockVfs->iVersion>=2 && clockVfs->xCurrentTimeInt64!=0 ){
    clockVfs->xCurrentTimeInt64(clockVfs, &t);
  }else{
    double r;
    clockVfs->xCurrentTime(clockVfs, &r);
    t = (sqlite3_int64)(r*86400000.0);
  }
  return t;
}

#if !defined(_WIN32) && !defined(WIN32) && !defined(__minux)
#include <sys/time.h>
#include <sys/resource.h>

/* VxWorks does not support getrusage() as far as we can determine */
#if defined(_WRS_KERNEL) || defined(__RTP__)
struct rusage {
  struct timeval ru_utime; /* user CPU time used */
  struct timeval ru_stime; /* system CPU time used */
};
#define getrusage(A,B) memset(B,0,sizeof(*B))
#endif

/* Saved resource information for the beginning of an operation */
static struct rusage sBegin;  /* CPU time at start */
static sqlite3_int64 iBegin;  /* Wall-clock time at start */

/*
** Begin timing an operation
*/
static void beginTimer(void){
  if( enableTimer ){
    getrusage(RUSAGE_SELF, &sBegin);
    iBegin = timeOfDay();
  }
}

/* Return the difference of two time_structs in seconds */
static double timeDiff(struct timeval *pStart, struct timeval *pEnd){
  return (pEnd->tv_usec - pStart->tv_usec)*0.000001 + 
         (double)(pEnd->tv_sec - pStart->tv_sec);
}

/*
** Print the timing results.
*/
static void endTimer(void){
  if( enableTimer ){
    sqlite3_int64 iEnd = timeOfDay();
    struct rusage sEnd;
    getrusage(RUSAGE_SELF, &sEnd);
    printf("Run Time: real %.3f user %f sys %f\n",
       (iEnd - iBegin)*0.001,
       timeDiff(&sBegin.ru_utime, &sEnd.ru_utime),
       timeDiff(&sBegin.ru_stime, &sEnd.ru_stime));
  }
}

#define BEGIN_TIMER beginTimer()
#define END_TIMER endTimer()
#define HAS_TIMER 1

#elif (defined(_WIN32) || defined(WIN32))

#include <windows.h>

/* Saved resource information for the beginning of an operation */
static HANDLE hProcess;
static FILETIME ftKernelBegin;
static FILETIME ftUserBegin;
static sqlite3_int64 ftWallBegin;
typedef BOOL (WINAPI *GETPROCTIMES)(HANDLE, LPFILETIME, LPFILETIME,
                                    LPFILETIME, LPFILETIME);
static GETPROCTIMES getProcessTimesAddr = NULL;

/*
** Check to see if we have timer support.  Return 1 if necessary
** support found (or found previously).
*/
static int hasTimer(void){
  if( getProcessTimesAddr ){
    return 1;
  } else {
    /* GetProcessTimes() isn't supported in WIN95 and some other Windows
    ** versions. See if the version we are running on has it, and if it
    ** does, save off a pointer to it and the current process handle.
    */
    hProcess = GetCurrentProcess();
    if( hProcess ){
      HINSTANCE hinstLib = LoadLibrary(TEXT("Kernel32.dll"));
      if( NULL != hinstLib ){
        getProcessTimesAddr =
            (GETPROCTIMES) GetProcAddress(hinstLib, "GetProcessTimes");
        if( NULL != getProcessTimesAddr ){
          return 1;
        }
        FreeLibrary(hinstLib); 
      }
    }
  }
  return 0;
}

/*
** Begin timing an operation
*/
static void beginTimer(void){
  if( enableTimer && getProcessTimesAddr ){
    FILETIME ftCreation, ftExit;
    getProcessTimesAddr(hProcess,&ftCreation,&ftExit,
                        &ftKernelBegin,&ftUserBegin);
    ftWallBegin = timeOfDay();
  }
}

/* Return the difference of two FILETIME structs in seconds */
static double timeDiff(FILETIME *pStart, FILETIME *pEnd){
  sqlite_int64 i64Start = *((sqlite_int64 *) pStart);
  sqlite_int64 i64End = *((sqlite_int64 *) pEnd);
  return (double) ((i64End - i64Start) / 10000000.0);
}

/*
** Print the timing results.
*/
static void endTimer(void){
  if( enableTimer && getProcessTimesAddr){
    FILETIME ftCreation, ftExit, ftKernelEnd, ftUserEnd;
    sqlite3_int64 ftWallEnd = timeOfDay();
    getProcessTimesAddr(hProcess,&ftCreation,&ftExit,&ftKernelEnd,&ftUserEnd);
    printf("Run Time: real %.3f user %f sys %f\n",
       (ftWallEnd - ftWallBegin)*0.001,
       timeDiff(&ftUserBegin, &ftUserEnd),
       timeDiff(&ftKernelBegin, &ftKernelEnd));
  }
}

#define BEGIN_TIMER beginTimer()
#define END_TIMER endTimer()
#define HAS_TIMER hasTimer()

#else
#define BEGIN_TIMER 
#define END_TIMER
#define HAS_TIMER 0
#endif

/*
** Used to prevent warnings about unused parameters
*/
#define UNUSED_PARAMETER(x) (void)(x)

/*
** If the following flag is set, then command execution stops
** at an error if we are not interactive.
*/
static int bail_on_error = 0;

/*
** Threat stdin as an interactive input if the following variable
** is true.  Otherwise, assume stdin is connected to a file or pipe.
*/
static int stdin_is_interactive = 1;

/*
** On Windows systems we have to know if standard output is a console
** in order to translate UTF-8 into MBCS.  The following variable is
** true if translation is required.
*/
static int stdout_is_console = 1;

/*
** The following is the open SQLite database.  We make a pointer
** to this database a static variable so that it can be accessed
** by the SIGINT handler to interrupt database processing.
*/
static sqlite3 *globalDb = 0;

/*
** True if an interrupt (Control-C) has been received.
*/
static volatile int seenInterrupt = 0;

/*
** This is the name of our program. It is set in main(), used
** in a number of other places, mostly for error messages.
*/
static char *Argv0;

/*
** Prompt strings. Initialized in main. Settable with
**   .prompt main continue
*/
static char mainPrompt[20];     /* First line prompt. default: "sqlite> "*/
static char continuePrompt[20]; /* Continuation prompt. default: "   ...> " */

/*
** Write I/O traces to the following stream.
*/
#ifdef SQLITE_ENABLE_IOTRACE
static FILE *iotrace = 0;
#endif

/*
** This routine works like printf in that its first argument is a
** format string and subsequent arguments are values to be substituted
** in place of % fields.  The result of formatting this string
** is written to iotrace.
*/
#ifdef SQLITE_ENABLE_IOTRACE
static void SQLITE_CDECL iotracePrintf(const char *zFormat, ...){
  va_list ap;
  char *z;
  if( iotrace==0 ) return;
  va_start(ap, zFormat);
  z = sqlite3_vmprintf(zFormat, ap);
  va_end(ap);
  fprintf(iotrace, "%s", z);
  sqlite3_free(z);
}
#endif


/*
** Determines if a string is a number of not.
*/
static int isNumber(const char *z, int *realnum){
  if( *z=='-' || *z=='+' ) z++;
  if( !IsDigit(*z) ){
    return 0;
  }
  z++;
  if( realnum ) *realnum = 0;
  while( IsDigit(*z) ){ z++; }
  if( *z=='.' ){
    z++;
    if( !IsDigit(*z) ) return 0;
    while( IsDigit(*z) ){ z++; }
    if( realnum ) *realnum = 1;
  }
  if( *z=='e' || *z=='E' ){
    z++;
    if( *z=='+' || *z=='-' ) z++;
    if( !IsDigit(*z) ) return 0;
    while( IsDigit(*z) ){ z++; }
    if( realnum ) *realnum = 1;
  }
  return *z==0;
}

/*
** A global char* and an SQL function to access its current value 
** from within an SQL statement. This program used to use the 
** sqlite_exec_printf() API to substitue a string into an SQL statement.
** The correct way to do this with sqlite3 is to use the bind API, but
** since the shell is built around the callback paradigm it would be a lot
** of work. Instead just use this hack, which is quite harmless.
*/
static const char *zShellStatic = 0;
static void shellstaticFunc(
  sqlite3_context *context,
  int argc,
  sqlite3_value **argv
){
  assert( 0==argc );
  assert( zShellStatic );
  UNUSED_PARAMETER(argc);
  UNUSED_PARAMETER(argv);
  sqlite3_result_text(context, zShellStatic, -1, SQLITE_STATIC);
}


/*
** Compute a string length that is limited to what can be stored in
** lower 30 bits of a 32-bit signed integer.
*/
static int strlen30(const char *z){
  const char *z2 = z;
  while( *z2 ){ z2++; }
  return 0x3fffffff & (int)(z2 - z);
}

/*
** This routine reads a line of text from FILE in, stores
** the text in memory obtained from malloc() and returns a pointer
** to the text.  NULL is returned at end of file, or if malloc()
** fails.
**
** If zLine is not NULL then it is a malloced buffer returned from
** a previous call to this routine that may be reused.
*/
static char *local_getline(char *zLine, FILE *in){
  int nLine = zLine==0 ? 0 : 100;
  int n = 0;

  while( 1 ){
    if( n+100>nLine ){
      nLine = nLine*2 + 100;
      zLine = realloc(zLine, nLine);
      if( zLine==0 ) return 0;
    }
    if( fgets(&zLine[n], nLine - n, in)==0 ){
      if( n==0 ){
        free(zLine);
        return 0;
      }
      zLine[n] = 0;
      break;
    }
    while( zLine[n] ) n++;
    if( n>0 && zLine[n-1]=='\n' ){
      n--;
      if( n>0 && zLine[n-1]=='\r' ) n--;
      zLine[n] = 0;
      break;
    }
  }
#if defined(_WIN32) || defined(WIN32)
  /* For interactive input on Windows systems, translate the 
  ** multi-byte characterset characters into UTF-8. */
  if( stdin_is_interactive ){
    extern char *sqlite3_win32_mbcs_to_utf8(const char*);
    char *zTrans = sqlite3_win32_mbcs_to_utf8(zLine);
    if( zTrans ){
      int nTrans = strlen30(zTrans)+1;
      if( nTrans>nLine ){
        zLine = realloc(zLine, nTrans);
        if( zLine==0 ){
          sqlite3_free(zTrans);
          return 0;
        }
      }
      memcpy(zLine, zTrans, nTrans);
      sqlite3_free(zTrans);
    }
  }
#endif /* defined(_WIN32) || defined(WIN32) */
  return zLine;
}

/*
** Retrieve a single line of input text.
**
** If in==0 then read from standard input and prompt before each line.
** If isContinuation is true, then a continuation prompt is appropriate.
** If isContinuation is zero, then the main prompt should be used.
**
** If zPrior is not NULL then it is a buffer from a prior call to this
** routine that can be reused.
**
** The result is stored in space obtained from malloc() and must either
** be freed by the caller or else passed back into this routine via the
** zPrior argument for reuse.
*/
static char *one_input_line(FILE *in, char *zPrior, int isContinuation){
  char *zPrompt;
  char *zResult;
  if( in!=0 ){
    zResult = local_getline(zPrior, in);
  }else{
    zPrompt = isContinuation ? continuePrompt : mainPrompt;
#if SHELL_USE_LOCAL_GETLINE
    printf("%s", zPrompt);
    fflush(stdout);
    zResult = local_getline(zPrior, stdin);
#else
    free(zPrior);
    zResult = shell_readline(zPrompt);
    if( zResult && *zResult ) shell_add_history(zResult);
#endif
  }
  return zResult;
}

/*
** Render output like fprintf().  Except, if the output is going to the
** console and if this is running on a Windows machine, translate the
** output from UTF-8 into MBCS.
*/
#if defined(_WIN32) || defined(WIN32)
void utf8_printf(FILE *out, const char *zFormat, ...){
  va_list ap;
  va_start(ap, zFormat);
  if( stdout_is_console && (out==stdout || out==stderr) ){
    extern char *sqlite3_win32_utf8_to_mbcs(const char*);
    char *z1 = sqlite3_vmprintf(zFormat, ap);
    char *z2 = sqlite3_win32_utf8_to_mbcs(z1);
    sqlite3_free(z1);
    fputs(z2, out);
    sqlite3_free(z2);
  }else{
    vfprintf(out, zFormat, ap);
  }
  va_end(ap);
}
#elif !defined(utf8_printf)
# define utf8_printf fprintf
#endif

/*
** Render output like fprintf().  This should not be used on anything that
** includes string formatting (e.g. "%s").
*/
#if !defined(raw_printf)
# define raw_printf fprintf
#endif

/*
** Shell output mode information from before ".explain on", 
** saved so that it can be restored by ".explain off"
*/
typedef struct SavedModeInfo SavedModeInfo;
struct SavedModeInfo {
  int valid;          /* Is there legit data in here? */
  int mode;           /* Mode prior to ".explain on" */
  int showHeader;     /* The ".header" setting prior to ".explain on" */
  int colWidth[100];  /* Column widths prior to ".explain on" */
};

/*
** State information about the database connection is contained in an
** instance of the following structure.
*/
typedef struct ShellState ShellState;
struct ShellState {
  sqlite3 *db;           /* The database */
  int echoOn;            /* True to echo input commands */
  int autoExplain;       /* Automatically turn on .explain mode */
  int autoEQP;           /* Run EXPLAIN QUERY PLAN prior to seach SQL stmt */
  int statsOn;           /* True to display memory stats before each finalize */
  int scanstatsOn;       /* True to display scan stats before each finalize */
  int countChanges;      /* True to display change counts */
  int backslashOn;       /* Resolve C-style \x escapes in SQL input text */
  int outCount;          /* Revert to stdout when reaching zero */
  int cnt;               /* Number of records displayed so far */
  FILE *out;             /* Write results here */
  FILE *traceOut;        /* Output for sqlite3_trace() */
  int nErr;              /* Number of errors seen */
  int mode;              /* An output mode setting */
  int cMode;             /* temporary output mode for the current query */
  int normalMode;        /* Output mode before ".explain on" */
  int writableSchema;    /* True if PRAGMA writable_schema=ON */
  int showHeader;        /* True to show column names in List or Column mode */
  unsigned shellFlgs;    /* Various flags */
  char *zDestTable;      /* Name of destination table when MODE_Insert */
  char colSeparator[20]; /* Column separator character for several modes */
  char rowSeparator[20]; /* Row separator character for MODE_Ascii */
  int colWidth[100];     /* Requested width of each column when in column mode*/
  int actualWidth[100];  /* Actual width of each column */
  char nullValue[20];    /* The text to print when a NULL comes back from
                         ** the database */
  char outfile[FILENAME_MAX]; /* Filename for *out */
  const char *zDbFilename;    /* name of the database file */
  char *zFreeOnClose;         /* Filename to free when closing */
  const char *zVfs;           /* Name of VFS to use */
  sqlite3_stmt *pStmt;   /* Current statement if any. */
  FILE *pLog;            /* Write log output here */
  int *aiIndent;         /* Array of indents used in MODE_Explain */
  int nIndent;           /* Size of array aiIndent[] */
  int iIndent;           /* Index of current op in aiIndent[] */
};

/*
** These are the allowed shellFlgs values
*/
#define SHFLG_Scratch     0x00001     /* The --scratch option is used */
#define SHFLG_Pagecache   0x00002     /* The --pagecache option is used */
#define SHFLG_Lookaside   0x00004     /* Lookaside memory is used */

/*
** These are the allowed modes.
*/
#define MODE_Line     0  /* One column per line.  Blank line between records */
#define MODE_Column   1  /* One record per line in neat columns */
#define MODE_List     2  /* One record per line with a separator */
#define MODE_Semi     3  /* Same as MODE_List but append ";" to each line */
#define MODE_Html     4  /* Generate an XHTML table */
#define MODE_Insert   5  /* Generate SQL "insert" statements */
#define MODE_Tcl      6  /* Generate ANSI-C or TCL quoted elements */
#define MODE_Csv      7  /* Quote strings, numbers are plain */
#define MODE_Explain  8  /* Like MODE_Column, but do not truncate data */
#define MODE_Ascii    9  /* Use ASCII unit and record separators (0x1F/0x1E) */

static const char *modeDescr[] = {
  "line",
  "column",
  "list",
  "semi",
  "html",
  "insert",
  "tcl",
  "csv",
  "explain",
  "ascii",
};

/*
** These are the column/row/line separators used by the various
** import/export modes.
*/
#define SEP_Column    "|"
#define SEP_Row       "\n"
#define SEP_Tab       "\t"
#define SEP_Space     " "
#define SEP_Comma     ","
#define SEP_CrLf      "\r\n"
#define SEP_Unit      "\x1F"
#define SEP_Record    "\x1E"

/*
** Number of elements in an array
*/
#define ArraySize(X)  (int)(sizeof(X)/sizeof(X[0]))

/*
** A callback for the sqlite3_log() interface.
*/
static void shellLog(void *pArg, int iErrCode, const char *zMsg){
  ShellState *p = (ShellState*)pArg;
  if( p->pLog==0 ) return;
  utf8_printf(p->pLog, "(%d) %s\n", iErrCode, zMsg);
  fflush(p->pLog);
}

/*
** Output the given string as a hex-encoded blob (eg. X'1234' )
*/
static void output_hex_blob(FILE *out, const void *pBlob, int nBlob){
  int i;
  char *zBlob = (char *)pBlob;
  raw_printf(out,"X'");
  for(i=0; i<nBlob; i++){ raw_printf(out,"%02x",zBlob[i]&0xff); }
  raw_printf(out,"'");
}

/*
** Output the given string as a quoted string using SQL quoting conventions.
*/
static void output_quoted_string(FILE *out, const char *z){
  int i;
  int nSingle = 0;
  setBinaryMode(out);
  for(i=0; z[i]; i++){
    if( z[i]=='\'' ) nSingle++;
  }
  if( nSingle==0 ){
    utf8_printf(out,"'%s'",z);
  }else{
    raw_printf(out,"'");
    while( *z ){
      for(i=0; z[i] && z[i]!='\''; i++){}
      if( i==0 ){
        raw_printf(out,"''");
        z++;
      }else if( z[i]=='\'' ){
        utf8_printf(out,"%.*s''",i,z);
        z += i+1;
      }else{
        utf8_printf(out,"%s",z);
        break;
      }
    }
    raw_printf(out,"'");
  }
  setTextMode(out);
}

/*
** Output the given string as a quoted according to C or TCL quoting rules.
*/
static void output_c_string(FILE *out, const char *z){
  unsigned int c;
  fputc('"', out);
  while( (c = *(z++))!=0 ){
    if( c=='\\' ){
      fputc(c, out);
      fputc(c, out);
    }else if( c=='"' ){
      fputc('\\', out);
      fputc('"', out);
    }else if( c=='\t' ){
      fputc('\\', out);
      fputc('t', out);
    }else if( c=='\n' ){
      fputc('\\', out);
      fputc('n', out);
    }else if( c=='\r' ){
      fputc('\\', out);
      fputc('r', out);
    }else if( !isprint(c&0xff) ){
      raw_printf(out, "\\%03o", c&0xff);
    }else{
      fputc(c, out);
    }
  }
  fputc('"', out);
}

/*
** Output the given string with characters that are special to
** HTML escaped.
*/
static void output_html_string(FILE *out, const char *z){
  int i;
  if( z==0 ) z = "";
  while( *z ){
    for(i=0;   z[i] 
            && z[i]!='<' 
            && z[i]!='&' 
            && z[i]!='>' 
            && z[i]!='\"' 
            && z[i]!='\'';
        i++){}
    if( i>0 ){
      utf8_printf(out,"%.*s",i,z);
    }
    if( z[i]=='<' ){
      raw_printf(out,"&lt;");
    }else if( z[i]=='&' ){
      raw_printf(out,"&amp;");
    }else if( z[i]=='>' ){
      raw_printf(out,"&gt;");
    }else if( z[i]=='\"' ){
      raw_printf(out,"&quot;");
    }else if( z[i]=='\'' ){
      raw_printf(out,"&#39;");
    }else{
      break;
    }
    z += i + 1;
  }
}

/*
** If a field contains any character identified by a 1 in the following
** array, then the string must be quoted for CSV.
*/
static const char needCsvQuote[] = {
  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,   
  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,   
  1, 0, 1, 0, 0, 0, 0, 1,   0, 0, 0, 0, 0, 0, 0, 0, 
  0, 0, 0, 0, 0, 0, 0, 0,   0, 0, 0, 0, 0, 0, 0, 0, 
  0, 0, 0, 0, 0, 0, 0, 0,   0, 0, 0, 0, 0, 0, 0, 0, 
  0, 0, 0, 0, 0, 0, 0, 0,   0, 0, 0, 0, 0, 0, 0, 0, 
  0, 0, 0, 0, 0, 0, 0, 0,   0, 0, 0, 0, 0, 0, 0, 0, 
  0, 0, 0, 0, 0, 0, 0, 0,   0, 0, 0, 0, 0, 0, 0, 1, 
  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,   
  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,   
  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,   
  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,   
  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,   
  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,   
  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,   
  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,   
};

/*
** Output a single term of CSV.  Actually, p->colSeparator is used for
** the separator, which may or may not be a comma.  p->nullValue is
** the null value.  Strings are quoted if necessary.  The separator
** is only issued if bSep is true.
*/
static void output_csv(ShellState *p, const char *z, int bSep){
  FILE *out = p->out;
  if( z==0 ){
    utf8_printf(out,"%s",p->nullValue);
  }else{
    int i;
    int nSep = strlen30(p->colSeparator);
    for(i=0; z[i]; i++){
      if( needCsvQuote[((unsigned char*)z)[i]] 
         || (z[i]==p->colSeparator[0] && 
             (nSep==1 || memcmp(z, p->colSeparator, nSep)==0)) ){
        i = 0;
        break;
      }
    }
    if( i==0 ){
      putc('"', out);
      for(i=0; z[i]; i++){
        if( z[i]=='"' ) putc('"', out);
        putc(z[i], out);
      }
      putc('"', out);
    }else{
      utf8_printf(out, "%s", z);
    }
  }
  if( bSep ){
    utf8_printf(p->out, "%s", p->colSeparator);
  }
}

#ifdef SIGINT
/*
** This routine runs when the user presses Ctrl-C
*/
static void interrupt_handler(int NotUsed){
  UNUSED_PARAMETER(NotUsed);
  seenInterrupt++;
  if( seenInterrupt>2 ) exit(1);
  if( globalDb ) sqlite3_interrupt(globalDb);
}
#endif

/*
** This is the callback routine that the shell
** invokes for each row of a query result.
*/
static int shell_callback(
  void *pArg,
  int nArg,        /* Number of result columns */
  char **azArg,    /* Text of each result column */
  char **azCol,    /* Column names */
  int *aiType      /* Column types */
){
  int i;
  ShellState *p = (ShellState*)pArg;

  switch( p->cMode ){
    case MODE_Line: {
      int w = 5;
      if( azArg==0 ) break;
      for(i=0; i<nArg; i++){
        int len = strlen30(azCol[i] ? azCol[i] : "");
        if( len>w ) w = len;
      }
      if( p->cnt++>0 ) utf8_printf(p->out, "%s", p->rowSeparator);
      for(i=0; i<nArg; i++){
        utf8_printf(p->out,"%*s = %s%s", w, azCol[i],
                azArg[i] ? azArg[i] : p->nullValue, p->rowSeparator);
      }
      break;
    }
    case MODE_Explain:
    case MODE_Column: {
      static const int aExplainWidths[] = {4, 13, 4, 4, 4, 13, 2, 13};
      const int *colWidth;
      int showHdr;
      char *rowSep;
      if( p->cMode==MODE_Column ){
        colWidth = p->colWidth;
        showHdr = p->showHeader;
        rowSep = p->rowSeparator;
      }else{
        colWidth = aExplainWidths;
        showHdr = 1;
        rowSep = SEP_Row;
      }
      if( p->cnt++==0 ){
        for(i=0; i<nArg; i++){
          int w, n;
          if( i<ArraySize(p->colWidth) ){
            w = colWidth[i];
          }else{
            w = 0;
          }
          if( w==0 ){
            w = strlen30(azCol[i] ? azCol[i] : "");
            if( w<10 ) w = 10;
            n = strlen30(azArg && azArg[i] ? azArg[i] : p->nullValue);
            if( w<n ) w = n;
          }
          if( i<ArraySize(p->actualWidth) ){
            p->actualWidth[i] = w;
          }
          if( showHdr ){
            if( w<0 ){
              utf8_printf(p->out,"%*.*s%s",-w,-w,azCol[i],
                      i==nArg-1 ? rowSep : "  ");
            }else{
              utf8_printf(p->out,"%-*.*s%s",w,w,azCol[i],
                      i==nArg-1 ? rowSep : "  ");
            }
          }
        }
        if( showHdr ){
          for(i=0; i<nArg; i++){
            int w;
            if( i<ArraySize(p->actualWidth) ){
               w = p->actualWidth[i];
               if( w<0 ) w = -w;
            }else{
               w = 10;
            }
            utf8_printf(p->out,"%-*.*s%s",w,w,
                   "----------------------------------------------------------"
                   "----------------------------------------------------------",
                    i==nArg-1 ? rowSep : "  ");
          }
        }
      }
      if( azArg==0 ) break;
      for(i=0; i<nArg; i++){
        int w;
        if( i<ArraySize(p->actualWidth) ){
           w = p->actualWidth[i];
        }else{
           w = 10;
        }
        if( p->cMode==MODE_Explain && azArg[i] && strlen30(azArg[i])>w ){
          w = strlen30(azArg[i]);
        }
        if( i==1 && p->aiIndent && p->pStmt ){
          if( p->iIndent<p->nIndent ){
            utf8_printf(p->out, "%*.s", p->aiIndent[p->iIndent], "");
          }
          p->iIndent++;
        }
        if( w<0 ){
          utf8_printf(p->out,"%*.*s%s",-w,-w,
              azArg[i] ? azArg[i] : p->nullValue,
              i==nArg-1 ? rowSep : "  ");
        }else{
          utf8_printf(p->out,"%-*.*s%s",w,w,
              azArg[i] ? azArg[i] : p->nullValue,
              i==nArg-1 ? rowSep : "  ");
        }
      }
      break;
    }
    case MODE_Semi:
    case MODE_List: {
      if( p->cnt++==0 && p->showHeader ){
        for(i=0; i<nArg; i++){
          utf8_printf(p->out,"%s%s",azCol[i],
                  i==nArg-1 ? p->rowSeparator : p->colSeparator);
        }
      }
      if( azArg==0 ) break;
      for(i=0; i<nArg; i++){
        char *z = azArg[i];
        if( z==0 ) z = p->nullValue;
        utf8_printf(p->out, "%s", z);
        if( i<nArg-1 ){
          utf8_printf(p->out, "%s", p->colSeparator);
        }else if( p->cMode==MODE_Semi ){
          utf8_printf(p->out, ";%s", p->rowSeparator);
        }else{
          utf8_printf(p->out, "%s", p->rowSeparator);
        }
      }
      break;
    }
    case MODE_Html: {
      if( p->cnt++==0 && p->showHeader ){
        raw_printf(p->out,"<TR>");
        for(i=0; i<nArg; i++){
          raw_printf(p->out,"<TH>");
          output_html_string(p->out, azCol[i]);
          raw_printf(p->out,"</TH>\n");
        }
        raw_printf(p->out,"</TR>\n");
      }
      if( azArg==0 ) break;
      raw_printf(p->out,"<TR>");
      for(i=0; i<nArg; i++){
        raw_printf(p->out,"<TD>");
        output_html_string(p->out, azArg[i] ? azArg[i] : p->nullValue);
        raw_printf(p->out,"</TD>\n");
      }
      raw_printf(p->out,"</TR>\n");
      break;
    }
    case MODE_Tcl: {
      if( p->cnt++==0 && p->showHeader ){
        for(i=0; i<nArg; i++){
          output_c_string(p->out,azCol[i] ? azCol[i] : "");
          if(i<nArg-1) utf8_printf(p->out, "%s", p->colSeparator);
        }
        utf8_printf(p->out, "%s", p->rowSeparator);
      }
      if( azArg==0 ) break;
      for(i=0; i<nArg; i++){
        output_c_string(p->out, azArg[i] ? azArg[i] : p->nullValue);
        if(i<nArg-1) utf8_printf(p->out, "%s", p->colSeparator);
      }
      utf8_printf(p->out, "%s", p->rowSeparator);
      break;
    }
    case MODE_Csv: {
      setBinaryMode(p->out);
      if( p->cnt++==0 && p->showHeader ){
        for(i=0; i<nArg; i++){
          output_csv(p, azCol[i] ? azCol[i] : "", i<nArg-1);
        }
        utf8_printf(p->out, "%s", p->rowSeparator);
      }
      if( nArg>0 ){
        for(i=0; i<nArg; i++){
          output_csv(p, azArg[i], i<nArg-1);
        }
        utf8_printf(p->out, "%s", p->rowSeparator);
      }
      setTextMode(p->out);
      break;
    }
    case MODE_Insert: {
      p->cnt++;
      if( azArg==0 ) break;
      utf8_printf(p->out,"INSERT INTO %s",p->zDestTable);
      if( p->showHeader ){
        raw_printf(p->out,"(");
        for(i=0; i<nArg; i++){
          char *zSep = i>0 ? ",": "";
          utf8_printf(p->out, "%s%s", zSep, azCol[i]);
        }
        raw_printf(p->out,")");
      }
      raw_printf(p->out," VALUES(");
      for(i=0; i<nArg; i++){
        char *zSep = i>0 ? ",": "";
        if( (azArg[i]==0) || (aiType && aiType[i]==SQLITE_NULL) ){
          utf8_printf(p->out,"%sNULL",zSep);
        }else if( aiType && aiType[i]==SQLITE_TEXT ){
          if( zSep[0] ) utf8_printf(p->out,"%s",zSep);
          output_quoted_string(p->out, azArg[i]);
        }else if( aiType && (aiType[i]==SQLITE_INTEGER
                             || aiType[i]==SQLITE_FLOAT) ){
          utf8_printf(p->out,"%s%s",zSep, azArg[i]);
        }else if( aiType && aiType[i]==SQLITE_BLOB && p->pStmt ){
          const void *pBlob = sqlite3_column_blob(p->pStmt, i);
          int nBlob = sqlite3_column_bytes(p->pStmt, i);
          if( zSep[0] ) utf8_printf(p->out,"%s",zSep);
          output_hex_blob(p->out, pBlob, nBlob);
        }else if( isNumber(azArg[i], 0) ){
          utf8_printf(p->out,"%s%s",zSep, azArg[i]);
        }else{
          if( zSep[0] ) utf8_printf(p->out,"%s",zSep);
          output_quoted_string(p->out, azArg[i]);
        }
      }
      raw_printf(p->out,");\n");
      break;
    }
    case MODE_Ascii: {
      if( p->cnt++==0 && p->showHeader ){
        for(i=0; i<nArg; i++){
          if( i>0 ) utf8_printf(p->out, "%s", p->colSeparator);
          utf8_printf(p->out,"%s",azCol[i] ? azCol[i] : "");
        }
        utf8_printf(p->out, "%s", p->rowSeparator);
      }
      if( azArg==0 ) break;
      for(i=0; i<nArg; i++){
        if( i>0 ) utf8_printf(p->out, "%s", p->colSeparator);
        utf8_printf(p->out,"%s",azArg[i] ? azArg[i] : p->nullValue);
      }
      utf8_printf(p->out, "%s", p->rowSeparator);
      break;
    }
  }
  return 0;
}

/*
** This is the callback routine that the SQLite library
** invokes for each row of a query result.
*/
static int callback(void *pArg, int nArg, char **azArg, char **azCol){
  /* since we don't have type info, call the shell_callback with a NULL value */
  return shell_callback(pArg, nArg, azArg, azCol, NULL);
}

/*
** Set the destination table field of the ShellState structure to
** the name of the table given.  Escape any quote characters in the
** table name.
*/
static void set_table_name(ShellState *p, const char *zName){
  int i, n;
  int needQuote;
  char *z;

  if( p->zDestTable ){
    free(p->zDestTable);
    p->zDestTable = 0;
  }
  if( zName==0 ) return;
  needQuote = !isalpha((unsigned char)*zName) && *zName!='_';
  for(i=n=0; zName[i]; i++, n++){
    if( !isalnum((unsigned char)zName[i]) && zName[i]!='_' ){
      needQuote = 1;
      if( zName[i]=='\'' ) n++;
    }
  }
  if( needQuote ) n += 2;
  z = p->zDestTable = malloc( n+1 );
  if( z==0 ){
    raw_printf(stderr,"Error: out of memory\n");
    exit(1);
  }
  n = 0;
  if( needQuote ) z[n++] = '\'';
  for(i=0; zName[i]; i++){
    z[n++] = zName[i];
    if( zName[i]=='\'' ) z[n++] = '\'';
  }
  if( needQuote ) z[n++] = '\'';
  z[n] = 0;
}

/* zIn is either a pointer to a NULL-terminated string in memory obtained
** from malloc(), or a NULL pointer. The string pointed to by zAppend is
** added to zIn, and the result returned in memory obtained from malloc().
** zIn, if it was not NULL, is freed.
**
** If the third argument, quote, is not '\0', then it is used as a 
** quote character for zAppend.
*/
static char *appendText(char *zIn, char const *zAppend, char quote){
  int len;
  int i;
  int nAppend = strlen30(zAppend);
  int nIn = (zIn?strlen30(zIn):0);

  len = nAppend+nIn+1;
  if( quote ){
    len += 2;
    for(i=0; i<nAppend; i++){
      if( zAppend[i]==quote ) len++;
    }
  }

  zIn = (char *)realloc(zIn, len);
  if( !zIn ){
    return 0;
  }

  if( quote ){
    char *zCsr = &zIn[nIn];
    *zCsr++ = quote;
    for(i=0; i<nAppend; i++){
      *zCsr++ = zAppend[i];
      if( zAppend[i]==quote ) *zCsr++ = quote;
    }
    *zCsr++ = quote;
    *zCsr++ = '\0';
    assert( (zCsr-zIn)==len );
  }else{
    memcpy(&zIn[nIn], zAppend, nAppend);
    zIn[len-1] = '\0';
  }

  return zIn;
}


/*
** Execute a query statement that will generate SQL output.  Print
** the result columns, comma-separated, on a line and then add a
** semicolon terminator to the end of that line.
**
** If the number of columns is 1 and that column contains text "--"
** then write the semicolon on a separate line.  That way, if a 
** "--" comment occurs at the end of the statement, the comment
** won't consume the semicolon terminator.
*/
static int run_table_dump_query(
  ShellState *p,           /* Query context */
  const char *zSelect,     /* SELECT statement to extract content */
  const char *zFirstRow    /* Print before first row, if not NULL */
){
  sqlite3_stmt *pSelect;
  int rc;
  int nResult;
  int i;
  const char *z;
  rc = sqlite3_prepare_v2(p->db, zSelect, -1, &pSelect, 0);
  if( rc!=SQLITE_OK || !pSelect ){
    utf8_printf(p->out, "/**** ERROR: (%d) %s *****/\n", rc,
                sqlite3_errmsg(p->db));
    if( (rc&0xff)!=SQLITE_CORRUPT ) p->nErr++;
    return rc;
  }
  rc = sqlite3_step(pSelect);
  nResult = sqlite3_column_count(pSelect);
  while( rc==SQLITE_ROW ){
    if( zFirstRow ){
      utf8_printf(p->out, "%s", zFirstRow);
      zFirstRow = 0;
    }
    z = (const char*)sqlite3_column_text(pSelect, 0);
    utf8_printf(p->out, "%s", z);
    for(i=1; i<nResult; i++){ 
      utf8_printf(p->out, ",%s", sqlite3_column_text(pSelect, i));
    }
    if( z==0 ) z = "";
    while( z[0] && (z[0]!='-' || z[1]!='-') ) z++;
    if( z[0] ){
      raw_printf(p->out, "\n;\n");
    }else{
      raw_printf(p->out, ";\n");
    }    
    rc = sqlite3_step(pSelect);
  }
  rc = sqlite3_finalize(pSelect);
  if( rc!=SQLITE_OK ){
    utf8_printf(p->out, "/**** ERROR: (%d) %s *****/\n", rc,
                sqlite3_errmsg(p->db));
    if( (rc&0xff)!=SQLITE_CORRUPT ) p->nErr++;
  }
  return rc;
}

/*
** Allocate space and save off current error string.
*/
static char *save_err_msg(
  sqlite3 *db            /* Database to query */
){
  int nErrMsg = 1+strlen30(sqlite3_errmsg(db));
  char *zErrMsg = sqlite3_malloc64(nErrMsg);
  if( zErrMsg ){
    memcpy(zErrMsg, sqlite3_errmsg(db), nErrMsg);
  }
  return zErrMsg;
}

#ifdef __linux__
/*
** Attempt to display I/O stats on Linux using /proc/PID/io
*/
static void displayLinuxIoStats(FILE *out){
  FILE *in;
  char z[200];
  sqlite3_snprintf(sizeof(z), z, "/proc/%d/io", getpid());
  in = fopen(z, "rb");
  if( in==0 ) return;
  while( fgets(z, sizeof(z), in)!=0 ){
    static const struct {
      const char *zPattern;
      const char *zDesc;
    } aTrans[] = {
      { "rchar: ",                  "Bytes received by read():" },
      { "wchar: ",                  "Bytes sent to write():"    },
      { "syscr: ",                  "Read() system calls:"      },
      { "syscw: ",                  "Write() system calls:"     },
      { "read_bytes: ",             "Bytes read from storage:"  },
      { "write_bytes: ",            "Bytes written to storage:" },
      { "cancelled_write_bytes: ",  "Cancelled write bytes:"    },
    };
    int i;
    for(i=0; i<ArraySize(aTrans); i++){
      int n = (int)strlen(aTrans[i].zPattern);
      if( strncmp(aTrans[i].zPattern, z, n)==0 ){
        raw_printf(out, "%-36s %s", aTrans[i].zDesc, &z[n]);
        break;
      }
    }
  }
  fclose(in);
}   
#endif


/*
** Display memory stats.
*/
static int display_stats(
  sqlite3 *db,                /* Database to query */
  ShellState *pArg,           /* Pointer to ShellState */
  int bReset                  /* True to reset the stats */
){
  int iCur;
  int iHiwtr;

  if( pArg && pArg->out ){
    
    iHiwtr = iCur = -1;
    sqlite3_status(SQLITE_STATUS_MEMORY_USED, &iCur, &iHiwtr, bReset);
    raw_printf(pArg->out,
            "Memory Used:                         %d (max %d) bytes\n",
            iCur, iHiwtr);
    iHiwtr = iCur = -1;
    sqlite3_status(SQLITE_STATUS_MALLOC_COUNT, &iCur, &iHiwtr, bReset);
    raw_printf(pArg->out, "Number of Outstanding Allocations:   %d (max %d)\n",
            iCur, iHiwtr);
    if( pArg->shellFlgs & SHFLG_Pagecache ){
      iHiwtr = iCur = -1;
      sqlite3_status(SQLITE_STATUS_PAGECACHE_USED, &iCur, &iHiwtr, bReset);
      raw_printf(pArg->out,
              "Number of Pcache Pages Used:         %d (max %d) pages\n",
              iCur, iHiwtr);
    }
    iHiwtr = iCur = -1;
    sqlite3_status(SQLITE_STATUS_PAGECACHE_OVERFLOW, &iCur, &iHiwtr, bReset);
    raw_printf(pArg->out,
            "Number of Pcache Overflow Bytes:     %d (max %d) bytes\n",
            iCur, iHiwtr);
    if( pArg->shellFlgs & SHFLG_Scratch ){
      iHiwtr = iCur = -1;
      sqlite3_status(SQLITE_STATUS_SCRATCH_USED, &iCur, &iHiwtr, bReset);
      raw_printf(pArg->out,
              "Number of Scratch Allocations Used:  %d (max %d)\n",
              iCur, iHiwtr);
    }
    iHiwtr = iCur = -1;
    sqlite3_status(SQLITE_STATUS_SCRATCH_OVERFLOW, &iCur, &iHiwtr, bReset);
    raw_printf(pArg->out,
            "Number of Scratch Overflow Bytes:    %d (max %d) bytes\n",
            iCur, iHiwtr);
    iHiwtr = iCur = -1;
    sqlite3_status(SQLITE_STATUS_MALLOC_SIZE, &iCur, &iHiwtr, bReset);
    raw_printf(pArg->out, "Largest Allocation:                  %d bytes\n",
            iHiwtr);
    iHiwtr = iCur = -1;
    sqlite3_status(SQLITE_STATUS_PAGECACHE_SIZE, &iCur, &iHiwtr, bReset);
    raw_printf(pArg->out, "Largest Pcache Allocation:           %d bytes\n",
            iHiwtr);
    iHiwtr = iCur = -1;
    sqlite3_status(SQLITE_STATUS_SCRATCH_SIZE, &iCur, &iHiwtr, bReset);
    raw_printf(pArg->out, "Largest Scratch Allocation:          %d bytes\n",
            iHiwtr);
#ifdef YYTRACKMAXSTACKDEPTH
    iHiwtr = iCur = -1;
    sqlite3_status(SQLITE_STATUS_PARSER_STACK, &iCur, &iHiwtr, bReset);
    raw_printf(pArg->out, "Deepest Parser Stack:                %d (max %d)\n",
            iCur, iHiwtr);
#endif
  }

  if( pArg && pArg->out && db ){
    if( pArg->shellFlgs & SHFLG_Lookaside ){
      iHiwtr = iCur = -1;
      sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_USED,
                        &iCur, &iHiwtr, bReset);
      raw_printf(pArg->out,
              "Lookaside Slots Used:                %d (max %d)\n",
              iCur, iHiwtr);
      sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_HIT,
                        &iCur, &iHiwtr, bReset);
      raw_printf(pArg->out, "Successful lookaside attempts:       %d\n",
              iHiwtr);
      sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE,
                        &iCur, &iHiwtr, bReset);
      raw_printf(pArg->out, "Lookaside failures due to size:      %d\n",
              iHiwtr);
      sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL,
                        &iCur, &iHiwtr, bReset);
      raw_printf(pArg->out, "Lookaside failures due to OOM:       %d\n",
              iHiwtr);
    }
    iHiwtr = iCur = -1;
    sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_USED, &iCur, &iHiwtr, bReset);
    raw_printf(pArg->out, "Pager Heap Usage:                    %d bytes\n",
            iCur);
    iHiwtr = iCur = -1;
    sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_HIT, &iCur, &iHiwtr, 1);
    raw_printf(pArg->out, "Page cache hits:                     %d\n", iCur);
    iHiwtr = iCur = -1;
    sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_MISS, &iCur, &iHiwtr, 1);
    raw_printf(pArg->out, "Page cache misses:                   %d\n", iCur); 
    iHiwtr = iCur = -1;
    sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_WRITE, &iCur, &iHiwtr, 1);
    raw_printf(pArg->out, "Page cache writes:                   %d\n", iCur); 
    iHiwtr = iCur = -1;
    sqlite3_db_status(db, SQLITE_DBSTATUS_SCHEMA_USED, &iCur, &iHiwtr, bReset);
    raw_printf(pArg->out, "Schema Heap Usage:                   %d bytes\n",
            iCur); 
    iHiwtr = iCur = -1;
    sqlite3_db_status(db, SQLITE_DBSTATUS_STMT_USED, &iCur, &iHiwtr, bReset);
    raw_printf(pArg->out, "Statement Heap/Lookaside Usage:      %d bytes\n",
            iCur); 
  }

  if( pArg && pArg->out && db && pArg->pStmt ){
    iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_FULLSCAN_STEP,
                               bReset);
    raw_printf(pArg->out, "Fullscan Steps:                      %d\n", iCur);
    iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_SORT, bReset);
    raw_printf(pArg->out, "Sort Operations:                     %d\n", iCur);
    iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_AUTOINDEX,bReset);
    raw_printf(pArg->out, "Autoindex Inserts:                   %d\n", iCur);
    iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_VM_STEP, bReset);
    raw_printf(pArg->out, "Virtual Machine Steps:               %d\n", iCur);
  }

#ifdef __linux__
  displayLinuxIoStats(pArg->out);
#endif

  /* Do not remove this machine readable comment: extra-stats-output-here */

  return 0;
}

/*
** Display scan stats.
*/
static void display_scanstats(
  sqlite3 *db,                    /* Database to query */
  ShellState *pArg                /* Pointer to ShellState */
){
#ifndef SQLITE_ENABLE_STMT_SCANSTATUS
  UNUSED_PARAMETER(db);
  UNUSED_PARAMETER(pArg);
#else
  int i, k, n, mx;
  raw_printf(pArg->out, "-------- scanstats --------\n");
  mx = 0;
  for(k=0; k<=mx; k++){
    double rEstLoop = 1.0;
    for(i=n=0; 1; i++){
      sqlite3_stmt *p = pArg->pStmt;
      sqlite3_int64 nLoop, nVisit;
      double rEst;
      int iSid;
      const char *zExplain;
      if( sqlite3_stmt_scanstatus(p, i, SQLITE_SCANSTAT_NLOOP, (void*)&nLoop) ){
        break;
      }
      sqlite3_stmt_scanstatus(p, i, SQLITE_SCANSTAT_SELECTID, (void*)&iSid);
      if( iSid>mx ) mx = iSid;
      if( iSid!=k ) continue;
      if( n==0 ){
        rEstLoop = (double)nLoop;
        if( k>0 ) raw_printf(pArg->out, "-------- subquery %d -------\n", k);
      }
      n++;
      sqlite3_stmt_scanstatus(p, i, SQLITE_SCANSTAT_NVISIT, (void*)&nVisit);
      sqlite3_stmt_scanstatus(p, i, SQLITE_SCANSTAT_EST, (void*)&rEst);
      sqlite3_stmt_scanstatus(p, i, SQLITE_SCANSTAT_EXPLAIN, (void*)&zExplain);
      utf8_printf(pArg->out, "Loop %2d: %s\n", n, zExplain);
      rEstLoop *= rEst;
      raw_printf(pArg->out, 
          "         nLoop=%-8lld nRow=%-8lld estRow=%-8lld estRow/Loop=%-8g\n",
          nLoop, nVisit, (sqlite3_int64)(rEstLoop+0.5), rEst
      );
    }
  }
  raw_printf(pArg->out, "---------------------------\n");
#endif
}

/*
** Parameter azArray points to a zero-terminated array of strings. zStr
** points to a single nul-terminated string. Return non-zero if zStr
** is equal, according to strcmp(), to any of the strings in the array.
** Otherwise, return zero.
*/
static int str_in_array(const char *zStr, const char **azArray){
  int i;
  for(i=0; azArray[i]; i++){
    if( 0==strcmp(zStr, azArray[i]) ) return 1;
  }
  return 0;
}

/*
** If compiled statement pSql appears to be an EXPLAIN statement, allocate
** and populate the ShellState.aiIndent[] array with the number of
** spaces each opcode should be indented before it is output. 
**
** The indenting rules are:
**
**     * For each "Next", "Prev", "VNext" or "VPrev" instruction, indent
**       all opcodes that occur between the p2 jump destination and the opcode
**       itself by 2 spaces.
**
**     * For each "Goto", if the jump destination is earlier in the program
**       and ends on one of:
**          Yield  SeekGt  SeekLt  RowSetRead  Rewind
**       or if the P1 parameter is one instead of zero,
**       then indent all opcodes between the earlier instruction
**       and "Goto" by 2 spaces.
*/
static void explain_data_prepare(ShellState *p, sqlite3_stmt *pSql){
  const char *zSql;               /* The text of the SQL statement */
  const char *z;                  /* Used to check if this is an EXPLAIN */
  int *abYield = 0;               /* True if op is an OP_Yield */
  int nAlloc = 0;                 /* Allocated size of p->aiIndent[], abYield */
  int iOp;                        /* Index of operation in p->aiIndent[] */

  const char *azNext[] = { "Next", "Prev", "VPrev", "VNext", "SorterNext",
                           "NextIfOpen", "PrevIfOpen", 0 };
  const char *azYield[] = { "Yield", "SeekLT", "SeekGT", "RowSetRead",
                            "Rewind", 0 };
  const char *azGoto[] = { "Goto", 0 };

  /* Try to figure out if this is really an EXPLAIN statement. If this
  ** cannot be verified, return early.  */
  if( sqlite3_column_count(pSql)!=8 ){
    p->cMode = p->mode;
    return;
  }
  zSql = sqlite3_sql(pSql);
  if( zSql==0 ) return;
  for(z=zSql; *z==' ' || *z=='\t' || *z=='\n' || *z=='\f' || *z=='\r'; z++);
  if( sqlite3_strnicmp(z, "explain", 7) ){
    p->cMode = p->mode;
    return;
  }

  for(iOp=0; SQLITE_ROW==sqlite3_step(pSql); iOp++){
    int i;
    int iAddr = sqlite3_column_int(pSql, 0);
    const char *zOp = (const char*)sqlite3_column_text(pSql, 1);

    /* Set p2 to the P2 field of the current opcode. Then, assuming that
    ** p2 is an instruction address, set variable p2op to the index of that
    ** instruction in the aiIndent[] array. p2 and p2op may be different if
    ** the current instruction is part of a sub-program generated by an
    ** SQL trigger or foreign key.  */
    int p2 = sqlite3_column_int(pSql, 3);
    int p2op = (p2 + (iOp-iAddr));

    /* Grow the p->aiIndent array as required */
    if( iOp>=nAlloc ){
      if( iOp==0 ){
        /* Do further verfication that this is explain output.  Abort if
        ** it is not */
        static const char *explainCols[] = {
           "addr", "opcode", "p1", "p2", "p3", "p4", "p5", "comment" };
        int jj;
        for(jj=0; jj<ArraySize(explainCols); jj++){
          if( strcmp(sqlite3_column_name(pSql,jj),explainCols[jj])!=0 ){
            p->cMode = p->mode;
            sqlite3_reset(pSql);
            return;
          }
        }
      }
      nAlloc += 100;
      p->aiIndent = (int*)sqlite3_realloc64(p->aiIndent, nAlloc*sizeof(int));
      abYield = (int*)sqlite3_realloc64(abYield, nAlloc*sizeof(int));
    }
    abYield[iOp] = str_in_array(zOp, azYield);
    p->aiIndent[iOp] = 0;
    p->nIndent = iOp+1;

    if( str_in_array(zOp, azNext) ){
      for(i=p2op; i<iOp; i++) p->aiIndent[i] += 2;
    }
    if( str_in_array(zOp, azGoto) && p2op<p->nIndent
     && (abYield[p2op] || sqlite3_column_int(pSql, 2))
    ){
      for(i=p2op+1; i<iOp; i++) p->aiIndent[i] += 2;
    }
  }

  p->iIndent = 0;
  sqlite3_free(abYield);
  sqlite3_reset(pSql);
}

/*
** Free the array allocated by explain_data_prepare().
*/
static void explain_data_delete(ShellState *p){
  sqlite3_free(p->aiIndent);
  p->aiIndent = 0;
  p->nIndent = 0;
  p->iIndent = 0;
}

/*
** Execute a statement or set of statements.  Print 
** any result rows/columns depending on the current mode 
** set via the supplied callback.
**
** This is very similar to SQLite's built-in sqlite3_exec() 
** function except it takes a slightly different callback 
** and callback data argument.
*/
static int shell_exec(
  sqlite3 *db,                              /* An open database */
  const char *zSql,                         /* SQL to be evaluated */
  int (*xCallback)(void*,int,char**,char**,int*),   /* Callback function */
                                            /* (not the same as sqlite3_exec) */
  ShellState *pArg,                         /* Pointer to ShellState */
  char **pzErrMsg                           /* Error msg written here */
){
  sqlite3_stmt *pStmt = NULL;     /* Statement to execute. */
  int rc = SQLITE_OK;             /* Return Code */
  int rc2;
  const char *zLeftover;          /* Tail of unprocessed SQL */

  if( pzErrMsg ){
    *pzErrMsg = NULL;
  }

  while( zSql[0] && (SQLITE_OK == rc) ){
    rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, &zLeftover);
    if( SQLITE_OK != rc ){
      if( pzErrMsg ){
        *pzErrMsg = save_err_msg(db);
      }
    }else{
      if( !pStmt ){
        /* this happens for a comment or white-space */
        zSql = zLeftover;
        while( IsSpace(zSql[0]) ) zSql++;
        continue;
      }

      /* save off the prepared statment handle and reset row count */
      if( pArg ){
        pArg->pStmt = pStmt;
        pArg->cnt = 0;
      }

      /* echo the sql statement if echo on */
      if( pArg && pArg->echoOn ){
        const char *zStmtSql = sqlite3_sql(pStmt);
        utf8_printf(pArg->out, "%s\n", zStmtSql ? zStmtSql : zSql);
      }

      /* Show the EXPLAIN QUERY PLAN if .eqp is on */
      if( pArg && pArg->autoEQP ){
        sqlite3_stmt *pExplain;
        char *zEQP = sqlite3_mprintf("EXPLAIN QUERY PLAN %s",
                                     sqlite3_sql(pStmt));
        rc = sqlite3_prepare_v2(db, zEQP, -1, &pExplain, 0);
        if( rc==SQLITE_OK ){
          while( sqlite3_step(pExplain)==SQLITE_ROW ){
            raw_printf(pArg->out,"--EQP-- %d,",sqlite3_column_int(pExplain, 0));
            raw_printf(pArg->out,"%d,", sqlite3_column_int(pExplain, 1));
            raw_printf(pArg->out,"%d,", sqlite3_column_int(pExplain, 2));
            utf8_printf(pArg->out,"%s\n", sqlite3_column_text(pExplain, 3));
          }
        }
        sqlite3_finalize(pExplain);
        sqlite3_free(zEQP);
      }

      if( pArg ){
        pArg->cMode = pArg->mode;
        if( pArg->autoExplain
         && sqlite3_column_count(pStmt)==8
         && sqlite3_strlike("%EXPLAIN%", sqlite3_sql(pStmt),0)==0
        ){
          pArg->cMode = MODE_Explain;
        }
      
        /* If the shell is currently in ".explain" mode, gather the extra
        ** data required to add indents to the output.*/
        if( pArg->cMode==MODE_Explain ){
          explain_data_prepare(pArg, pStmt);
        }
      }

      /* perform the first step.  this will tell us if we
      ** have a result set or not and how wide it is.
      */
      rc = sqlite3_step(pStmt);
      /* if we have a result set... */
      if( SQLITE_ROW == rc ){
        /* if we have a callback... */
        if( xCallback ){
          /* allocate space for col name ptr, value ptr, and type */
          int nCol = sqlite3_column_count(pStmt);
          void *pData = sqlite3_malloc64(3*nCol*sizeof(const char*) + 1);
          if( !pData ){
            rc = SQLITE_NOMEM;
          }else{
            char **azCols = (char **)pData;      /* Names of result columns */
            char **azVals = &azCols[nCol];       /* Results */
            int *aiTypes = (int *)&azVals[nCol]; /* Result types */
            int i, x;
            assert(sizeof(int) <= sizeof(char *)); 
            /* save off ptrs to column names */
            for(i=0; i<nCol; i++){
              azCols[i] = (char *)sqlite3_column_name(pStmt, i);
            }
            do{
              /* extract the data and data types */
              for(i=0; i<nCol; i++){
                aiTypes[i] = x = sqlite3_column_type(pStmt, i);
                if( x==SQLITE_BLOB && pArg && pArg->cMode==MODE_Insert ){
                  azVals[i] = "";
                }else{
                  azVals[i] = (char*)sqlite3_column_text(pStmt, i);
                }
                if( !azVals[i] && (aiTypes[i]!=SQLITE_NULL) ){
                  rc = SQLITE_NOMEM;
                  break; /* from for */
                }
              } /* end for */

              /* if data and types extracted successfully... */
              if( SQLITE_ROW == rc ){ 
                /* call the supplied callback with the result row data */
                if( xCallback(pArg, nCol, azVals, azCols, aiTypes) ){
                  rc = SQLITE_ABORT;
                }else{
                  rc = sqlite3_step(pStmt);
                }
              }
            } while( SQLITE_ROW == rc );
            sqlite3_free(pData);
          }
        }else{
          do{
            rc = sqlite3_step(pStmt);
          } while( rc == SQLITE_ROW );
        }
      }

      explain_data_delete(pArg);

      /* print usage stats if stats on */
      if( pArg && pArg->statsOn ){
        display_stats(db, pArg, 0);
      }

      /* print loop-counters if required */
      if( pArg && pArg->scanstatsOn ){
        display_scanstats(db, pArg);
      }

      /* Finalize the statement just executed. If this fails, save a 
      ** copy of the error message. Otherwise, set zSql to point to the
      ** next statement to execute. */
      rc2 = sqlite3_finalize(pStmt);
      if( rc!=SQLITE_NOMEM ) rc = rc2;
      if( rc==SQLITE_OK ){
        zSql = zLeftover;
        while( IsSpace(zSql[0]) ) zSql++;
      }else if( pzErrMsg ){
        *pzErrMsg = save_err_msg(db);
      }

      /* clear saved stmt handle */
      if( pArg ){
        pArg->pStmt = NULL;
      }
    }
  } /* end while */

  return rc;
}


/*
** This is a different callback routine used for dumping the database.
** Each row received by this callback consists of a table name,
** the table type ("index" or "table") and SQL to create the table.
** This routine should print text sufficient to recreate the table.
*/
static int dump_callback(void *pArg, int nArg, char **azArg, char **azCol){
  int rc;
  const char *zTable;
  const char *zType;
  const char *zSql;
  const char *zPrepStmt = 0;
  ShellState *p = (ShellState *)pArg;

  UNUSED_PARAMETER(azCol);
  if( nArg!=3 ) return 1;
  zTable = azArg[0];
  zType = azArg[1];
  zSql = azArg[2];
  
  if( strcmp(zTable, "sqlite_sequence")==0 ){
    zPrepStmt = "DELETE FROM sqlite_sequence;\n";
  }else if( sqlite3_strglob("sqlite_stat?", zTable)==0 ){
    raw_printf(p->out, "ANALYZE sqlite_master;\n");
  }else if( strncmp(zTable, "sqlite_", 7)==0 ){
    return 0;
  }else if( strncmp(zSql, "CREATE VIRTUAL TABLE", 20)==0 ){
    char *zIns;
    if( !p->writableSchema ){
      raw_printf(p->out, "PRAGMA writable_schema=ON;\n");
      p->writableSchema = 1;
    }
    zIns = sqlite3_mprintf(
       "INSERT INTO sqlite_master(type,name,tbl_name,rootpage,sql)"
       "VALUES('table','%q','%q',0,'%q');",
       zTable, zTable, zSql);
    utf8_printf(p->out, "%s\n", zIns);
    sqlite3_free(zIns);
    return 0;
  }else{
    utf8_printf(p->out, "%s;\n", zSql);
  }

  if( strcmp(zType, "table")==0 ){
    sqlite3_stmt *pTableInfo = 0;
    char *zSelect = 0;
    char *zTableInfo = 0;
    char *zTmp = 0;
    int nRow = 0;
   
    zTableInfo = appendText(zTableInfo, "PRAGMA table_info(", 0);
    zTableInfo = appendText(zTableInfo, zTable, '"');
    zTableInfo = appendText(zTableInfo, ");", 0);

    rc = sqlite3_prepare_v2(p->db, zTableInfo, -1, &pTableInfo, 0);
    free(zTableInfo);
    if( rc!=SQLITE_OK || !pTableInfo ){
      return 1;
    }

    zSelect = appendText(zSelect, "SELECT 'INSERT INTO ' || ", 0);
    /* Always quote the table name, even if it appears to be pure ascii,
    ** in case it is a keyword. Ex:  INSERT INTO "table" ... */
    zTmp = appendText(zTmp, zTable, '"');
    if( zTmp ){
      zSelect = appendText(zSelect, zTmp, '\'');
      free(zTmp);
    }
    zSelect = appendText(zSelect, " || ' VALUES(' || ", 0);
    rc = sqlite3_step(pTableInfo);
    while( rc==SQLITE_ROW ){
      const char *zText = (const char *)sqlite3_column_text(pTableInfo, 1);
      zSelect = appendText(zSelect, "quote(", 0);
      zSelect = appendText(zSelect, zText, '"');
      rc = sqlite3_step(pTableInfo);
      if( rc==SQLITE_ROW ){
        zSelect = appendText(zSelect, "), ", 0);
      }else{
        zSelect = appendText(zSelect, ") ", 0);
      }
      nRow++;
    }
    rc = sqlite3_finalize(pTableInfo);
    if( rc!=SQLITE_OK || nRow==0 ){
      free(zSelect);
      return 1;
    }
    zSelect = appendText(zSelect, "|| ')' FROM  ", 0);
    zSelect = appendText(zSelect, zTable, '"');

    rc = run_table_dump_query(p, zSelect, zPrepStmt);
    if( rc==SQLITE_CORRUPT ){
      zSelect = appendText(zSelect, " ORDER BY rowid DESC", 0);
      run_table_dump_query(p, zSelect, 0);
    }
    free(zSelect);
  }
  return 0;
}

/*
** Run zQuery.  Use dump_callback() as the callback routine so that
** the contents of the query are output as SQL statements.
**
** If we get a SQLITE_CORRUPT error, rerun the query after appending
** "ORDER BY rowid DESC" to the end.
*/
static int run_schema_dump_query(
  ShellState *p, 
  const char *zQuery
){
  int rc;
  char *zErr = 0;
  rc = sqlite3_exec(p->db, zQuery, dump_callback, p, &zErr);
  if( rc==SQLITE_CORRUPT ){
    char *zQ2;
    int len = strlen30(zQuery);
    raw_printf(p->out, "/****** CORRUPTION ERROR *******/\n");
    if( zErr ){
      utf8_printf(p->out, "/****** %s ******/\n", zErr);
      sqlite3_free(zErr);
      zErr = 0;
    }
    zQ2 = malloc( len+100 );
    if( zQ2==0 ) return rc;
    sqlite3_snprintf(len+100, zQ2, "%s ORDER BY rowid DESC", zQuery);
    rc = sqlite3_exec(p->db, zQ2, dump_callback, p, &zErr);
    if( rc ){
      utf8_printf(p->out, "/****** ERROR: %s ******/\n", zErr);
    }else{
      rc = SQLITE_CORRUPT;
    }
    sqlite3_free(zErr);
    free(zQ2);
  }
  return rc;
}

/*
** Text of a help message
*/
static char zHelp[] =
  ".backup ?DB? FILE      Backup DB (default \"main\") to FILE\n"
  ".bail on|off           Stop after hitting an error.  Default OFF\n"
  ".binary on|off         Turn binary output on or off.  Default OFF\n"
  ".changes on|off        Show number of rows changed by SQL\n"
  ".clone NEWDB           Clone data into NEWDB from the existing database\n"
  ".databases             List names and files of attached databases\n"
  ".dbinfo ?DB?           Show status information about the database\n"
  ".dump ?TABLE? ...      Dump the database in an SQL text format\n"
  "                         If TABLE specified, only dump tables matching\n"
  "                         LIKE pattern TABLE.\n"
  ".echo on|off           Turn command echo on or off\n"
  ".eqp on|off            Enable or disable automatic EXPLAIN QUERY PLAN\n"
  ".exit                  Exit this program\n"
  ".explain ?on|off|auto? Turn EXPLAIN output mode on or off or to automatic\n"
  ".fullschema            Show schema and the content of sqlite_stat tables\n"
  ".headers on|off        Turn display of headers on or off\n"
  ".help                  Show this message\n"
  ".import FILE TABLE     Import data from FILE into TABLE\n"
  ".indexes ?TABLE?       Show names of all indexes\n"
  "                         If TABLE specified, only show indexes for tables\n"
  "                         matching LIKE pattern TABLE.\n"
#ifdef SQLITE_ENABLE_IOTRACE
  ".iotrace FILE          Enable I/O diagnostic logging to FILE\n"
#endif
  ".limit ?LIMIT? ?VAL?   Display or change the value of an SQLITE_LIMIT\n"
#ifndef SQLITE_OMIT_LOAD_EXTENSION
  ".load FILE ?ENTRY?     Load an extension library\n"
#endif
  ".log FILE|off          Turn logging on or off.  FILE can be stderr/stdout\n"
  ".mode MODE ?TABLE?     Set output mode where MODE is one of:\n"
  "                         ascii    Columns/rows delimited by 0x1F and 0x1E\n"
  "                         csv      Comma-separated values\n"
  "                         column   Left-aligned columns.  (See .width)\n"
  "                         html     HTML <table> code\n"
  "                         insert   SQL insert statements for TABLE\n"
  "                         line     One value per line\n"
  "                         list     Values delimited by .separator strings\n"
  "                         tabs     Tab-separated values\n"
  "                         tcl      TCL list elements\n"
  ".nullvalue STRING      Use STRING in place of NULL values\n"
  ".once FILENAME         Output for the next SQL command only to FILENAME\n"
  ".open ?FILENAME?       Close existing database and reopen FILENAME\n"
  ".output ?FILENAME?     Send output to FILENAME or stdout\n"
  ".print STRING...       Print literal STRING\n"
  ".prompt MAIN CONTINUE  Replace the standard prompts\n"
  ".quit                  Exit this program\n"
  ".read FILENAME         Execute SQL in FILENAME\n"
  ".restore ?DB? FILE     Restore content of DB (default \"main\") from FILE\n"
  ".save FILE             Write in-memory database into FILE\n"
  ".scanstats on|off      Turn sqlite3_stmt_scanstatus() metrics on or off\n"
  ".schema ?TABLE?        Show the CREATE statements\n"
  "                         If TABLE specified, only show tables matching\n"
  "                         LIKE pattern TABLE.\n"
  ".separator COL ?ROW?   Change the column separator and optionally the row\n"
  "                         separator for both the output mode and .import\n"
  ".shell CMD ARGS...     Run CMD ARGS... in a system shell\n"
  ".show                  Show the current values for various settings\n"
  ".stats ?on|off?        Show stats or turn stats on or off\n"
  ".system CMD ARGS...    Run CMD ARGS... in a system shell\n"
  ".tables ?TABLE?        List names of tables\n"
  "                         If TABLE specified, only list tables matching\n"
  "                         LIKE pattern TABLE.\n"
  ".timeout MS            Try opening locked tables for MS milliseconds\n"
  ".timer on|off          Turn SQL timer on or off\n"
  ".trace FILE|off        Output each SQL statement as it is run\n"
  ".vfsinfo ?AUX?         Information about the top-level VFS\n"
  ".vfslist               List all available VFSes\n"
  ".vfsname ?AUX?         Print the name of the VFS stack\n"
  ".width NUM1 NUM2 ...   Set column widths for \"column\" mode\n"
  "                         Negative values right-justify\n"
;

/* Forward reference */
static int process_input(ShellState *p, FILE *in);
/*
** Implementation of the "readfile(X)" SQL function.  The entire content
** of the file named X is read and returned as a BLOB.  NULL is returned
** if the file does not exist or is unreadable.
*/
static void readfileFunc(
  sqlite3_context *context,
  int argc,
  sqlite3_value **argv
){
  const char *zName;
  FILE *in;
  long nIn;
  void *pBuf;

  UNUSED_PARAMETER(argc);
  zName = (const char*)sqlite3_value_text(argv[0]);
  if( zName==0 ) return;
  in = fopen(zName, "rb");
  if( in==0 ) return;
  fseek(in, 0, SEEK_END);
  nIn = ftell(in);
  rewind(in);
  pBuf = sqlite3_malloc64( nIn );
  if( pBuf && 1==fread(pBuf, nIn, 1, in) ){
    sqlite3_result_blob(context, pBuf, nIn, sqlite3_free);
  }else{
    sqlite3_free(pBuf);
  }
  fclose(in);
}

/*
** Implementation of the "writefile(X,Y)" SQL function.  The argument Y
** is written into file X.  The number of bytes written is returned.  Or
** NULL is returned if something goes wrong, such as being unable to open
** file X for writing.
*/
static void writefileFunc(
  sqlite3_context *context,
  int argc,
  sqlite3_value **argv
){
  FILE *out;
  const char *z;
  sqlite3_int64 rc;
  const char *zFile;

  UNUSED_PARAMETER(argc);
  zFile = (const char*)sqlite3_value_text(argv[0]);
  if( zFile==0 ) return;
  out = fopen(zFile, "wb");
  if( out==0 ) return;
  z = (const char*)sqlite3_value_blob(argv[1]);
  if( z==0 ){
    rc = 0;
  }else{
    rc = fwrite(z, 1, sqlite3_value_bytes(argv[1]), out);
  }
  fclose(out);
  sqlite3_result_int64(context, rc);
}

/*
** Make sure the database is open.  If it is not, then open it.  If
** the database fails to open, print an error message and exit.
*/
static void open_db(ShellState *p, int keepAlive){
  if( p->db==0 ){
    sqlite3_initialize();
    sqlite3_open(p->zDbFilename, &p->db);
    globalDb = p->db;
    if( p->db && sqlite3_errcode(p->db)==SQLITE_OK ){
      sqlite3_create_function(p->db, "shellstatic", 0, SQLITE_UTF8, 0,
          shellstaticFunc, 0, 0);
    }
    if( p->db==0 || SQLITE_OK!=sqlite3_errcode(p->db) ){
      utf8_printf(stderr,"Error: unable to open database \"%s\": %s\n", 
          p->zDbFilename, sqlite3_errmsg(p->db));
      if( keepAlive ) return;
      exit(1);
    }
#ifndef SQLITE_OMIT_LOAD_EXTENSION
    sqlite3_enable_load_extension(p->db, 1);
#endif
    sqlite3_create_function(p->db, "readfile", 1, SQLITE_UTF8, 0,
                            readfileFunc, 0, 0);
    sqlite3_create_function(p->db, "writefile", 2, SQLITE_UTF8, 0,
                            writefileFunc, 0, 0);
  }
}

/*
** Do C-language style dequoting.
**
**    \a    -> alarm
**    \b    -> backspace
**    \t    -> tab
**    \n    -> newline
**    \v    -> vertical tab
**    \f    -> form feed
**    \r    -> carriage return
**    \s    -> space
**    \"    -> "
**    \'    -> '
**    \\    -> backslash
**    \NNN  -> ascii character NNN in octal
*/
static void resolve_backslashes(char *z){
  int i, j;
  char c;
  while( *z && *z!='\\' ) z++;
  for(i=j=0; (c = z[i])!=0; i++, j++){
    if( c=='\\' && z[i+1]!=0 ){
      c = z[++i];
      if( c=='a' ){
        c = '\a';
      }else if( c=='b' ){
        c = '\b';
      }else if( c=='t' ){
        c = '\t';
      }else if( c=='n' ){
        c = '\n';
      }else if( c=='v' ){
        c = '\v';
      }else if( c=='f' ){
        c = '\f';
      }else if( c=='r' ){
        c = '\r';
      }else if( c=='"' ){
        c = '"';
      }else if( c=='\'' ){
        c = '\'';
      }else if( c=='\\' ){
        c = '\\';
      }else if( c>='0' && c<='7' ){
        c -= '0';
        if( z[i+1]>='0' && z[i+1]<='7' ){
          i++;
          c = (c<<3) + z[i] - '0';
          if( z[i+1]>='0' && z[i+1]<='7' ){
            i++;
            c = (c<<3) + z[i] - '0';
          }
        }
      }
    }
    z[j] = c;
  }
  if( j<i ) z[j] = 0;
}

/*
** Return the value of a hexadecimal digit.  Return -1 if the input
** is not a hex digit.
*/
static int hexDigitValue(char c){
  if( c>='0' && c<='9' ) return c - '0';
  if( c>='a' && c<='f' ) return c - 'a' + 10;
  if( c>='A' && c<='F' ) return c - 'A' + 10;
  return -1;
}

/*
** Interpret zArg as an integer value, possibly with suffixes.
*/
static sqlite3_int64 integerValue(const char *zArg){
  sqlite3_int64 v = 0;
  static const struct { char *zSuffix; int iMult; } aMult[] = {
    { "KiB", 1024 },
    { "MiB", 1024*1024 },
    { "GiB", 1024*1024*1024 },
    { "KB",  1000 },
    { "MB",  1000000 },
    { "GB",  1000000000 },
    { "K",   1000 },
    { "M",   1000000 },
    { "G",   1000000000 },
  };
  int i;
  int isNeg = 0;
  if( zArg[0]=='-' ){
    isNeg = 1;
    zArg++;
  }else if( zArg[0]=='+' ){
    zArg++;
  }
  if( zArg[0]=='0' && zArg[1]=='x' ){
    int x;
    zArg += 2;
    while( (x = hexDigitValue(zArg[0]))>=0 ){
      v = (v<<4) + x;
      zArg++;
    }
  }else{
    while( IsDigit(zArg[0]) ){
      v = v*10 + zArg[0] - '0';
      zArg++;
    }
  }
  for(i=0; i<ArraySize(aMult); i++){
    if( sqlite3_stricmp(aMult[i].zSuffix, zArg)==0 ){
      v *= aMult[i].iMult;
      break;
    }
  }
  return isNeg? -v : v;
}

/*
** Interpret zArg as either an integer or a boolean value.  Return 1 or 0
** for TRUE and FALSE.  Return the integer value if appropriate.
*/
static int booleanValue(char *zArg){
  int i;
  if( zArg[0]=='0' && zArg[1]=='x' ){
    for(i=2; hexDigitValue(zArg[i])>=0; i++){}
  }else{
    for(i=0; zArg[i]>='0' && zArg[i]<='9'; i++){}
  }
  if( i>0 && zArg[i]==0 ) return (int)(integerValue(zArg) & 0xffffffff);
  if( sqlite3_stricmp(zArg, "on")==0 || sqlite3_stricmp(zArg,"yes")==0 ){
    return 1;
  }
  if( sqlite3_stricmp(zArg, "off")==0 || sqlite3_stricmp(zArg,"no")==0 ){
    return 0;
  }
  utf8_printf(stderr, "ERROR: Not a boolean value: \"%s\". Assuming \"no\".\n",
          zArg);
  return 0;
}

/*
** Close an output file, assuming it is not stderr or stdout
*/
static void output_file_close(FILE *f){
  if( f && f!=stdout && f!=stderr ) fclose(f);
}

/*
** Try to open an output file.   The names "stdout" and "stderr" are
** recognized and do the right thing.  NULL is returned if the output 
** filename is "off".
*/
static FILE *output_file_open(const char *zFile){
  FILE *f;
  if( strcmp(zFile,"stdout")==0 ){
    f = stdout;
  }else if( strcmp(zFile, "stderr")==0 ){
    f = stderr;
  }else if( strcmp(zFile, "off")==0 ){
    f = 0;
  }else{
    f = fopen(zFile, "wb");
    if( f==0 ){
      utf8_printf(stderr, "Error: cannot open \"%s\"\n", zFile);
    }
  }
  return f;
}

/*
** A routine for handling output from sqlite3_trace().
*/
static void sql_trace_callback(void *pArg, const char *z){
  FILE *f = (FILE*)pArg;
  if( f ){
    int i = (int)strlen(z);
    while( i>0 && z[i-1]==';' ){ i--; }
    utf8_printf(f, "%.*s;\n", i, z);
  }
}

/*
** A no-op routine that runs with the ".breakpoint" doc-command.  This is
** a useful spot to set a debugger breakpoint.
*/
static void test_breakpoint(void){
  static int nCall = 0;
  nCall++;
}

/*
** An object used to read a CSV and other files for import.
*/
typedef struct ImportCtx ImportCtx;
struct ImportCtx {
  const char *zFile;  /* Name of the input file */
  FILE *in;           /* Read the CSV text from this input stream */
  char *z;            /* Accumulated text for a field */
  int n;              /* Number of bytes in z */
  int nAlloc;         /* Space allocated for z[] */
  int nLine;          /* Current line number */
  int cTerm;          /* Character that terminated the most recent field */
  int cColSep;        /* The column separator character.  (Usually ",") */
  int cRowSep;        /* The row separator character.  (Usually "\n") */
};

/* Append a single byte to z[] */
static void import_append_char(ImportCtx *p, int c){
  if( p->n+1>=p->nAlloc ){
    p->nAlloc += p->nAlloc + 100;
    p->z = sqlite3_realloc64(p->z, p->nAlloc);
    if( p->z==0 ){
      raw_printf(stderr, "out of memory\n");
      exit(1);
    }
  }
  p->z[p->n++] = (char)c;
}

/* Read a single field of CSV text.  Compatible with rfc4180 and extended
** with the option of having a separator other than ",".
**
**   +  Input comes from p->in.
**   +  Store results in p->z of length p->n.  Space to hold p->z comes
**      from sqlite3_malloc64().
**   +  Use p->cSep as the column separator.  The default is ",".
**   +  Use p->rSep as the row separator.  The default is "\n".
**   +  Keep track of the line number in p->nLine.
**   +  Store the character that terminates the field in p->cTerm.  Store
**      EOF on end-of-file.
**   +  Report syntax errors on stderr
*/
static char *SQLITE_CDECL csv_read_one_field(ImportCtx *p){
  int c;
  int cSep = p->cColSep;
  int rSep = p->cRowSep;
  p->n = 0;
  c = fgetc(p->in);
  if( c==EOF || seenInterrupt ){
    p->cTerm = EOF;
    return 0;
  }
  if( c=='"' ){
    int pc, ppc;
    int startLine = p->nLine;
    int cQuote = c;
    pc = ppc = 0;
    while( 1 ){
      c = fgetc(p->in);
      if( c==rSep ) p->nLine++;
      if( c==cQuote ){
        if( pc==cQuote ){
          pc = 0;
          continue;
        }
      }
      if( (c==cSep && pc==cQuote)
       || (c==rSep && pc==cQuote)
       || (c==rSep && pc=='\r' && ppc==cQuote)
       || (c==EOF && pc==cQuote)
      ){
        do{ p->n--; }while( p->z[p->n]!=cQuote );
        p->cTerm = c;
        break;
      }
      if( pc==cQuote && c!='\r' ){
        utf8_printf(stderr, "%s:%d: unescaped %c character\n",
                p->zFile, p->nLine, cQuote);
      }
      if( c==EOF ){
        utf8_printf(stderr, "%s:%d: unterminated %c-quoted field\n",
                p->zFile, startLine, cQuote);
        p->cTerm = c;
        break;
      }
      import_append_char(p, c);
      ppc = pc;
      pc = c;
    }
  }else{
    while( c!=EOF && c!=cSep && c!=rSep ){
      import_append_char(p, c);
      c = fgetc(p->in);
    }
    if( c==rSep ){
      p->nLine++;
      if( p->n>0 && p->z[p->n-1]=='\r' ) p->n--;
    }
    p->cTerm = c;
  }
  if( p->z ) p->z[p->n] = 0;
  return p->z;
}

/* Read a single field of ASCII delimited text.
**
**   +  Input comes from p->in.
**   +  Store results in p->z of length p->n.  Space to hold p->z comes
**      from sqlite3_malloc64().
**   +  Use p->cSep as the column separator.  The default is "\x1F".
**   +  Use p->rSep as the row separator.  The default is "\x1E".
**   +  Keep track of the row number in p->nLine.
**   +  Store the character that terminates the field in p->cTerm.  Store
**      EOF on end-of-file.
**   +  Report syntax errors on stderr
*/
static char *SQLITE_CDECL ascii_read_one_field(ImportCtx *p){
  int c;
  int cSep = p->cColSep;
  int rSep = p->cRowSep;
  p->n = 0;
  c = fgetc(p->in);
  if( c==EOF || seenInterrupt ){
    p->cTerm = EOF;
    return 0;
  }
  while( c!=EOF && c!=cSep && c!=rSep ){
    import_append_char(p, c);
    c = fgetc(p->in);
  }
  if( c==rSep ){
    p->nLine++;
  }
  p->cTerm = c;
  if( p->z ) p->z[p->n] = 0;
  return p->z;
}

/*
** Try to transfer data for table zTable.  If an error is seen while
** moving forward, try to go backwards.  The backwards movement won't
** work for WITHOUT ROWID tables.
*/
static void tryToCloneData(
  ShellState *p,
  sqlite3 *newDb,
  const char *zTable
){
  sqlite3_stmt *pQuery = 0; 
  sqlite3_stmt *pInsert = 0;
  char *zQuery = 0;
  char *zInsert = 0;
  int rc;
  int i, j, n;
  int nTable = (int)strlen(zTable);
  int k = 0;
  int cnt = 0;
  const int spinRate = 10000;

  zQuery = sqlite3_mprintf("SELECT * FROM \"%w\"", zTable);
  rc = sqlite3_prepare_v2(p->db, zQuery, -1, &pQuery, 0);
  if( rc ){
    utf8_printf(stderr, "Error %d: %s on [%s]\n",
            sqlite3_extended_errcode(p->db), sqlite3_errmsg(p->db),
            zQuery);
    goto end_data_xfer;
  }
  n = sqlite3_column_count(pQuery);
  zInsert = sqlite3_malloc64(200 + nTable + n*3);
  if( zInsert==0 ){
    raw_printf(stderr, "out of memory\n");
    goto end_data_xfer;
  }
  sqlite3_snprintf(200+nTable,zInsert,
                   "INSERT OR IGNORE INTO \"%s\" VALUES(?", zTable);
  i = (int)strlen(zInsert);
  for(j=1; j<n; j++){
    memcpy(zInsert+i, ",?", 2);
    i += 2;
  }
  memcpy(zInsert+i, ");", 3);
  rc = sqlite3_prepare_v2(newDb, zInsert, -1, &pInsert, 0);
  if( rc ){
    utf8_printf(stderr, "Error %d: %s on [%s]\n",
            sqlite3_extended_errcode(newDb), sqlite3_errmsg(newDb),
            zQuery);
    goto end_data_xfer;
  }
  for(k=0; k<2; k++){
    while( (rc = sqlite3_step(pQuery))==SQLITE_ROW ){
      for(i=0; i<n; i++){
        switch( sqlite3_column_type(pQuery, i) ){
          case SQLITE_NULL: {
            sqlite3_bind_null(pInsert, i+1);
            break;
          }
          case SQLITE_INTEGER: {
            sqlite3_bind_int64(pInsert, i+1, sqlite3_column_int64(pQuery,i));
            break;
          }
          case SQLITE_FLOAT: {
            sqlite3_bind_double(pInsert, i+1, sqlite3_column_double(pQuery,i));
            break;
          }
          case SQLITE_TEXT: {
            sqlite3_bind_text(pInsert, i+1,
                             (const char*)sqlite3_column_text(pQuery,i),
                             -1, SQLITE_STATIC);
            break;
          }
          case SQLITE_BLOB: {
            sqlite3_bind_blob(pInsert, i+1, sqlite3_column_blob(pQuery,i),
                                            sqlite3_column_bytes(pQuery,i),
                                            SQLITE_STATIC);
            break;
          }
        }
      } /* End for */
      rc = sqlite3_step(pInsert);
      if( rc!=SQLITE_OK && rc!=SQLITE_ROW && rc!=SQLITE_DONE ){
        utf8_printf(stderr, "Error %d: %s\n", sqlite3_extended_errcode(newDb),
                        sqlite3_errmsg(newDb));
      }
      sqlite3_reset(pInsert);
      cnt++;
      if( (cnt%spinRate)==0 ){
        printf("%c\b", "|/-\\"[(cnt/spinRate)%4]);
        fflush(stdout);
      }
    } /* End while */
    if( rc==SQLITE_DONE ) break;
    sqlite3_finalize(pQuery);
    sqlite3_free(zQuery);
    zQuery = sqlite3_mprintf("SELECT * FROM \"%w\" ORDER BY rowid DESC;",
                             zTable);
    rc = sqlite3_prepare_v2(p->db, zQuery, -1, &pQuery, 0);
    if( rc ){
      utf8_printf(stderr, "Warning: cannot step \"%s\" backwards", zTable);
      break;
    }
  } /* End for(k=0...) */

end_data_xfer:
  sqlite3_finalize(pQuery);
  sqlite3_finalize(pInsert);
  sqlite3_free(zQuery);
  sqlite3_free(zInsert);
}


/*
** Try to transfer all rows of the schema that match zWhere.  For
** each row, invoke xForEach() on the object defined by that row.
** If an error is encountered while moving forward through the
** sqlite_master table, try again moving backwards.
*/
static void tryToCloneSchema(
  ShellState *p,
  sqlite3 *newDb,
  const char *zWhere,
  void (*xForEach)(ShellState*,sqlite3*,const char*)
){
  sqlite3_stmt *pQuery = 0;
  char *zQuery = 0;
  int rc;
  const unsigned char *zName;
  const unsigned char *zSql;
  char *zErrMsg = 0;

  zQuery = sqlite3_mprintf("SELECT name, sql FROM sqlite_master"
                           " WHERE %s", zWhere);
  rc = sqlite3_prepare_v2(p->db, zQuery, -1, &pQuery, 0);
  if( rc ){
    utf8_printf(stderr, "Error: (%d) %s on [%s]\n",
                    sqlite3_extended_errcode(p->db), sqlite3_errmsg(p->db),
                    zQuery);
    goto end_schema_xfer;
  }
  while( (rc = sqlite3_step(pQuery))==SQLITE_ROW ){
    zName = sqlite3_column_text(pQuery, 0);
    zSql = sqlite3_column_text(pQuery, 1);
    printf("%s... ", zName); fflush(stdout);
    sqlite3_exec(newDb, (const char*)zSql, 0, 0, &zErrMsg);
    if( zErrMsg ){
      utf8_printf(stderr, "Error: %s\nSQL: [%s]\n", zErrMsg, zSql);
      sqlite3_free(zErrMsg);
      zErrMsg = 0;
    }
    if( xForEach ){
      xForEach(p, newDb, (const char*)zName);
    }
    printf("done\n");
  }
  if( rc!=SQLITE_DONE ){
    sqlite3_finalize(pQuery);
    sqlite3_free(zQuery);
    zQuery = sqlite3_mprintf("SELECT name, sql FROM sqlite_master"
                             " WHERE %s ORDER BY rowid DESC", zWhere);
    rc = sqlite3_prepare_v2(p->db, zQuery, -1, &pQuery, 0);
    if( rc ){
      utf8_printf(stderr, "Error: (%d) %s on [%s]\n",
                      sqlite3_extended_errcode(p->db), sqlite3_errmsg(p->db),
                      zQuery);
      goto end_schema_xfer;
    }
    while( (rc = sqlite3_step(pQuery))==SQLITE_ROW ){
      zName = sqlite3_column_text(pQuery, 0);
      zSql = sqlite3_column_text(pQuery, 1);
      printf("%s... ", zName); fflush(stdout);
      sqlite3_exec(newDb, (const char*)zSql, 0, 0, &zErrMsg);
      if( zErrMsg ){
        utf8_printf(stderr, "Error: %s\nSQL: [%s]\n", zErrMsg, zSql);
        sqlite3_free(zErrMsg);
        zErrMsg = 0;
      }
      if( xForEach ){
        xForEach(p, newDb, (const char*)zName);
      }
      printf("done\n");
    }
  }
end_schema_xfer:
  sqlite3_finalize(pQuery);
  sqlite3_free(zQuery);
}

/*
** Open a new database file named "zNewDb".  Try to recover as much information
** as possible out of the main database (which might be corrupt) and write it
** into zNewDb.
*/
static void tryToClone(ShellState *p, const char *zNewDb){
  int rc;
  sqlite3 *newDb = 0;
  if( access(zNewDb,0)==0 ){
    utf8_printf(stderr, "File \"%s\" already exists.\n", zNewDb);
    return;
  }
  rc = sqlite3_open(zNewDb, &newDb);
  if( rc ){
    utf8_printf(stderr, "Cannot create output database: %s\n",
            sqlite3_errmsg(newDb));
  }else{
    sqlite3_exec(p->db, "PRAGMA writable_schema=ON;", 0, 0, 0);
    sqlite3_exec(newDb, "BEGIN EXCLUSIVE;", 0, 0, 0);
    tryToCloneSchema(p, newDb, "type='table'", tryToCloneData);
    tryToCloneSchema(p, newDb, "type!='table'", 0);
    sqlite3_exec(newDb, "COMMIT;", 0, 0, 0);
    sqlite3_exec(p->db, "PRAGMA writable_schema=OFF;", 0, 0, 0);
  }
  sqlite3_close(newDb);
}

/*
** Change the output file back to stdout
*/
static void output_reset(ShellState *p){
  if( p->outfile[0]=='|' ){
#ifndef SQLITE_OMIT_POPEN
    pclose(p->out);
#endif
  }else{
    output_file_close(p->out);
  }
  p->outfile[0] = 0;
  p->out = stdout;
}

/*
** Run an SQL command and return the single integer result.
*/
static int db_int(ShellState *p, const char *zSql){
  sqlite3_stmt *pStmt;
  int res = 0;
  sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
  if( pStmt && sqlite3_step(pStmt)==SQLITE_ROW ){
    res = sqlite3_column_int(pStmt,0);
  }
  sqlite3_finalize(pStmt);
  return res;
}

/*
** Convert a 2-byte or 4-byte big-endian integer into a native integer
*/
unsigned int get2byteInt(unsigned char *a){
  return (a[0]<<8) + a[1];
}
unsigned int get4byteInt(unsigned char *a){
  return (a[0]<<24) + (a[1]<<16) + (a[2]<<8) + a[3];
}

/*
** Implementation of the ".info" command.
**
** Return 1 on error, 2 to exit, and 0 otherwise.
*/
static int shell_dbinfo_command(ShellState *p, int nArg, char **azArg){
  static const struct { const char *zName; int ofst; } aField[] = {
     { "file change counter:",  24  },
     { "database page count:",  28  },
     { "freelist page count:",  36  },
     { "schema cookie:",        40  },
     { "schema format:",        44  },
     { "default cache size:",   48  },
     { "autovacuum top root:",  52  },
     { "incremental vacuum:",   64  },
     { "text encoding:",        56  },
     { "user version:",         60  },
     { "application id:",       68  },
     { "software version:",     96  },
  };
  static const struct { const char *zName; const char *zSql; } aQuery[] = {
     { "number of tables:",
       "SELECT count(*) FROM %s WHERE type='table'" },
     { "number of indexes:",
       "SELECT count(*) FROM %s WHERE type='index'" },
     { "number of triggers:",
       "SELECT count(*) FROM %s WHERE type='trigger'" },
     { "number of views:",
       "SELECT count(*) FROM %s WHERE type='view'" },
     { "schema size:",
       "SELECT total(length(sql)) FROM %s" },
  };
  sqlite3_file *pFile = 0;
  int i;
  char *zSchemaTab;
  char *zDb = nArg>=2 ? azArg[1] : "main";
  unsigned char aHdr[100];
  open_db(p, 0);
  if( p->db==0 ) return 1;
  sqlite3_file_control(p->db, zDb, SQLITE_FCNTL_FILE_POINTER, &pFile);
  if( pFile==0 || pFile->pMethods==0 || pFile->pMethods->xRead==0 ){
    return 1;
  }
  i = pFile->pMethods->xRead(pFile, aHdr, 100, 0);
  if( i!=SQLITE_OK ){
    raw_printf(stderr, "unable to read database header\n");
    return 1;
  }
  i = get2byteInt(aHdr+16);
  if( i==1 ) i = 65536;
  utf8_printf(p->out, "%-20s %d\n", "database page size:", i);
  utf8_printf(p->out, "%-20s %d\n", "write format:", aHdr[18]);
  utf8_printf(p->out, "%-20s %d\n", "read format:", aHdr[19]);
  utf8_printf(p->out, "%-20s %d\n", "reserved bytes:", aHdr[20]);
  for(i=0; i<ArraySize(aField); i++){
    int ofst = aField[i].ofst;
    unsigned int val = get4byteInt(aHdr + ofst);
    utf8_printf(p->out, "%-20s %u", aField[i].zName, val);
    switch( ofst ){
      case 56: {
        if( val==1 ) raw_printf(p->out, " (utf8)"); 
        if( val==2 ) raw_printf(p->out, " (utf16le)"); 
        if( val==3 ) raw_printf(p->out, " (utf16be)"); 
      }
    }
    raw_printf(p->out, "\n");
  }
  if( zDb==0 ){
    zSchemaTab = sqlite3_mprintf("main.sqlite_master");
  }else if( strcmp(zDb,"temp")==0 ){
    zSchemaTab = sqlite3_mprintf("%s", "sqlite_temp_master");
  }else{
    zSchemaTab = sqlite3_mprintf("\"%w\".sqlite_master", zDb);
  }
  for(i=0; i<ArraySize(aQuery); i++){
    char *zSql = sqlite3_mprintf(aQuery[i].zSql, zSchemaTab);
    int val = db_int(p, zSql);
    sqlite3_free(zSql);
    utf8_printf(p->out, "%-20s %d\n", aQuery[i].zName, val);
  }
  sqlite3_free(zSchemaTab);
  return 0;
}

/*
** Print the current sqlite3_errmsg() value to stderr and return 1.
*/
static int shellDatabaseError(sqlite3 *db){
  const char *zErr = sqlite3_errmsg(db);
  utf8_printf(stderr, "Error: %s\n", zErr);
  return 1;
}

/*
** Print an out-of-memory message to stderr and return 1.
*/
static int shellNomemError(void){
  raw_printf(stderr, "Error: out of memory\n");
  return 1;
}

/*
** If an input line begins with "." then invoke this routine to
** process that line.
**
** Return 1 on error, 2 to exit, and 0 otherwise.
*/
static int do_meta_command(char *zLine, ShellState *p){
  int h = 1;
  int nArg = 0;
  int n, c;
  int rc = 0;
  char *azArg[50];

  /* Parse the input line into tokens.
  */
  while( zLine[h] && nArg<ArraySize(azArg) ){
    while( IsSpace(zLine[h]) ){ h++; }
    if( zLine[h]==0 ) break;
    if( zLine[h]=='\'' || zLine[h]=='"' ){
      int delim = zLine[h++];
      azArg[nArg++] = &zLine[h];
      while( zLine[h] && zLine[h]!=delim ){ 
        if( zLine[h]=='\\' && delim=='"' && zLine[h+1]!=0 ) h++;
        h++; 
      }
      if( zLine[h]==delim ){
        zLine[h++] = 0;
      }
      if( delim=='"' ) resolve_backslashes(azArg[nArg-1]);
    }else{
      azArg[nArg++] = &zLine[h];
      while( zLine[h] && !IsSpace(zLine[h]) ){ h++; }
      if( zLine[h] ) zLine[h++] = 0;
      resolve_backslashes(azArg[nArg-1]);
    }
  }

  /* Process the input line.
  */
  if( nArg==0 ) return 0; /* no tokens, no error */
  n = strlen30(azArg[0]);
  c = azArg[0][0];
  if( (c=='b' && n>=3 && strncmp(azArg[0], "backup", n)==0)
   || (c=='s' && n>=3 && strncmp(azArg[0], "save", n)==0)
  ){
    const char *zDestFile = 0;
    const char *zDb = 0;
    sqlite3 *pDest;
    sqlite3_backup *pBackup;
    int j;
    for(j=1; j<nArg; j++){
      const char *z = azArg[j];
      if( z[0]=='-' ){
        while( z[0]=='-' ) z++;
        /* No options to process at this time */
        {
          utf8_printf(stderr, "unknown option: %s\n", azArg[j]);
          return 1;
        }
      }else if( zDestFile==0 ){
        zDestFile = azArg[j];
      }else if( zDb==0 ){
        zDb = zDestFile;
        zDestFile = azArg[j];
      }else{
        raw_printf(stderr, "too many arguments to .backup\n");
        return 1;
      }
    }
    if( zDestFile==0 ){
      raw_printf(stderr, "missing FILENAME argument on .backup\n");
      return 1;
    }
    if( zDb==0 ) zDb = "main";
    rc = sqlite3_open(zDestFile, &pDest);
    if( rc!=SQLITE_OK ){
      utf8_printf(stderr, "Error: cannot open \"%s\"\n", zDestFile);
      sqlite3_close(pDest);
      return 1;
    }
    open_db(p, 0);
    pBackup = sqlite3_backup_init(pDest, "main", p->db, zDb);
    if( pBackup==0 ){
      utf8_printf(stderr, "Error: %s\n", sqlite3_errmsg(pDest));
      sqlite3_close(pDest);
      return 1;
    }
    while(  (rc = sqlite3_backup_step(pBackup,100))==SQLITE_OK ){}
    sqlite3_backup_finish(pBackup);
    if( rc==SQLITE_DONE ){
      rc = 0;
    }else{
      utf8_printf(stderr, "Error: %s\n", sqlite3_errmsg(pDest));
      rc = 1;
    }
    sqlite3_close(pDest);
  }else

  if( c=='b' && n>=3 && strncmp(azArg[0], "bail", n)==0 ){
    if( nArg==2 ){
      bail_on_error = booleanValue(azArg[1]);
    }else{
      raw_printf(stderr, "Usage: .bail on|off\n");
      rc = 1;
    }
  }else

  if( c=='b' && n>=3 && strncmp(azArg[0], "binary", n)==0 ){
    if( nArg==2 ){
      if( booleanValue(azArg[1]) ){
        setBinaryMode(p->out);
      }else{
        setTextMode(p->out);
      }
    }else{
      raw_printf(stderr, "Usage: .binary on|off\n");
      rc = 1;
    }
  }else

  /* The undocumented ".breakpoint" command causes a call to the no-op
  ** routine named test_breakpoint().
  */
  if( c=='b' && n>=3 && strncmp(azArg[0], "breakpoint", n)==0 ){
    test_breakpoint();
  }else

  if( c=='c' && n>=3 && strncmp(azArg[0], "changes", n)==0 ){
    if( nArg==2 ){
      p->countChanges = booleanValue(azArg[1]);
    }else{
      raw_printf(stderr, "Usage: .changes on|off\n");
      rc = 1;
    }
  }else

  if( c=='c' && strncmp(azArg[0], "clone", n)==0 ){
    if( nArg==2 ){
      tryToClone(p, azArg[1]);
    }else{
      raw_printf(stderr, "Usage: .clone FILENAME\n");
      rc = 1;
    }
  }else

  if( c=='d' && n>1 && strncmp(azArg[0], "databases", n)==0 ){
    ShellState data;
    char *zErrMsg = 0;
    open_db(p, 0);
    memcpy(&data, p, sizeof(data));
    data.showHeader = 1;
    data.cMode = data.mode = MODE_Column;
    data.colWidth[0] = 3;
    data.colWidth[1] = 15;
    data.colWidth[2] = 58;
    data.cnt = 0;
    sqlite3_exec(p->db, "PRAGMA database_list; ", callback, &data, &zErrMsg);
    if( zErrMsg ){
      utf8_printf(stderr,"Error: %s\n", zErrMsg);
      sqlite3_free(zErrMsg);
      rc = 1;
    }
  }else

  if( c=='d' && strncmp(azArg[0], "dbinfo", n)==0 ){
    rc = shell_dbinfo_command(p, nArg, azArg);
  }else

  if( c=='d' && strncmp(azArg[0], "dump", n)==0 ){
    open_db(p, 0);
    /* When playing back a "dump", the content might appear in an order
    ** which causes immediate foreign key constraints to be violated.
    ** So disable foreign-key constraint enforcement to prevent problems. */
    if( nArg!=1 && nArg!=2 ){
      raw_printf(stderr, "Usage: .dump ?LIKE-PATTERN?\n");
      rc = 1;
      goto meta_command_exit;
    }
    raw_printf(p->out, "PRAGMA foreign_keys=OFF;\n");
    raw_printf(p->out, "BEGIN TRANSACTION;\n");
    p->writableSchema = 0;
    sqlite3_exec(p->db, "SAVEPOINT dump; PRAGMA writable_schema=ON", 0, 0, 0);
    p->nErr = 0;
    if( nArg==1 ){
      run_schema_dump_query(p, 
        "SELECT name, type, sql FROM sqlite_master "
        "WHERE sql NOT NULL AND type=='table' AND name!='sqlite_sequence'"
      );
      run_schema_dump_query(p, 
        "SELECT name, type, sql FROM sqlite_master "
        "WHERE name=='sqlite_sequence'"
      );
      run_table_dump_query(p,
        "SELECT sql FROM sqlite_master "
        "WHERE sql NOT NULL AND type IN ('index','trigger','view')", 0
      );
    }else{
      int i;
      for(i=1; i<nArg; i++){
        zShellStatic = azArg[i];
        run_schema_dump_query(p,
          "SELECT name, type, sql FROM sqlite_master "
          "WHERE tbl_name LIKE shellstatic() AND type=='table'"
          "  AND sql NOT NULL");
        run_table_dump_query(p,
          "SELECT sql FROM sqlite_master "
          "WHERE sql NOT NULL"
          "  AND type IN ('index','trigger','view')"
          "  AND tbl_name LIKE shellstatic()", 0
        );
        zShellStatic = 0;
      }
    }
    if( p->writableSchema ){
      raw_printf(p->out, "PRAGMA writable_schema=OFF;\n");
      p->writableSchema = 0;
    }
    sqlite3_exec(p->db, "PRAGMA writable_schema=OFF;", 0, 0, 0);
    sqlite3_exec(p->db, "RELEASE dump;", 0, 0, 0);
    raw_printf(p->out, p->nErr ? "ROLLBACK; -- due to errors\n" : "COMMIT;\n");
  }else

  if( c=='e' && strncmp(azArg[0], "echo", n)==0 ){
    if( nArg==2 ){
      p->echoOn = booleanValue(azArg[1]);
    }else{
      raw_printf(stderr, "Usage: .echo on|off\n");
      rc = 1;
    }
  }else

  if( c=='e' && strncmp(azArg[0], "eqp", n)==0 ){
    if( nArg==2 ){
      p->autoEQP = booleanValue(azArg[1]);
    }else{
      raw_printf(stderr, "Usage: .eqp on|off\n");
      rc = 1;
    }   
  }else

  if( c=='e' && strncmp(azArg[0], "exit", n)==0 ){
    if( nArg>1 && (rc = (int)integerValue(azArg[1]))!=0 ) exit(rc);
    rc = 2;
  }else

  if( c=='e' && strncmp(azArg[0], "explain", n)==0 ){
    int val = 1;
    if( nArg>=2 ){
      if( strcmp(azArg[1],"auto")==0 ){
        val = 99;
      }else{
        val =  booleanValue(azArg[1]);
      }
    }
    if( val==1 && p->mode!=MODE_Explain ){
      p->normalMode = p->mode;
      p->mode = MODE_Explain;
      p->autoExplain = 0;
    }else if( val==0 ){
      if( p->mode==MODE_Explain ) p->mode = p->normalMode;
      p->autoExplain = 0;
    }else if( val==99 ){
      if( p->mode==MODE_Explain ) p->mode = p->normalMode;
      p->autoExplain = 1;
    }
  }else

  if( c=='f' && strncmp(azArg[0], "fullschema", n)==0 ){
    ShellState data;
    char *zErrMsg = 0;
    int doStats = 0;
    if( nArg!=1 ){
      raw_printf(stderr, "Usage: .fullschema\n");
      rc = 1;
      goto meta_command_exit;
    }
    open_db(p, 0);
    memcpy(&data, p, sizeof(data));
    data.showHeader = 0;
    data.cMode = data.mode = MODE_Semi;
    rc = sqlite3_exec(p->db,
       "SELECT sql FROM"
       "  (SELECT sql sql, type type, tbl_name tbl_name, name name, rowid x"
       "     FROM sqlite_master UNION ALL"
       "   SELECT sql, type, tbl_name, name, rowid FROM sqlite_temp_master) "
       "WHERE type!='meta' AND sql NOTNULL AND name NOT LIKE 'sqlite_%' "
       "ORDER BY rowid",
       callback, &data, &zErrMsg
    );
    if( rc==SQLITE_OK ){
      sqlite3_stmt *pStmt;
      rc = sqlite3_prepare_v2(p->db,
               "SELECT rowid FROM sqlite_master"
               " WHERE name GLOB 'sqlite_stat[134]'",
               -1, &pStmt, 0);
      doStats = sqlite3_step(pStmt)==SQLITE_ROW;
      sqlite3_finalize(pStmt);
    }
    if( doStats==0 ){
      raw_printf(p->out, "/* No STAT tables available */\n");
    }else{
      raw_printf(p->out, "ANALYZE sqlite_master;\n");
      sqlite3_exec(p->db, "SELECT 'ANALYZE sqlite_master'",
                   callback, &data, &zErrMsg);
      data.cMode = data.mode = MODE_Insert;
      data.zDestTable = "sqlite_stat1";
      shell_exec(p->db, "SELECT * FROM sqlite_stat1",
                 shell_callback, &data,&zErrMsg);
      data.zDestTable = "sqlite_stat3";
      shell_exec(p->db, "SELECT * FROM sqlite_stat3",
                 shell_callback, &data,&zErrMsg);
      data.zDestTable = "sqlite_stat4";
      shell_exec(p->db, "SELECT * FROM sqlite_stat4",
                 shell_callback, &data, &zErrMsg);
      raw_printf(p->out, "ANALYZE sqlite_master;\n");
    }
  }else

  if( c=='h' && strncmp(azArg[0], "headers", n)==0 ){
    if( nArg==2 ){
      p->showHeader = booleanValue(azArg[1]);
    }else{
      raw_printf(stderr, "Usage: .headers on|off\n");
      rc = 1;
    }
  }else

  if( c=='h' && strncmp(azArg[0], "help", n)==0 ){
    utf8_printf(p->out, "%s", zHelp);
  }else

  if( c=='i' && strncmp(azArg[0], "import", n)==0 ){
    char *zTable;               /* Insert data into this table */
    char *zFile;                /* Name of file to extra content from */
    sqlite3_stmt *pStmt = NULL; /* A statement */
    int nCol;                   /* Number of columns in the table */
    int nByte;                  /* Number of bytes in an SQL string */
    int i, j;                   /* Loop counters */
    int needCommit;             /* True to COMMIT or ROLLBACK at end */
    int nSep;                   /* Number of bytes in p->colSeparator[] */
    char *zSql;                 /* An SQL statement */
    ImportCtx sCtx;             /* Reader context */
    char *(SQLITE_CDECL *xRead)(ImportCtx*); /* Func to read one value */
    int (SQLITE_CDECL *xCloser)(FILE*);      /* Func to close file */

    if( nArg!=3 ){
      raw_printf(stderr, "Usage: .import FILE TABLE\n");
      goto meta_command_exit;
    }
    zFile = azArg[1];
    zTable = azArg[2];
    seenInterrupt = 0;
    memset(&sCtx, 0, sizeof(sCtx));
    open_db(p, 0);
    nSep = strlen30(p->colSeparator);
    if( nSep==0 ){
      raw_printf(stderr,
                 "Error: non-null column separator required for import\n");
      return 1;
    }
    if( nSep>1 ){
      raw_printf(stderr, "Error: multi-character column separators not allowed"
                      " for import\n");
      return 1;
    }
    nSep = strlen30(p->rowSeparator);
    if( nSep==0 ){
      raw_printf(stderr, "Error: non-null row separator required for import\n");
      return 1;
    }
    if( nSep==2 && p->mode==MODE_Csv && strcmp(p->rowSeparator, SEP_CrLf)==0 ){
      /* When importing CSV (only), if the row separator is set to the
      ** default output row separator, change it to the default input
      ** row separator.  This avoids having to maintain different input
      ** and output row separators. */
      sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_Row);
      nSep = strlen30(p->rowSeparator);
    }
    if( nSep>1 ){
      raw_printf(stderr, "Error: multi-character row separators not allowed"
                      " for import\n");
      return 1;
    }
    sCtx.zFile = zFile;
    sCtx.nLine = 1;
    if( sCtx.zFile[0]=='|' ){
#ifdef SQLITE_OMIT_POPEN
      raw_printf(stderr, "Error: pipes are not supported in this OS\n");
      return 1;
#else
      sCtx.in = popen(sCtx.zFile+1, "r");
      sCtx.zFile = "<pipe>";
      xCloser = pclose;
#endif
    }else{
      sCtx.in = fopen(sCtx.zFile, "rb");
      xCloser = fclose;
    }
    if( p->mode==MODE_Ascii ){
      xRead = ascii_read_one_field;
    }else{
      xRead = csv_read_one_field;
    }
    if( sCtx.in==0 ){
      utf8_printf(stderr, "Error: cannot open \"%s\"\n", zFile);
      return 1;
    }
    sCtx.cColSep = p->colSeparator[0];
    sCtx.cRowSep = p->rowSeparator[0];
    zSql = sqlite3_mprintf("SELECT * FROM %s", zTable);
    if( zSql==0 ){
      raw_printf(stderr, "Error: out of memory\n");
      xCloser(sCtx.in);
      return 1;
    }
    nByte = strlen30(zSql);
    rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
    import_append_char(&sCtx, 0);    /* To ensure sCtx.z is allocated */
    if( rc && sqlite3_strglob("no such table: *", sqlite3_errmsg(p->db))==0 ){
      char *zCreate = sqlite3_mprintf("CREATE TABLE %s", zTable);
      char cSep = '(';
      while( xRead(&sCtx) ){
        zCreate = sqlite3_mprintf("%z%c\n  \"%w\" TEXT", zCreate, cSep, sCtx.z);
        cSep = ',';
        if( sCtx.cTerm!=sCtx.cColSep ) break;
      }
      if( cSep=='(' ){
        sqlite3_free(zCreate);
        sqlite3_free(sCtx.z);
        xCloser(sCtx.in);
        utf8_printf(stderr,"%s: empty file\n", sCtx.zFile);
        return 1;
      }
      zCreate = sqlite3_mprintf("%z\n)", zCreate);
      rc = sqlite3_exec(p->db, zCreate, 0, 0, 0);
      sqlite3_free(zCreate);
      if( rc ){
        utf8_printf(stderr, "CREATE TABLE %s(...) failed: %s\n", zTable,
                sqlite3_errmsg(p->db));
        sqlite3_free(sCtx.z);
        xCloser(sCtx.in);
        return 1;
      }
      rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
    }
    sqlite3_free(zSql);
    if( rc ){
      if (pStmt) sqlite3_finalize(pStmt);
      utf8_printf(stderr,"Error: %s\n", sqlite3_errmsg(p->db));
      xCloser(sCtx.in);
      return 1;
    }
    nCol = sqlite3_column_count(pStmt);
    sqlite3_finalize(pStmt);
    pStmt = 0;
    if( nCol==0 ) return 0; /* no columns, no error */
    zSql = sqlite3_malloc64( nByte*2 + 20 + nCol*2 );
    if( zSql==0 ){
      raw_printf(stderr, "Error: out of memory\n");
      xCloser(sCtx.in);
      return 1;
    }
    sqlite3_snprintf(nByte+20, zSql, "INSERT INTO \"%w\" VALUES(?", zTable);
    j = strlen30(zSql);
    for(i=1; i<nCol; i++){
      zSql[j++] = ',';
      zSql[j++] = '?';
    }
    zSql[j++] = ')';
    zSql[j] = 0;
    rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
    sqlite3_free(zSql);
    if( rc ){
      utf8_printf(stderr, "Error: %s\n", sqlite3_errmsg(p->db));
      if (pStmt) sqlite3_finalize(pStmt);
      xCloser(sCtx.in);
      return 1;
    }
    needCommit = sqlite3_get_autocommit(p->db);
    if( needCommit ) sqlite3_exec(p->db, "BEGIN", 0, 0, 0);
    do{
      int startLine = sCtx.nLine;
      for(i=0; i<nCol; i++){
        char *z = xRead(&sCtx);
        /*
        ** Did we reach end-of-file before finding any columns?
        ** If so, stop instead of NULL filling the remaining columns.
        */
        if( z==0 && i==0 ) break;
        /*
        ** Did we reach end-of-file OR end-of-line before finding any
        ** columns in ASCII mode?  If so, stop instead of NULL filling
        ** the remaining columns.
        */
        if( p->mode==MODE_Ascii && (z==0 || z[0]==0) && i==0 ) break;
        sqlite3_bind_text(pStmt, i+1, z, -1, SQLITE_TRANSIENT);
        if( i<nCol-1 && sCtx.cTerm!=sCtx.cColSep ){
          utf8_printf(stderr, "%s:%d: expected %d columns but found %d - "
                          "filling the rest with NULL\n",
                          sCtx.zFile, startLine, nCol, i+1);
          i += 2;
          while( i<=nCol ){ sqlite3_bind_null(pStmt, i); i++; }
        }
      }
      if( sCtx.cTerm==sCtx.cColSep ){
        do{
          xRead(&sCtx);
          i++;
        }while( sCtx.cTerm==sCtx.cColSep );
        utf8_printf(stderr, "%s:%d: expected %d columns but found %d - "
                        "extras ignored\n",
                        sCtx.zFile, startLine, nCol, i);
      }
      if( i>=nCol ){
        sqlite3_step(pStmt);
        rc = sqlite3_reset(pStmt);
        if( rc!=SQLITE_OK ){
          utf8_printf(stderr, "%s:%d: INSERT failed: %s\n", sCtx.zFile,
                      startLine, sqlite3_errmsg(p->db));
        }
      }
    }while( sCtx.cTerm!=EOF );

    xCloser(sCtx.in);
    sqlite3_free(sCtx.z);
    sqlite3_finalize(pStmt);
    if( needCommit ) sqlite3_exec(p->db, "COMMIT", 0, 0, 0);
  }else

  if( c=='i' && (strncmp(azArg[0], "indices", n)==0
                 || strncmp(azArg[0], "indexes", n)==0) ){
    ShellState data;
    char *zErrMsg = 0;
    open_db(p, 0);
    memcpy(&data, p, sizeof(data));
    data.showHeader = 0;
    data.cMode = data.mode = MODE_List;
    if( nArg==1 ){
      rc = sqlite3_exec(p->db,
        "SELECT name FROM sqlite_master "
        "WHERE type='index' AND name NOT LIKE 'sqlite_%' "
        "UNION ALL "
        "SELECT name FROM sqlite_temp_master "
        "WHERE type='index' "
        "ORDER BY 1",
        callback, &data, &zErrMsg
      );
    }else if( nArg==2 ){
      zShellStatic = azArg[1];
      rc = sqlite3_exec(p->db,
        "SELECT name FROM sqlite_master "
        "WHERE type='index' AND tbl_name LIKE shellstatic() "
        "UNION ALL "
        "SELECT name FROM sqlite_temp_master "
        "WHERE type='index' AND tbl_name LIKE shellstatic() "
        "ORDER BY 1",
        callback, &data, &zErrMsg
      );
      zShellStatic = 0;
    }else{
      raw_printf(stderr, "Usage: .indexes ?LIKE-PATTERN?\n");
      rc = 1;
      goto meta_command_exit;
    }
    if( zErrMsg ){
      utf8_printf(stderr,"Error: %s\n", zErrMsg);
      sqlite3_free(zErrMsg);
      rc = 1;
    }else if( rc != SQLITE_OK ){
      raw_printf(stderr,
                 "Error: querying sqlite_master and sqlite_temp_master\n");
      rc = 1;
    }
  }else

#ifdef SQLITE_ENABLE_IOTRACE
  if( c=='i' && strncmp(azArg[0], "iotrace", n)==0 ){
    SQLITE_API extern void (SQLITE_CDECL *sqlite3IoTrace)(const char*, ...);
    if( iotrace && iotrace!=stdout ) fclose(iotrace);
    iotrace = 0;
    if( nArg<2 ){
      sqlite3IoTrace = 0;
    }else if( strcmp(azArg[1], "-")==0 ){
      sqlite3IoTrace = iotracePrintf;
      iotrace = stdout;
    }else{
      iotrace = fopen(azArg[1], "w");
      if( iotrace==0 ){
        utf8_printf(stderr, "Error: cannot open \"%s\"\n", azArg[1]);
        sqlite3IoTrace = 0;
        rc = 1;
      }else{
        sqlite3IoTrace = iotracePrintf;
      }
    }
  }else
#endif
  if( c=='l' && n>=5 && strncmp(azArg[0], "limits", n)==0 ){
    static const struct {
       const char *zLimitName;   /* Name of a limit */
       int limitCode;            /* Integer code for that limit */
    } aLimit[] = {
      { "length",                SQLITE_LIMIT_LENGTH                    },
      { "sql_length",            SQLITE_LIMIT_SQL_LENGTH                },
      { "column",                SQLITE_LIMIT_COLUMN                    },
      { "expr_depth",            SQLITE_LIMIT_EXPR_DEPTH                },
      { "compound_select",       SQLITE_LIMIT_COMPOUND_SELECT           },
      { "vdbe_op",               SQLITE_LIMIT_VDBE_OP                   },
      { "function_arg",          SQLITE_LIMIT_FUNCTION_ARG              },
      { "attached",              SQLITE_LIMIT_ATTACHED                  },
      { "like_pattern_length",   SQLITE_LIMIT_LIKE_PATTERN_LENGTH       },
      { "variable_number",       SQLITE_LIMIT_VARIABLE_NUMBER           },
      { "trigger_depth",         SQLITE_LIMIT_TRIGGER_DEPTH             },
      { "worker_threads",        SQLITE_LIMIT_WORKER_THREADS            },
    };
    int i, n2;
    open_db(p, 0);
    if( nArg==1 ){
      for(i=0; i<ArraySize(aLimit); i++){
        printf("%20s %d\n", aLimit[i].zLimitName, 
               sqlite3_limit(p->db, aLimit[i].limitCode, -1));
      }
    }else if( nArg>3 ){
      raw_printf(stderr, "Usage: .limit NAME ?NEW-VALUE?\n");
      rc = 1;
      goto meta_command_exit;
    }else{
      int iLimit = -1;
      n2 = strlen30(azArg[1]);
      for(i=0; i<ArraySize(aLimit); i++){
        if( sqlite3_strnicmp(aLimit[i].zLimitName, azArg[1], n2)==0 ){
          if( iLimit<0 ){
            iLimit = i;
          }else{
            utf8_printf(stderr, "ambiguous limit: \"%s\"\n", azArg[1]);
            rc = 1;
            goto meta_command_exit;
          }
        }
      }
      if( iLimit<0 ){
        utf8_printf(stderr, "unknown limit: \"%s\"\n"
                        "enter \".limits\" with no arguments for a list.\n",
                         azArg[1]);
        rc = 1;
        goto meta_command_exit;
      }
      if( nArg==3 ){
        sqlite3_limit(p->db, aLimit[iLimit].limitCode,
                      (int)integerValue(azArg[2]));
      }
      printf("%20s %d\n", aLimit[iLimit].zLimitName,
             sqlite3_limit(p->db, aLimit[iLimit].limitCode, -1));
    }
  }else

#ifndef SQLITE_OMIT_LOAD_EXTENSION
  if( c=='l' && strncmp(azArg[0], "load", n)==0 ){
    const char *zFile, *zProc;
    char *zErrMsg = 0;
    if( nArg<2 ){
      raw_printf(stderr, "Usage: .load FILE ?ENTRYPOINT?\n");
      rc = 1;
      goto meta_command_exit;
    }
    zFile = azArg[1];
    zProc = nArg>=3 ? azArg[2] : 0;
    open_db(p, 0);
    rc = sqlite3_load_extension(p->db, zFile, zProc, &zErrMsg);
    if( rc!=SQLITE_OK ){
      utf8_printf(stderr, "Error: %s\n", zErrMsg);
      sqlite3_free(zErrMsg);
      rc = 1;
    }
  }else
#endif

  if( c=='l' && strncmp(azArg[0], "log", n)==0 ){
    if( nArg!=2 ){
      raw_printf(stderr, "Usage: .log FILENAME\n");
      rc = 1;
    }else{
      const char *zFile = azArg[1];
      output_file_close(p->pLog);
      p->pLog = output_file_open(zFile);
    }
  }else

  if( c=='m' && strncmp(azArg[0], "mode", n)==0 ){
    const char *zMode = nArg>=2 ? azArg[1] : "";
    int n2 = (int)strlen(zMode);
    int c2 = zMode[0];
    if( c2=='l' && n2>2 && strncmp(azArg[1],"lines",n2)==0 ){
      p->mode = MODE_Line;
    }else if( c2=='c' && strncmp(azArg[1],"columns",n2)==0 ){
      p->mode = MODE_Column;
    }else if( c2=='l' && n2>2 && strncmp(azArg[1],"list",n2)==0 ){
      p->mode = MODE_List;
    }else if( c2=='h' && strncmp(azArg[1],"html",n2)==0 ){
      p->mode = MODE_Html;
    }else if( c2=='t' && strncmp(azArg[1],"tcl",n2)==0 ){
      p->mode = MODE_Tcl;
      sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator, SEP_Space);
    }else if( c2=='c' && strncmp(azArg[1],"csv",n2)==0 ){
      p->mode = MODE_Csv;
      sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator, SEP_Comma);
      sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_CrLf);
    }else if( c2=='t' && strncmp(azArg[1],"tabs",n2)==0 ){
      p->mode = MODE_List;
      sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator, SEP_Tab);
    }else if( c2=='i' && strncmp(azArg[1],"insert",n2)==0 ){
      p->mode = MODE_Insert;
      set_table_name(p, nArg>=3 ? azArg[2] : "table");
    }else if( c2=='a' && strncmp(azArg[1],"ascii",n2)==0 ){
      p->mode = MODE_Ascii;
      sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator, SEP_Unit);
      sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_Record);
    }else {
      raw_printf(stderr, "Error: mode should be one of: "
         "ascii column csv html insert line list tabs tcl\n");
      rc = 1;
    }
    p->cMode = p->mode;
  }else

  if( c=='n' && strncmp(azArg[0], "nullvalue", n)==0 ){
    if( nArg==2 ){
      sqlite3_snprintf(sizeof(p->nullValue), p->nullValue,
                       "%.*s", (int)ArraySize(p->nullValue)-1, azArg[1]);
    }else{
      raw_printf(stderr, "Usage: .nullvalue STRING\n");
      rc = 1;
    }
  }else

  if( c=='o' && strncmp(azArg[0], "open", n)==0 && n>=2 ){
    sqlite3 *savedDb = p->db;
    const char *zSavedFilename = p->zDbFilename;
    char *zNewFilename = 0;
    p->db = 0;
    if( nArg>=2 ) zNewFilename = sqlite3_mprintf("%s", azArg[1]);
    p->zDbFilename = zNewFilename;
    open_db(p, 1);
    if( p->db!=0 ){
      sqlite3_close(savedDb);
      sqlite3_free(p->zFreeOnClose);
      p->zFreeOnClose = zNewFilename;
    }else{
      sqlite3_free(zNewFilename);
      p->db = savedDb;
      p->zDbFilename = zSavedFilename;
    }
  }else

  if( c=='o'
   && (strncmp(azArg[0], "output", n)==0 || strncmp(azArg[0], "once", n)==0)
  ){
    const char *zFile = nArg>=2 ? azArg[1] : "stdout";
    if( nArg>2 ){
      utf8_printf(stderr, "Usage: .%s FILE\n", azArg[0]);
      rc = 1;
      goto meta_command_exit;
    }
    if( n>1 && strncmp(azArg[0], "once", n)==0 ){
      if( nArg<2 ){
        raw_printf(stderr, "Usage: .once FILE\n");
        rc = 1;
        goto meta_command_exit;
      }
      p->outCount = 2;
    }else{
      p->outCount = 0;
    }
    output_reset(p);
    if( zFile[0]=='|' ){
#ifdef SQLITE_OMIT_POPEN
      raw_printf(stderr, "Error: pipes are not supported in this OS\n");
      rc = 1;
      p->out = stdout;
#else
      p->out = popen(zFile + 1, "w");
      if( p->out==0 ){
        utf8_printf(stderr,"Error: cannot open pipe \"%s\"\n", zFile + 1);
        p->out = stdout;
        rc = 1;
      }else{
        sqlite3_snprintf(sizeof(p->outfile), p->outfile, "%s", zFile);
      }
#endif
    }else{
      p->out = output_file_open(zFile);
      if( p->out==0 ){
        if( strcmp(zFile,"off")!=0 ){
          utf8_printf(stderr,"Error: cannot write to \"%s\"\n", zFile);
        }
        p->out = stdout;
        rc = 1;
      } else {
        sqlite3_snprintf(sizeof(p->outfile), p->outfile, "%s", zFile);
      }
    }
  }else

  if( c=='p' && n>=3 && strncmp(azArg[0], "print", n)==0 ){
    int i;
    for(i=1; i<nArg; i++){
      if( i>1 ) raw_printf(p->out, " ");
      utf8_printf(p->out, "%s", azArg[i]);
    }
    raw_printf(p->out, "\n");
  }else

  if( c=='p' && strncmp(azArg[0], "prompt", n)==0 ){
    if( nArg >= 2) {
      strncpy(mainPrompt,azArg[1],(int)ArraySize(mainPrompt)-1);
    }
    if( nArg >= 3) {
      strncpy(continuePrompt,azArg[2],(int)ArraySize(continuePrompt)-1);
    }
  }else

  if( c=='q' && strncmp(azArg[0], "quit", n)==0 ){
    rc = 2;
  }else

  if( c=='r' && n>=3 && strncmp(azArg[0], "read", n)==0 ){
    FILE *alt;
    if( nArg!=2 ){
      raw_printf(stderr, "Usage: .read FILE\n");
      rc = 1;
      goto meta_command_exit;
    }
    alt = fopen(azArg[1], "rb");
    if( alt==0 ){
      utf8_printf(stderr,"Error: cannot open \"%s\"\n", azArg[1]);
      rc = 1;
    }else{
      rc = process_input(p, alt);
      fclose(alt);
    }
  }else

  if( c=='r' && n>=3 && strncmp(azArg[0], "restore", n)==0 ){
    const char *zSrcFile;
    const char *zDb;
    sqlite3 *pSrc;
    sqlite3_backup *pBackup;
    int nTimeout = 0;

    if( nArg==2 ){
      zSrcFile = azArg[1];
      zDb = "main";
    }else if( nArg==3 ){
      zSrcFile = azArg[2];
      zDb = azArg[1];
    }else{
      raw_printf(stderr, "Usage: .restore ?DB? FILE\n");
      rc = 1;
      goto meta_command_exit;
    }
    rc = sqlite3_open(zSrcFile, &pSrc);
    if( rc!=SQLITE_OK ){
      utf8_printf(stderr, "Error: cannot open \"%s\"\n", zSrcFile);
      sqlite3_close(pSrc);
      return 1;
    }
    open_db(p, 0);
    pBackup = sqlite3_backup_init(p->db, zDb, pSrc, "main");
    if( pBackup==0 ){
      utf8_printf(stderr, "Error: %s\n", sqlite3_errmsg(p->db));
      sqlite3_close(pSrc);
      return 1;
    }
    while( (rc = sqlite3_backup_step(pBackup,100))==SQLITE_OK
          || rc==SQLITE_BUSY  ){
      if( rc==SQLITE_BUSY ){
        if( nTimeout++ >= 3 ) break;
        sqlite3_sleep(100);
      }
    }
    sqlite3_backup_finish(pBackup);
    if( rc==SQLITE_DONE ){
      rc = 0;
    }else if( rc==SQLITE_BUSY || rc==SQLITE_LOCKED ){
      raw_printf(stderr, "Error: source database is busy\n");
      rc = 1;
    }else{
      utf8_printf(stderr, "Error: %s\n", sqlite3_errmsg(p->db));
      rc = 1;
    }
    sqlite3_close(pSrc);
  }else


  if( c=='s' && strncmp(azArg[0], "scanstats", n)==0 ){
    if( nArg==2 ){
      p->scanstatsOn = booleanValue(azArg[1]);
#ifndef SQLITE_ENABLE_STMT_SCANSTATUS
      raw_printf(stderr, "Warning: .scanstats not available in this build.\n");
#endif
    }else{
      raw_printf(stderr, "Usage: .scanstats on|off\n");
      rc = 1;
    }
  }else

  if( c=='s' && strncmp(azArg[0], "schema", n)==0 ){
    ShellState data;
    char *zErrMsg = 0;
    open_db(p, 0);
    memcpy(&data, p, sizeof(data));
    data.showHeader = 0;
    data.cMode = data.mode = MODE_Semi;
    if( nArg==2 ){
      int i;
      for(i=0; azArg[1][i]; i++) azArg[1][i] = ToLower(azArg[1][i]);
      if( strcmp(azArg[1],"sqlite_master")==0 ){
        char *new_argv[2], *new_colv[2];
        new_argv[0] = "CREATE TABLE sqlite_master (\n"
                      "  type text,\n"
                      "  name text,\n"
                      "  tbl_name text,\n"
                      "  rootpage integer,\n"
                      "  sql text\n"
                      ")";
        new_argv[1] = 0;
        new_colv[0] = "sql";
        new_colv[1] = 0;
        callback(&data, 1, new_argv, new_colv);
        rc = SQLITE_OK;
      }else if( strcmp(azArg[1],"sqlite_temp_master")==0 ){
        char *new_argv[2], *new_colv[2];
        new_argv[0] = "CREATE TEMP TABLE sqlite_temp_master (\n"
                      "  type text,\n"
                      "  name text,\n"
                      "  tbl_name text,\n"
                      "  rootpage integer,\n"
                      "  sql text\n"
                      ")";
        new_argv[1] = 0;
        new_colv[0] = "sql";
        new_colv[1] = 0;
        callback(&data, 1, new_argv, new_colv);
        rc = SQLITE_OK;
      }else{
        zShellStatic = azArg[1];
        rc = sqlite3_exec(p->db,
          "SELECT sql FROM "
          "  (SELECT sql sql, type type, tbl_name tbl_name, name name, rowid x"
          "     FROM sqlite_master UNION ALL"
          "   SELECT sql, type, tbl_name, name, rowid FROM sqlite_temp_master) "
          "WHERE lower(tbl_name) LIKE shellstatic()"
          "  AND type!='meta' AND sql NOTNULL "
          "ORDER BY rowid",
          callback, &data, &zErrMsg);
        zShellStatic = 0;
      }
    }else if( nArg==1 ){
      rc = sqlite3_exec(p->db,
         "SELECT sql FROM "
         "  (SELECT sql sql, type type, tbl_name tbl_name, name name, rowid x"
         "     FROM sqlite_master UNION ALL"
         "   SELECT sql, type, tbl_name, name, rowid FROM sqlite_temp_master) "
         "WHERE type!='meta' AND sql NOTNULL AND name NOT LIKE 'sqlite_%' "
         "ORDER BY rowid",
         callback, &data, &zErrMsg
      );
    }else{
      raw_printf(stderr, "Usage: .schema ?LIKE-PATTERN?\n");
      rc = 1;
      goto meta_command_exit;
    }
    if( zErrMsg ){
      utf8_printf(stderr,"Error: %s\n", zErrMsg);
      sqlite3_free(zErrMsg);
      rc = 1;
    }else if( rc != SQLITE_OK ){
      raw_printf(stderr,"Error: querying schema information\n");
      rc = 1;
    }else{
      rc = 0;
    }
  }else


#if defined(SQLITE_DEBUG) && defined(SQLITE_ENABLE_SELECTTRACE)
  if( c=='s' && n==11 && strncmp(azArg[0], "selecttrace", n)==0 ){
    extern int sqlite3SelectTrace;
    sqlite3SelectTrace = integerValue(azArg[1]);
  }else
#endif


#ifdef SQLITE_DEBUG
  /* Undocumented commands for internal testing.  Subject to change
  ** without notice. */
  if( c=='s' && n>=10 && strncmp(azArg[0], "selftest-", 9)==0 ){
    if( strncmp(azArg[0]+9, "boolean", n-9)==0 ){
      int i, v;
      for(i=1; i<nArg; i++){
        v = booleanValue(azArg[i]);
        utf8_printf(p->out, "%s: %d 0x%x\n", azArg[i], v, v);
      }
    }
    if( strncmp(azArg[0]+9, "integer", n-9)==0 ){
      int i; sqlite3_int64 v;
      for(i=1; i<nArg; i++){
        char zBuf[200];
        v = integerValue(azArg[i]);
        sqlite3_snprintf(sizeof(zBuf),zBuf,"%s: %lld 0x%llx\n", azArg[i],v,v);
        utf8_printf(p->out, "%s", zBuf);
      }
    }
  }else
#endif

  if( c=='s' && strncmp(azArg[0], "separator", n)==0 ){
    if( nArg<2 || nArg>3 ){
      raw_printf(stderr, "Usage: .separator COL ?ROW?\n");
      rc = 1;
    }
    if( nArg>=2 ){
      sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator,
                       "%.*s", (int)ArraySize(p->colSeparator)-1, azArg[1]);
    }
    if( nArg>=3 ){
      sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator,
                       "%.*s", (int)ArraySize(p->rowSeparator)-1, azArg[2]);
    }
  }else

  if( c=='s'
   && (strncmp(azArg[0], "shell", n)==0 || strncmp(azArg[0],"system",n)==0)
  ){
    char *zCmd;
    int i, x;
    if( nArg<2 ){
      raw_printf(stderr, "Usage: .system COMMAND\n");
      rc = 1;
      goto meta_command_exit;
    }
    zCmd = sqlite3_mprintf(strchr(azArg[1],' ')==0?"%s":"\"%s\"", azArg[1]);
    for(i=2; i<nArg; i++){
      zCmd = sqlite3_mprintf(strchr(azArg[i],' ')==0?"%z %s":"%z \"%s\"",
                             zCmd, azArg[i]);
    }
    x = system(zCmd);
    sqlite3_free(zCmd);
    if( x ) raw_printf(stderr, "System command returns %d\n", x);
  }else

  if( c=='s' && strncmp(azArg[0], "show", n)==0 ){
    int i;
    if( nArg!=1 ){
      raw_printf(stderr, "Usage: .show\n");
      rc = 1;
      goto meta_command_exit;
    }
    utf8_printf(p->out, "%12.12s: %s\n","echo", p->echoOn ? "on" : "off");
    utf8_printf(p->out, "%12.12s: %s\n","eqp", p->autoEQP ? "on" : "off");
    utf8_printf(p->out, "%12.12s: %s\n","explain",
         p->mode==MODE_Explain ? "on" : p->autoExplain ? "auto" : "off");
    utf8_printf(p->out,"%12.12s: %s\n","headers", p->showHeader ? "on" : "off");
    utf8_printf(p->out, "%12.12s: %s\n","mode", modeDescr[p->mode]);
    utf8_printf(p->out, "%12.12s: ", "nullvalue");
      output_c_string(p->out, p->nullValue);
      raw_printf(p->out, "\n");
    utf8_printf(p->out,"%12.12s: %s\n","output",
            strlen30(p->outfile) ? p->outfile : "stdout");
    utf8_printf(p->out,"%12.12s: ", "colseparator");
      output_c_string(p->out, p->colSeparator);
      raw_printf(p->out, "\n");
    utf8_printf(p->out,"%12.12s: ", "rowseparator");
      output_c_string(p->out, p->rowSeparator);
      raw_printf(p->out, "\n");
    utf8_printf(p->out, "%12.12s: %s\n","stats", p->statsOn ? "on" : "off");
    utf8_printf(p->out, "%12.12s: ", "width");
    for (i=0;i<(int)ArraySize(p->colWidth) && p->colWidth[i] != 0;i++) {
      raw_printf(p->out, "%d ", p->colWidth[i]);
    }
    raw_printf(p->out, "\n");
  }else

  if( c=='s' && strncmp(azArg[0], "stats", n)==0 ){
    if( nArg==2 ){
      p->statsOn = booleanValue(azArg[1]);
    }else if( nArg==1 ){
      display_stats(p->db, p, 0);
    }else{
      raw_printf(stderr, "Usage: .stats ?on|off?\n");
      rc = 1;
    }
  }else

  if( c=='t' && n>1 && strncmp(azArg[0], "tables", n)==0 ){
    sqlite3_stmt *pStmt;
    char **azResult;
    int nRow, nAlloc;
    char *zSql = 0;
    int ii;
    open_db(p, 0);
    rc = sqlite3_prepare_v2(p->db, "PRAGMA database_list", -1, &pStmt, 0);
    if( rc ) return shellDatabaseError(p->db);

    /* Create an SQL statement to query for the list of tables in the
    ** main and all attached databases where the table name matches the
    ** LIKE pattern bound to variable "?1". */
    zSql = sqlite3_mprintf(
        "SELECT name FROM sqlite_master"
        " WHERE type IN ('table','view')"
        "   AND name NOT LIKE 'sqlite_%%'"
        "   AND name LIKE ?1");
    while( zSql && sqlite3_step(pStmt)==SQLITE_ROW ){
      const char *zDbName = (const char*)sqlite3_column_text(pStmt, 1);
      if( zDbName==0 || strcmp(zDbName,"main")==0 ) continue;
      if( strcmp(zDbName,"temp")==0 ){
        zSql = sqlite3_mprintf(
                 "%z UNION ALL "
                 "SELECT 'temp.' || name FROM sqlite_temp_master"
                 " WHERE type IN ('table','view')"
                 "   AND name NOT LIKE 'sqlite_%%'"
                 "   AND name LIKE ?1", zSql);
      }else{
        zSql = sqlite3_mprintf(
                 "%z UNION ALL "
                 "SELECT '%q.' || name FROM \"%w\".sqlite_master"
                 " WHERE type IN ('table','view')"
                 "   AND name NOT LIKE 'sqlite_%%'"
                 "   AND name LIKE ?1", zSql, zDbName, zDbName);
      }
    }
    rc = sqlite3_finalize(pStmt);
    if( zSql && rc==SQLITE_OK ){
      zSql = sqlite3_mprintf("%z ORDER BY 1", zSql);
      if( zSql ) rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
    }
    sqlite3_free(zSql);
    if( !zSql ) return shellNomemError();
    if( rc ) return shellDatabaseError(p->db);

    /* Run the SQL statement prepared by the above block. Store the results
    ** as an array of nul-terminated strings in azResult[].  */
    nRow = nAlloc = 0;
    azResult = 0;
    if( nArg>1 ){
      sqlite3_bind_text(pStmt, 1, azArg[1], -1, SQLITE_TRANSIENT);
    }else{
      sqlite3_bind_text(pStmt, 1, "%", -1, SQLITE_STATIC);
    }
    while( sqlite3_step(pStmt)==SQLITE_ROW ){
      if( nRow>=nAlloc ){
        char **azNew;
        int n2 = nAlloc*2 + 10;
        azNew = sqlite3_realloc64(azResult, sizeof(azResult[0])*n2);
        if( azNew==0 ){
          rc = shellNomemError();
          break;
        }
        nAlloc = n2;
        azResult = azNew;
      }
      azResult[nRow] = sqlite3_mprintf("%s", sqlite3_column_text(pStmt, 0));
      if( 0==azResult[nRow] ){
        rc = shellNomemError();
        break;
      }
      nRow++;
    }
    if( sqlite3_finalize(pStmt)!=SQLITE_OK ){
      rc = shellDatabaseError(p->db);
    }

    /* Pretty-print the contents of array azResult[] to the output */
    if( rc==0 && nRow>0 ){
      int len, maxlen = 0;
      int i, j;
      int nPrintCol, nPrintRow;
      for(i=0; i<nRow; i++){
        len = strlen30(azResult[i]);
        if( len>maxlen ) maxlen = len;
      }
      nPrintCol = 80/(maxlen+2);
      if( nPrintCol<1 ) nPrintCol = 1;
      nPrintRow = (nRow + nPrintCol - 1)/nPrintCol;
      for(i=0; i<nPrintRow; i++){
        for(j=i; j<nRow; j+=nPrintRow){
          char *zSp = j<nPrintRow ? "" : "  ";
          utf8_printf(p->out, "%s%-*s", zSp, maxlen,
                      azResult[j] ? azResult[j]:"");
        }
        raw_printf(p->out, "\n");
      }
    }

    for(ii=0; ii<nRow; ii++) sqlite3_free(azResult[ii]);
    sqlite3_free(azResult);
  }else

  if( c=='t' && n>=8 && strncmp(azArg[0], "testctrl", n)==0 && nArg>=2 ){
    static const struct {
       const char *zCtrlName;   /* Name of a test-control option */
       int ctrlCode;            /* Integer code for that option */
    } aCtrl[] = {
      { "prng_save",             SQLITE_TESTCTRL_PRNG_SAVE              },
      { "prng_restore",          SQLITE_TESTCTRL_PRNG_RESTORE           },
      { "prng_reset",            SQLITE_TESTCTRL_PRNG_RESET             },
      { "bitvec_test",           SQLITE_TESTCTRL_BITVEC_TEST            },
      { "fault_install",         SQLITE_TESTCTRL_FAULT_INSTALL          },
      { "benign_malloc_hooks",   SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS    },
      { "pending_byte",          SQLITE_TESTCTRL_PENDING_BYTE           },
      { "assert",                SQLITE_TESTCTRL_ASSERT                 },
      { "always",                SQLITE_TESTCTRL_ALWAYS                 },
      { "reserve",               SQLITE_TESTCTRL_RESERVE                },
      { "optimizations",         SQLITE_TESTCTRL_OPTIMIZATIONS          },
      { "iskeyword",             SQLITE_TESTCTRL_ISKEYWORD              },
      { "scratchmalloc",         SQLITE_TESTCTRL_SCRATCHMALLOC          },
      { "byteorder",             SQLITE_TESTCTRL_BYTEORDER              },
      { "never_corrupt",         SQLITE_TESTCTRL_NEVER_CORRUPT          },
      { "imposter",              SQLITE_TESTCTRL_IMPOSTER               },
    };
    int testctrl = -1;
    int rc2 = 0;
    int i, n2;
    open_db(p, 0);

    /* convert testctrl text option to value. allow any unique prefix
    ** of the option name, or a numerical value. */
    n2 = strlen30(azArg[1]);
    for(i=0; i<ArraySize(aCtrl); i++){
      if( strncmp(azArg[1], aCtrl[i].zCtrlName, n2)==0 ){
        if( testctrl<0 ){
          testctrl = aCtrl[i].ctrlCode;
        }else{
          utf8_printf(stderr, "ambiguous option name: \"%s\"\n", azArg[1]);
          testctrl = -1;
          break;
        }
      }
    }
    if( testctrl<0 ) testctrl = (int)integerValue(azArg[1]);
    if( (testctrl<SQLITE_TESTCTRL_FIRST) || (testctrl>SQLITE_TESTCTRL_LAST) ){
      utf8_printf(stderr,"Error: invalid testctrl option: %s\n", azArg[1]);
    }else{
      switch(testctrl){

        /* sqlite3_test_control(int, db, int) */
        case SQLITE_TESTCTRL_OPTIMIZATIONS:
        case SQLITE_TESTCTRL_RESERVE:             
          if( nArg==3 ){
            int opt = (int)strtol(azArg[2], 0, 0);        
            rc2 = sqlite3_test_control(testctrl, p->db, opt);
            raw_printf(p->out, "%d (0x%08x)\n", rc2, rc2);
          } else {
            utf8_printf(stderr,"Error: testctrl %s takes a single int option\n",
                    azArg[1]);
          }
          break;

        /* sqlite3_test_control(int) */
        case SQLITE_TESTCTRL_PRNG_SAVE:
        case SQLITE_TESTCTRL_PRNG_RESTORE:
        case SQLITE_TESTCTRL_PRNG_RESET:
        case SQLITE_TESTCTRL_BYTEORDER:
          if( nArg==2 ){
            rc2 = sqlite3_test_control(testctrl);
            raw_printf(p->out, "%d (0x%08x)\n", rc2, rc2);
          } else {
            utf8_printf(stderr,"Error: testctrl %s takes no options\n",
                        azArg[1]);
          }
          break;

        /* sqlite3_test_control(int, uint) */
        case SQLITE_TESTCTRL_PENDING_BYTE:        
          if( nArg==3 ){
            unsigned int opt = (unsigned int)integerValue(azArg[2]);
            rc2 = sqlite3_test_control(testctrl, opt);
            raw_printf(p->out, "%d (0x%08x)\n", rc2, rc2);
          } else {
            utf8_printf(stderr,"Error: testctrl %s takes a single unsigned"
                           " int option\n", azArg[1]);
          }
          break;
          
        /* sqlite3_test_control(int, int) */
        case SQLITE_TESTCTRL_ASSERT:              
        case SQLITE_TESTCTRL_ALWAYS:      
        case SQLITE_TESTCTRL_NEVER_CORRUPT:        
          if( nArg==3 ){
            int opt = booleanValue(azArg[2]);        
            rc2 = sqlite3_test_control(testctrl, opt);
            raw_printf(p->out, "%d (0x%08x)\n", rc2, rc2);
          } else {
            utf8_printf(stderr,"Error: testctrl %s takes a single int option\n",
                            azArg[1]);
          }
          break;

        /* sqlite3_test_control(int, char *) */
#ifdef SQLITE_N_KEYWORD
        case SQLITE_TESTCTRL_ISKEYWORD:           
          if( nArg==3 ){
            const char *opt = azArg[2];        
            rc2 = sqlite3_test_control(testctrl, opt);
            raw_printf(p->out, "%d (0x%08x)\n", rc2, rc2);
          } else {
            utf8_printf(stderr,
                        "Error: testctrl %s takes a single char * option\n",
                        azArg[1]);
          }
          break;
#endif

        case SQLITE_TESTCTRL_IMPOSTER:
          if( nArg==5 ){
            rc2 = sqlite3_test_control(testctrl, p->db, 
                          azArg[2],
                          integerValue(azArg[3]),
                          integerValue(azArg[4]));
            raw_printf(p->out, "%d (0x%08x)\n", rc2, rc2);
          }else{
            raw_printf(stderr,"Usage: .testctrl imposter dbName onoff tnum\n");
          }
          break;

        case SQLITE_TESTCTRL_BITVEC_TEST:         
        case SQLITE_TESTCTRL_FAULT_INSTALL:       
        case SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS: 
        case SQLITE_TESTCTRL_SCRATCHMALLOC:       
        default:
          utf8_printf(stderr,
                      "Error: CLI support for testctrl %s not implemented\n",
                      azArg[1]);
          break;
      }
    }
  }else

  if( c=='t' && n>4 && strncmp(azArg[0], "timeout", n)==0 ){
    open_db(p, 0);
    sqlite3_busy_timeout(p->db, nArg>=2 ? (int)integerValue(azArg[1]) : 0);
  }else
    
  if( c=='t' && n>=5 && strncmp(azArg[0], "timer", n)==0 ){
    if( nArg==2 ){
      enableTimer = booleanValue(azArg[1]);
      if( enableTimer && !HAS_TIMER ){
        raw_printf(stderr, "Error: timer not available on this system.\n");
        enableTimer = 0;
      }
    }else{
      raw_printf(stderr, "Usage: .timer on|off\n");
      rc = 1;
    }
  }else
  
  if( c=='t' && strncmp(azArg[0], "trace", n)==0 ){
    open_db(p, 0);
    if( nArg!=2 ){
      raw_printf(stderr, "Usage: .trace FILE|off\n");
      rc = 1;
      goto meta_command_exit;
    }
    output_file_close(p->traceOut);
    p->traceOut = output_file_open(azArg[1]);
#if !defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_OMIT_FLOATING_POINT)
    if( p->traceOut==0 ){
      sqlite3_trace(p->db, 0, 0);
    }else{
      sqlite3_trace(p->db, sql_trace_callback, p->traceOut);
    }
#endif
  }else

#if SQLITE_USER_AUTHENTICATION
  if( c=='u' && strncmp(azArg[0], "user", n)==0 ){
    if( nArg<2 ){
      raw_printf(stderr, "Usage: .user SUBCOMMAND ...\n");
      rc = 1;
      goto meta_command_exit;
    }
    open_db(p, 0);
    if( strcmp(azArg[1],"login")==0 ){
      if( nArg!=4 ){
        raw_printf(stderr, "Usage: .user login USER PASSWORD\n");
        rc = 1;
        goto meta_command_exit;
      }
      rc = sqlite3_user_authenticate(p->db, azArg[2], azArg[3],
                                    (int)strlen(azArg[3]));
      if( rc ){
        utf8_printf(stderr, "Authentication failed for user %s\n", azArg[2]);
        rc = 1;
      }
    }else if( strcmp(azArg[1],"add")==0 ){
      if( nArg!=5 ){
        raw_printf(stderr, "Usage: .user add USER PASSWORD ISADMIN\n");
        rc = 1;
        goto meta_command_exit;
      }
      rc = sqlite3_user_add(p->db, azArg[2],
                            azArg[3], (int)strlen(azArg[3]),
                            booleanValue(azArg[4]));
      if( rc ){
        raw_printf(stderr, "User-Add failed: %d\n", rc);
        rc = 1;
      }
    }else if( strcmp(azArg[1],"edit")==0 ){
      if( nArg!=5 ){
        raw_printf(stderr, "Usage: .user edit USER PASSWORD ISADMIN\n");
        rc = 1;
        goto meta_command_exit;
      }
      rc = sqlite3_user_change(p->db, azArg[2],
                              azArg[3], (int)strlen(azArg[3]),
                              booleanValue(azArg[4]));
      if( rc ){
        raw_printf(stderr, "User-Edit failed: %d\n", rc);
        rc = 1;
      }
    }else if( strcmp(azArg[1],"delete")==0 ){
      if( nArg!=3 ){
        raw_printf(stderr, "Usage: .user delete USER\n");
        rc = 1;
        goto meta_command_exit;
      }
      rc = sqlite3_user_delete(p->db, azArg[2]);
      if( rc ){
        raw_printf(stderr, "User-Delete failed: %d\n", rc);
        rc = 1;
      }
    }else{
      raw_printf(stderr, "Usage: .user login|add|edit|delete ...\n");
      rc = 1;
      goto meta_command_exit;
    }    
  }else
#endif /* SQLITE_USER_AUTHENTICATION */

  if( c=='v' && strncmp(azArg[0], "version", n)==0 ){
    utf8_printf(p->out, "SQLite %s %s\n" /*extra-version-info*/,
        sqlite3_libversion(), sqlite3_sourceid());
  }else

  if( c=='v' && strncmp(azArg[0], "vfsinfo", n)==0 ){
    const char *zDbName = nArg==2 ? azArg[1] : "main";
    sqlite3_vfs *pVfs;
    if( p->db ){
      sqlite3_file_control(p->db, zDbName, SQLITE_FCNTL_VFS_POINTER, &pVfs);
      if( pVfs ){
        utf8_printf(p->out, "vfs.zName      = \"%s\"\n", pVfs->zName);
        raw_printf(p->out, "vfs.iVersion   = %d\n", pVfs->iVersion);
        raw_printf(p->out, "vfs.szOsFile   = %d\n", pVfs->szOsFile);
        raw_printf(p->out, "vfs.mxPathname = %d\n", pVfs->mxPathname);
      }
    }
  }else

  if( c=='v' && strncmp(azArg[0], "vfslist", n)==0 ){
    sqlite3_vfs *pVfs;
    sqlite3_vfs *pCurrent = 0;
    if( p->db ){
      sqlite3_file_control(p->db, "main", SQLITE_FCNTL_VFS_POINTER, &pCurrent);
    }
    for(pVfs=sqlite3_vfs_find(0); pVfs; pVfs=pVfs->pNext){
      utf8_printf(p->out, "vfs.zName      = \"%s\"%s\n", pVfs->zName,
           pVfs==pCurrent ? "  <--- CURRENT" : "");
      raw_printf(p->out, "vfs.iVersion   = %d\n", pVfs->iVersion);
      raw_printf(p->out, "vfs.szOsFile   = %d\n", pVfs->szOsFile);
      raw_printf(p->out, "vfs.mxPathname = %d\n", pVfs->mxPathname);
      if( pVfs->pNext ){
        raw_printf(p->out, "-----------------------------------\n");
      }
    }
  }else

  if( c=='v' && strncmp(azArg[0], "vfsname", n)==0 ){
    const char *zDbName = nArg==2 ? azArg[1] : "main";
    char *zVfsName = 0;
    if( p->db ){
      sqlite3_file_control(p->db, zDbName, SQLITE_FCNTL_VFSNAME, &zVfsName);
      if( zVfsName ){
        utf8_printf(p->out, "%s\n", zVfsName);
        sqlite3_free(zVfsName);
      }
    }
  }else

#if defined(SQLITE_DEBUG) && defined(SQLITE_ENABLE_WHERETRACE)
  if( c=='w' && strncmp(azArg[0], "wheretrace", n)==0 ){
    extern int sqlite3WhereTrace;
    sqlite3WhereTrace = nArg>=2 ? booleanValue(azArg[1]) : 0xff;
  }else
#endif

  if( c=='w' && strncmp(azArg[0], "width", n)==0 ){
    int j;
    assert( nArg<=ArraySize(azArg) );
    for(j=1; j<nArg && j<ArraySize(p->colWidth); j++){
      p->colWidth[j-1] = (int)integerValue(azArg[j]);
    }
  }else

  {
    utf8_printf(stderr, "Error: unknown command or invalid arguments: "
      " \"%s\". Enter \".help\" for help\n", azArg[0]);
    rc = 1;
  }

meta_command_exit:
  if( p->outCount ){
    p->outCount--;
    if( p->outCount==0 ) output_reset(p);
  }
  return rc;
}

/*
** Return TRUE if a semicolon occurs anywhere in the first N characters
** of string z[].
*/
static int line_contains_semicolon(const char *z, int N){
  int i;
  for(i=0; i<N; i++){  if( z[i]==';' ) return 1; }
  return 0;
}

/*
** Test to see if a line consists entirely of whitespace.
*/
static int _all_whitespace(const char *z){
  for(; *z; z++){
    if( IsSpace(z[0]) ) continue;
    if( *z=='/' && z[1]=='*' ){
      z += 2;
      while( *z && (*z!='*' || z[1]!='/') ){ z++; }
      if( *z==0 ) return 0;
      z++;
      continue;
    }
    if( *z=='-' && z[1]=='-' ){
      z += 2;
      while( *z && *z!='\n' ){ z++; }
      if( *z==0 ) return 1;
      continue;
    }
    return 0;
  }
  return 1;
}

/*
** Return TRUE if the line typed in is an SQL command terminator other
** than a semi-colon.  The SQL Server style "go" command is understood
** as is the Oracle "/".
*/
static int line_is_command_terminator(const char *zLine){
  while( IsSpace(zLine[0]) ){ zLine++; };
  if( zLine[0]=='/' && _all_whitespace(&zLine[1]) ){
    return 1;  /* Oracle */
  }
  if( ToLower(zLine[0])=='g' && ToLower(zLine[1])=='o'
         && _all_whitespace(&zLine[2]) ){
    return 1;  /* SQL Server */
  }
  return 0;
}

/*
** Return true if zSql is a complete SQL statement.  Return false if it
** ends in the middle of a string literal or C-style comment.
*/
static int line_is_complete(char *zSql, int nSql){
  int rc;
  if( zSql==0 ) return 1;
  zSql[nSql] = ';';
  zSql[nSql+1] = 0;
  rc = sqlite3_complete(zSql);
  zSql[nSql] = 0;
  return rc;
}

/*
** Read input from *in and process it.  If *in==0 then input
** is interactive - the user is typing it it.  Otherwise, input
** is coming from a file or device.  A prompt is issued and history
** is saved only if input is interactive.  An interrupt signal will
** cause this routine to exit immediately, unless input is interactive.
**
** Return the number of errors.
*/
static int process_input(ShellState *p, FILE *in){
  char *zLine = 0;          /* A single input line */
  char *zSql = 0;           /* Accumulated SQL text */
  int nLine;                /* Length of current line */
  int nSql = 0;             /* Bytes of zSql[] used */
  int nAlloc = 0;           /* Allocated zSql[] space */
  int nSqlPrior = 0;        /* Bytes of zSql[] used by prior line */
  char *zErrMsg;            /* Error message returned */
  int rc;                   /* Error code */
  int errCnt = 0;           /* Number of errors seen */
  int lineno = 0;           /* Current line number */
  int startline = 0;        /* Line number for start of current input */

  while( errCnt==0 || !bail_on_error || (in==0 && stdin_is_interactive) ){
    fflush(p->out);
    zLine = one_input_line(in, zLine, nSql>0);
    if( zLine==0 ){
      /* End of input */
      if( stdin_is_interactive ) printf("\n");
      break;
    }
    if( seenInterrupt ){
      if( in!=0 ) break;
      seenInterrupt = 0;
    }
    lineno++;
    if( nSql==0 && _all_whitespace(zLine) ){
      if( p->echoOn ) printf("%s\n", zLine);
      continue;
    }
    if( zLine && zLine[0]=='.' && nSql==0 ){
      if( p->echoOn ) printf("%s\n", zLine);
      rc = do_meta_command(zLine, p);
      if( rc==2 ){ /* exit requested */
        break;
      }else if( rc ){
        errCnt++;
      }
      continue;
    }
    if( line_is_command_terminator(zLine) && line_is_complete(zSql, nSql) ){
      memcpy(zLine,";",2);
    }
    nLine = strlen30(zLine);
    if( nSql+nLine+2>=nAlloc ){
      nAlloc = nSql+nLine+100;
      zSql = realloc(zSql, nAlloc);
      if( zSql==0 ){
        raw_printf(stderr, "Error: out of memory\n");
        exit(1);
      }
    }
    nSqlPrior = nSql;
    if( nSql==0 ){
      int i;
      for(i=0; zLine[i] && IsSpace(zLine[i]); i++){}
      assert( nAlloc>0 && zSql!=0 );
      memcpy(zSql, zLine+i, nLine+1-i);
      startline = lineno;
      nSql = nLine-i;
    }else{
      zSql[nSql++] = '\n';
      memcpy(zSql+nSql, zLine, nLine+1);
      nSql += nLine;
    }
    if( nSql && line_contains_semicolon(&zSql[nSqlPrior], nSql-nSqlPrior)
                && sqlite3_complete(zSql) ){
      p->cnt = 0;
      open_db(p, 0);
      if( p->backslashOn ) resolve_backslashes(zSql);
      BEGIN_TIMER;
      rc = shell_exec(p->db, zSql, shell_callback, p, &zErrMsg);
      END_TIMER;
      if( rc || zErrMsg ){
        char zPrefix[100];
        if( in!=0 || !stdin_is_interactive ){
          sqlite3_snprintf(sizeof(zPrefix), zPrefix, 
                           "Error: near line %d:", startline);
        }else{
          sqlite3_snprintf(sizeof(zPrefix), zPrefix, "Error:");
        }
        if( zErrMsg!=0 ){
          utf8_printf(stderr, "%s %s\n", zPrefix, zErrMsg);
          sqlite3_free(zErrMsg);
          zErrMsg = 0;
        }else{
          utf8_printf(stderr, "%s %s\n", zPrefix, sqlite3_errmsg(p->db));
        }
        errCnt++;
      }else if( p->countChanges ){
        raw_printf(p->out, "changes: %3d   total_changes: %d\n",
                sqlite3_changes(p->db), sqlite3_total_changes(p->db));
      }
      nSql = 0;
      if( p->outCount ){
        output_reset(p);
        p->outCount = 0;
      }
    }else if( nSql && _all_whitespace(zSql) ){
      if( p->echoOn ) printf("%s\n", zSql);
      nSql = 0;
    }
  }
  if( nSql ){
    if( !_all_whitespace(zSql) ){
      utf8_printf(stderr, "Error: incomplete SQL: %s\n", zSql);
      errCnt++;
    }
  }
  free(zSql);
  free(zLine);
  return errCnt>0;
}

/*
** Return a pathname which is the user's home directory.  A
** 0 return indicates an error of some kind.
*/
static char *find_home_dir(void){
  static char *home_dir = NULL;
  if( home_dir ) return home_dir;

#if !defined(_WIN32) && !defined(WIN32) && !defined(_WIN32_WCE) \
     && !defined(__RTP__) && !defined(_WRS_KERNEL)
  {
    struct passwd *pwent;
    uid_t uid = getuid();
    if( (pwent=getpwuid(uid)) != NULL) {
      home_dir = pwent->pw_dir;
    }
  }
#endif

#if defined(_WIN32_WCE)
  /* Windows CE (arm-wince-mingw32ce-gcc) does not provide getenv()
   */
  home_dir = "/";
#else

#if defined(_WIN32) || defined(WIN32)
  if (!home_dir) {
    home_dir = getenv("USERPROFILE");
  }
#endif

  if (!home_dir) {
    home_dir = getenv("HOME");
  }

#if defined(_WIN32) || defined(WIN32)
  if (!home_dir) {
    char *zDrive, *zPath;
    int n;
    zDrive = getenv("HOMEDRIVE");
    zPath = getenv("HOMEPATH");
    if( zDrive && zPath ){
      n = strlen30(zDrive) + strlen30(zPath) + 1;
      home_dir = malloc( n );
      if( home_dir==0 ) return 0;
      sqlite3_snprintf(n, home_dir, "%s%s", zDrive, zPath);
      return home_dir;
    }
    home_dir = "c:\\";
  }
#endif

#endif /* !_WIN32_WCE */

  if( home_dir ){
    int n = strlen30(home_dir) + 1;
    char *z = malloc( n );
    if( z ) memcpy(z, home_dir, n);
    home_dir = z;
  }

  return home_dir;
}

/*
** Read input from the file given by sqliterc_override.  Or if that
** parameter is NULL, take input from ~/.sqliterc
**
** Returns the number of errors.
*/
static void process_sqliterc(
  ShellState *p,                  /* Configuration data */
  const char *sqliterc_override   /* Name of config file. NULL to use default */
){
  char *home_dir = NULL;
  const char *sqliterc = sqliterc_override;
  char *zBuf = 0;
  FILE *in = NULL;

  if (sqliterc == NULL) {
    home_dir = find_home_dir();
    if( home_dir==0 ){
      raw_printf(stderr, "-- warning: cannot find home directory;"
                      " cannot read ~/.sqliterc\n");
      return;
    }
    sqlite3_initialize();
    zBuf = sqlite3_mprintf("%s/.sqliterc",home_dir);
    sqliterc = zBuf;
  }
  in = fopen(sqliterc,"rb");
  if( in ){
    if( stdin_is_interactive ){
      utf8_printf(stderr,"-- Loading resources from %s\n",sqliterc);
    }
    process_input(p,in);
    fclose(in);
  }
  sqlite3_free(zBuf);
}

/*
** Show available command line options
*/
static const char zOptions[] = 
  "   -ascii               set output mode to 'ascii'\n"
  "   -bail                stop after hitting an error\n"
  "   -batch               force batch I/O\n"
  "   -column              set output mode to 'column'\n"
  "   -cmd COMMAND         run \"COMMAND\" before reading stdin\n"
  "   -csv                 set output mode to 'csv'\n"
  "   -echo                print commands before execution\n"
  "   -init FILENAME       read/process named file\n"
  "   -[no]header          turn headers on or off\n"
#if defined(SQLITE_ENABLE_MEMSYS3) || defined(SQLITE_ENABLE_MEMSYS5)
  "   -heap SIZE           Size of heap for memsys3 or memsys5\n"
#endif
  "   -help                show this message\n"
  "   -html                set output mode to HTML\n"
  "   -interactive         force interactive I/O\n"
  "   -line                set output mode to 'line'\n"
  "   -list                set output mode to 'list'\n"
  "   -lookaside SIZE N    use N entries of SZ bytes for lookaside memory\n"
  "   -mmap N              default mmap size set to N\n"
#ifdef SQLITE_ENABLE_MULTIPLEX
  "   -multiplex           enable the multiplexor VFS\n"
#endif
  "   -newline SEP         set output row separator. Default: '\\n'\n"
  "   -nullvalue TEXT      set text string for NULL values. Default ''\n"
  "   -pagecache SIZE N    use N slots of SZ bytes each for page cache memory\n"
  "   -scratch SIZE N      use N slots of SZ bytes each for scratch memory\n"
  "   -separator SEP       set output column separator. Default: '|'\n"
  "   -stats               print memory stats before each finalize\n"
  "   -version             show SQLite version\n"
  "   -vfs NAME            use NAME as the default VFS\n"
#ifdef SQLITE_ENABLE_VFSTRACE
  "   -vfstrace            enable tracing of all VFS calls\n"
#endif
;
static void usage(int showDetail){
  utf8_printf(stderr,
      "Usage: %s [OPTIONS] FILENAME [SQL]\n"  
      "FILENAME is the name of an SQLite database. A new database is created\n"
      "if the file does not previously exist.\n", Argv0);
  if( showDetail ){
    utf8_printf(stderr, "OPTIONS include:\n%s", zOptions);
  }else{
    raw_printf(stderr, "Use the -help option for additional information\n");
  }
  exit(1);
}

/*
** Initialize the state information in data
*/
static void main_init(ShellState *data) {
  memset(data, 0, sizeof(*data));
  data->normalMode = data->cMode = data->mode = MODE_List;
  data->autoExplain = 1;
  memcpy(data->colSeparator,SEP_Column, 2);
  memcpy(data->rowSeparator,SEP_Row, 2);
  data->showHeader = 0;
  data->shellFlgs = SHFLG_Lookaside;
  sqlite3_config(SQLITE_CONFIG_URI, 1);
  sqlite3_config(SQLITE_CONFIG_LOG, shellLog, data);
  sqlite3_config(SQLITE_CONFIG_MULTITHREAD);
  sqlite3_snprintf(sizeof(mainPrompt), mainPrompt,"sqlite> ");
  sqlite3_snprintf(sizeof(continuePrompt), continuePrompt,"   ...> ");
}

/*
** Output text to the console in a font that attracts extra attention.
*/
#ifdef _WIN32
static void printBold(const char *zText){
  HANDLE out = GetStdHandle(STD_OUTPUT_HANDLE);
  CONSOLE_SCREEN_BUFFER_INFO defaultScreenInfo;
  GetConsoleScreenBufferInfo(out, &defaultScreenInfo);
  SetConsoleTextAttribute(out,
         FOREGROUND_RED|FOREGROUND_INTENSITY
  );
  printf("%s", zText);
  SetConsoleTextAttribute(out, defaultScreenInfo.wAttributes);
}
#else
static void printBold(const char *zText){
  printf("\033[1m%s\033[0m", zText);
}
#endif

/*
** Get the argument to an --option.  Throw an error and die if no argument
** is available.
*/
static char *cmdline_option_value(int argc, char **argv, int i){
  if( i==argc ){
    utf8_printf(stderr, "%s: Error: missing argument to %s\n",
            argv[0], argv[argc-1]);
    exit(1);
  }
  return argv[i];
}

int SQLITE_CDECL main(int argc, char **argv){
  char *zErrMsg = 0;
  ShellState data;
  const char *zInitFile = 0;
  int i;
  int rc = 0;
  int warnInmemoryDb = 0;
  int readStdin = 1;
  int nCmd = 0;
  char **azCmd = 0;

#if USE_SYSTEM_SQLITE+0!=1
  if( strcmp(sqlite3_sourceid(),SQLITE_SOURCE_ID)!=0 ){
    utf8_printf(stderr, "SQLite header and source version mismatch\n%s\n%s\n",
            sqlite3_sourceid(), SQLITE_SOURCE_ID);
    exit(1);
  }
#endif
  setBinaryMode(stdin);
  setvbuf(stderr, 0, _IONBF, 0); /* Make sure stderr is unbuffered */
  Argv0 = argv[0];
  main_init(&data);
  stdin_is_interactive = isatty(0);
  stdout_is_console = isatty(1);

  /* Make sure we have a valid signal handler early, before anything
  ** else is done.
  */
#ifdef SIGINT
  signal(SIGINT, interrupt_handler);
#endif

#ifdef SQLITE_SHELL_DBNAME_PROC
  {
    /* If the SQLITE_SHELL_DBNAME_PROC macro is defined, then it is the name
    ** of a C-function that will provide the name of the database file.  Use
    ** this compile-time option to embed this shell program in larger
    ** applications. */
    extern void SQLITE_SHELL_DBNAME_PROC(const char**);
    SQLITE_SHELL_DBNAME_PROC(&data.zDbFilename);
    warnInmemoryDb = 0;
  }
#endif

  /* Do an initial pass through the command-line argument to locate
  ** the name of the database file, the name of the initialization file,
  ** the size of the alternative malloc heap,
  ** and the first command to execute.
  */
  for(i=1; i<argc; i++){
    char *z;
    z = argv[i];
    if( z[0]!='-' ){
      if( data.zDbFilename==0 ){
        data.zDbFilename = z;
      }else{
        /* Excesss arguments are interpreted as SQL (or dot-commands) and
        ** mean that nothing is read from stdin */
        readStdin = 0;
        nCmd++;
        azCmd = realloc(azCmd, sizeof(azCmd[0])*nCmd);
        if( azCmd==0 ){
          raw_printf(stderr, "out of memory\n");
          exit(1);
        }
        azCmd[nCmd-1] = z;
      }
    }
    if( z[1]=='-' ) z++;
    if( strcmp(z,"-separator")==0
     || strcmp(z,"-nullvalue")==0
     || strcmp(z,"-newline")==0
     || strcmp(z,"-cmd")==0
    ){
      (void)cmdline_option_value(argc, argv, ++i);
    }else if( strcmp(z,"-init")==0 ){
      zInitFile = cmdline_option_value(argc, argv, ++i);
    }else if( strcmp(z,"-batch")==0 ){
      /* Need to check for batch mode here to so we can avoid printing
      ** informational messages (like from process_sqliterc) before 
      ** we do the actual processing of arguments later in a second pass.
      */
      stdin_is_interactive = 0;
    }else if( strcmp(z,"-heap")==0 ){
#if defined(SQLITE_ENABLE_MEMSYS3) || defined(SQLITE_ENABLE_MEMSYS5)
      const char *zSize;
      sqlite3_int64 szHeap;

      zSize = cmdline_option_value(argc, argv, ++i);
      szHeap = integerValue(zSize);
      if( szHeap>0x7fff0000 ) szHeap = 0x7fff0000;
      sqlite3_config(SQLITE_CONFIG_HEAP, malloc((int)szHeap), (int)szHeap, 64);
#endif
    }else if( strcmp(z,"-scratch")==0 ){
      int n, sz;
      sz = (int)integerValue(cmdline_option_value(argc,argv,++i));
      if( sz>400000 ) sz = 400000;
      if( sz<2500 ) sz = 2500;
      n = (int)integerValue(cmdline_option_value(argc,argv,++i));
      if( n>10 ) n = 10;
      if( n<1 ) n = 1;
      sqlite3_config(SQLITE_CONFIG_SCRATCH, malloc(n*sz+1), sz, n);
      data.shellFlgs |= SHFLG_Scratch;
    }else if( strcmp(z,"-pagecache")==0 ){
      int n, sz;
      sz = (int)integerValue(cmdline_option_value(argc,argv,++i));
      if( sz>70000 ) sz = 70000;
      if( sz<0 ) sz = 0;
      n = (int)integerValue(cmdline_option_value(argc,argv,++i));
      sqlite3_config(SQLITE_CONFIG_PAGECACHE,
                    (n>0 && sz>0) ? malloc(n*sz) : 0, sz, n);
      data.shellFlgs |= SHFLG_Pagecache;
    }else if( strcmp(z,"-lookaside")==0 ){
      int n, sz;
      sz = (int)integerValue(cmdline_option_value(argc,argv,++i));
      if( sz<0 ) sz = 0;
      n = (int)integerValue(cmdline_option_value(argc,argv,++i));
      if( n<0 ) n = 0;
      sqlite3_config(SQLITE_CONFIG_LOOKASIDE, sz, n);
      if( sz*n==0 ) data.shellFlgs &= ~SHFLG_Lookaside;
#ifdef SQLITE_ENABLE_VFSTRACE
    }else if( strcmp(z,"-vfstrace")==0 ){
      extern int vfstrace_register(
         const char *zTraceName,
         const char *zOldVfsName,
         int (*xOut)(const char*,void*),
         void *pOutArg,
         int makeDefault
      );
      vfstrace_register("trace",0,(int(*)(const char*,void*))fputs,stderr,1);
#endif
#ifdef SQLITE_ENABLE_MULTIPLEX
    }else if( strcmp(z,"-multiplex")==0 ){
      extern int sqlite3_multiple_initialize(const char*,int);
      sqlite3_multiplex_initialize(0, 1);
#endif
    }else if( strcmp(z,"-mmap")==0 ){
      sqlite3_int64 sz = integerValue(cmdline_option_value(argc,argv,++i));
      sqlite3_config(SQLITE_CONFIG_MMAP_SIZE, sz, sz);
    }else if( strcmp(z,"-vfs")==0 ){
      sqlite3_vfs *pVfs = sqlite3_vfs_find(cmdline_option_value(argc,argv,++i));
      if( pVfs ){
        sqlite3_vfs_register(pVfs, 1);
      }else{
        utf8_printf(stderr, "no such VFS: \"%s\"\n", argv[i]);
        exit(1);
      }
    }
  }
  if( data.zDbFilename==0 ){
#ifndef SQLITE_OMIT_MEMORYDB
    data.zDbFilename = ":memory:";
    warnInmemoryDb = argc==1;
#else
    utf8_printf(stderr,"%s: Error: no database filename specified\n", Argv0);
    return 1;
#endif
  }
  data.out = stdout;

  /* Go ahead and open the database file if it already exists.  If the
  ** file does not exist, delay opening it.  This prevents empty database
  ** files from being created if a user mistypes the database name argument
  ** to the sqlite command-line tool.
  */
  if( access(data.zDbFilename, 0)==0 ){
    open_db(&data, 0);
  }

  /* Process the initialization file if there is one.  If no -init option
  ** is given on the command line, look for a file named ~/.sqliterc and
  ** try to process it.
  */
  process_sqliterc(&data,zInitFile);

  /* Make a second pass through the command-line argument and set
  ** options.  This second pass is delayed until after the initialization
  ** file is processed so that the command-line arguments will override
  ** settings in the initialization file.
  */
  for(i=1; i<argc; i++){
    char *z = argv[i];
    if( z[0]!='-' ) continue;
    if( z[1]=='-' ){ z++; }
    if( strcmp(z,"-init")==0 ){
      i++;
    }else if( strcmp(z,"-html")==0 ){
      data.mode = MODE_Html;
    }else if( strcmp(z,"-list")==0 ){
      data.mode = MODE_List;
    }else if( strcmp(z,"-line")==0 ){
      data.mode = MODE_Line;
    }else if( strcmp(z,"-column")==0 ){
      data.mode = MODE_Column;
    }else if( strcmp(z,"-csv")==0 ){
      data.mode = MODE_Csv;
      memcpy(data.colSeparator,",",2);
    }else if( strcmp(z,"-ascii")==0 ){
      data.mode = MODE_Ascii;
      sqlite3_snprintf(sizeof(data.colSeparator), data.colSeparator,
                       SEP_Unit);
      sqlite3_snprintf(sizeof(data.rowSeparator), data.rowSeparator,
                       SEP_Record);
    }else if( strcmp(z,"-separator")==0 ){
      sqlite3_snprintf(sizeof(data.colSeparator), data.colSeparator,
                       "%s",cmdline_option_value(argc,argv,++i));
    }else if( strcmp(z,"-newline")==0 ){
      sqlite3_snprintf(sizeof(data.rowSeparator), data.rowSeparator,
                       "%s",cmdline_option_value(argc,argv,++i));
    }else if( strcmp(z,"-nullvalue")==0 ){
      sqlite3_snprintf(sizeof(data.nullValue), data.nullValue,
                       "%s",cmdline_option_value(argc,argv,++i));
    }else if( strcmp(z,"-header")==0 ){
      data.showHeader = 1;
    }else if( strcmp(z,"-noheader")==0 ){
      data.showHeader = 0;
    }else if( strcmp(z,"-echo")==0 ){
      data.echoOn = 1;
    }else if( strcmp(z,"-eqp")==0 ){
      data.autoEQP = 1;
    }else if( strcmp(z,"-stats")==0 ){
      data.statsOn = 1;
    }else if( strcmp(z,"-scanstats")==0 ){
      data.scanstatsOn = 1;
    }else if( strcmp(z,"-backslash")==0 ){
      /* Undocumented command-line option: -backslash
      ** Causes C-style backslash escapes to be evaluated in SQL statements
      ** prior to sending the SQL into SQLite.  Useful for injecting
      ** crazy bytes in the middle of SQL statements for testing and debugging.
      */
      data.backslashOn = 1;
    }else if( strcmp(z,"-bail")==0 ){
      bail_on_error = 1;
    }else if( strcmp(z,"-version")==0 ){
      printf("%s %s\n", sqlite3_libversion(), sqlite3_sourceid());
      return 0;
    }else if( strcmp(z,"-interactive")==0 ){
      stdin_is_interactive = 1;
    }else if( strcmp(z,"-batch")==0 ){
      stdin_is_interactive = 0;
    }else if( strcmp(z,"-heap")==0 ){
      i++;
    }else if( strcmp(z,"-scratch")==0 ){
      i+=2;
    }else if( strcmp(z,"-pagecache")==0 ){
      i+=2;
    }else if( strcmp(z,"-lookaside")==0 ){
      i+=2;
    }else if( strcmp(z,"-mmap")==0 ){
      i++;
    }else if( strcmp(z,"-vfs")==0 ){
      i++;
#ifdef SQLITE_ENABLE_VFSTRACE
    }else if( strcmp(z,"-vfstrace")==0 ){
      i++;
#endif
#ifdef SQLITE_ENABLE_MULTIPLEX
    }else if( strcmp(z,"-multiplex")==0 ){
      i++;
#endif
    }else if( strcmp(z,"-help")==0 ){
      usage(1);
    }else if( strcmp(z,"-cmd")==0 ){
      /* Run commands that follow -cmd first and separately from commands
      ** that simply appear on the command-line.  This seems goofy.  It would
      ** be better if all commands ran in the order that they appear.  But
      ** we retain the goofy behavior for historical compatibility. */
      if( i==argc-1 ) break;
      z = cmdline_option_value(argc,argv,++i);
      if( z[0]=='.' ){
        rc = do_meta_command(z, &data);
        if( rc && bail_on_error ) return rc==2 ? 0 : rc;
      }else{
        open_db(&data, 0);
        rc = shell_exec(data.db, z, shell_callback, &data, &zErrMsg);
        if( zErrMsg!=0 ){
          utf8_printf(stderr,"Error: %s\n", zErrMsg);
          if( bail_on_error ) return rc!=0 ? rc : 1;
        }else if( rc!=0 ){
          utf8_printf(stderr,"Error: unable to process SQL \"%s\"\n", z);
          if( bail_on_error ) return rc;
        }
      }
    }else{
      utf8_printf(stderr,"%s: Error: unknown option: %s\n", Argv0, z);
      raw_printf(stderr,"Use -help for a list of options.\n");
      return 1;
    }
    data.cMode = data.mode;
  }

  if( !readStdin ){
    /* Run all arguments that do not begin with '-' as if they were separate
    ** command-line inputs, except for the argToSkip argument which contains
    ** the database filename.
    */
    for(i=0; i<nCmd; i++){
      if( azCmd[i][0]=='.' ){
        rc = do_meta_command(azCmd[i], &data);
        if( rc ) return rc==2 ? 0 : rc;
      }else{
        open_db(&data, 0);
        rc = shell_exec(data.db, azCmd[i], shell_callback, &data, &zErrMsg);
        if( zErrMsg!=0 ){
          utf8_printf(stderr,"Error: %s\n", zErrMsg);
          return rc!=0 ? rc : 1;
        }else if( rc!=0 ){
          utf8_printf(stderr,"Error: unable to process SQL: %s\n", azCmd[i]);
          return rc;
        }
      }
    }
    free(azCmd);
  }else{
    /* Run commands received from standard input
    */
    if( stdin_is_interactive ){
      char *zHome;
      char *zHistory = 0;
      int nHistory;
      printf(
        "SQLite version %s %.19s\n" /*extra-version-info*/
        "Enter \".help\" for usage hints.\n",
        sqlite3_libversion(), sqlite3_sourceid()
      );
      if( warnInmemoryDb ){
        printf("Connected to a ");
        printBold("transient in-memory database");
        printf(".\nUse \".open FILENAME\" to reopen on a "
               "persistent database.\n");
      }
      zHome = find_home_dir();
      if( zHome ){
        nHistory = strlen30(zHome) + 20;
        if( (zHistory = malloc(nHistory))!=0 ){
          sqlite3_snprintf(nHistory, zHistory,"%s/.sqlite_history", zHome);
        }
      }
      if( zHistory ){ shell_read_history(zHistory); }
      rc = process_input(&data, 0);
      if( zHistory ){
        shell_stifle_history(100);
        shell_write_history(zHistory);
        free(zHistory);
      }
    }else{
      rc = process_input(&data, stdin);
    }
  }
  set_table_name(&data, 0);
  if( data.db ){
    sqlite3_close(data.db);
  }
  sqlite3_free(data.zFreeOnClose); 
  return rc;
}


================================================
FILE: ext/SQLite/sqlite3.c
================================================
/******************************************************************************
** This file is an amalgamation of many separate C source files from SQLite
** version 3.12.0.  By combining all the individual C code files into this 
** single large file, the entire code can be compiled as a single translation
** unit.  This allows many compilers to do optimizations that would not be
** possible if the files were compiled separately.  Performance improvements
** of 5% or more are commonly seen when SQLite is compiled as a single
** translation unit.
**
** This file is all you need to compile SQLite.  To use SQLite in other
** programs, you need this file and the "sqlite3.h" header file that defines
** the programming interface to the SQLite library.  (If you do not have 
** the "sqlite3.h" header file at hand, you will find a copy embedded within
** the text of this file.  Search for "Begin file sqlite3.h" to find the start
** of the embedded sqlite3.h header file.) Additional code files may be needed
** if you want a wrapper to interface SQLite with your choice of programming
** language. The code for the "sqlite3" command-line shell is also in a
** separate file. This file contains only code for the core SQLite library.
*/
#define SQLITE_CORE 1
#define SQLITE_AMALGAMATION 1
#ifndef SQLITE_PRIVATE
# define SQLITE_PRIVATE static
#endif
/************** Begin file sqliteInt.h ***************************************/
/*
** 2001 September 15
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** Internal interface definitions for SQLite.
**
*/
#ifndef _SQLITEINT_H_
#define _SQLITEINT_H_

/*
** Make sure that rand_s() is available on Windows systems with MSVC 2005
** or higher.
*/
#if defined(_MSC_VER) && _MSC_VER>=1400
#  define _CRT_RAND_S
#endif

/*
** Include the header file used to customize the compiler options for MSVC.
** This should be done first so that it can successfully prevent spurious
** compiler warnings due to subsequent content in this file and other files
** that are included by this file.
*/
/************** Include msvc.h in the middle of sqliteInt.h ******************/
/************** Begin file msvc.h ********************************************/
/*
** 2015 January 12
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
******************************************************************************
**
** This file contains code that is specific to MSVC.
*/
#ifndef _MSVC_H_
#define _MSVC_H_

#if defined(_MSC_VER)
#pragma warning(disable : 4054)
#pragma warning(disable : 4055)
#pragma warning(disable : 4100)
#pragma warning(disable : 4127)
#pragma warning(disable : 4130)
#pragma warning(disable : 4152)
#pragma warning(disable : 4189)
#pragma warning(disable : 4206)
#pragma warning(disable : 4210)
#pragma warning(disable : 4232)
#pragma warning(disable : 4244)
#pragma warning(disable : 4305)
#pragma warning(disable : 4306)
#pragma warning(disable : 4702)
#pragma warning(disable : 4706)
#endif /* defined(_MSC_VER) */

#endif /* _MSVC_H_ */

/************** End of msvc.h ************************************************/
/************** Continuing where we left off in sqliteInt.h ******************/

/*
** Special setup for VxWorks
*/
/************** Include vxworks.h in the middle of sqliteInt.h ***************/
/************** Begin file vxworks.h *****************************************/
/*
** 2015-03-02
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
******************************************************************************
**
** This file contains code that is specific to Wind River's VxWorks
*/
#if defined(__RTP__) || defined(_WRS_KERNEL)
/* This is VxWorks.  Set up things specially for that OS
*/
#include <vxWorks.h>
#include <pthread.h>  /* amalgamator: dontcache */
#define OS_VXWORKS 1
#define SQLITE_OS_OTHER 0
#define SQLITE_HOMEGROWN_RECURSIVE_MUTEX 1
#define SQLITE_OMIT_LOAD_EXTENSION 1
#define SQLITE_ENABLE_LOCKING_STYLE 0
#define HAVE_UTIME 1
#else
/* This is not VxWorks. */
#define OS_VXWORKS 0
#define HAVE_FCHOWN 1
#define HAVE_READLINK 1
#define HAVE_LSTAT 1
#endif /* defined(_WRS_KERNEL) */

/************** End of vxworks.h *********************************************/
/************** Continuing where we left off in sqliteInt.h ******************/

/*
** These #defines should enable >2GB file support on POSIX if the
** underlying operating system supports it.  If the OS lacks
** large file support, or if the OS is windows, these should be no-ops.
**
** Ticket #2739:  The _LARGEFILE_SOURCE macro must appear before any
** system #includes.  Hence, this block of code must be the very first
** code in all source files.
**
** Large file support can be disabled using the -DSQLITE_DISABLE_LFS switch
** on the compiler command line.  This is necessary if you are compiling
** on a recent machine (ex: Red Hat 7.2) but you want your code to work
** on an older machine (ex: Red Hat 6.0).  If you compile on Red Hat 7.2
** without this option, LFS is enable.  But LFS does not exist in the kernel
** in Red Hat 6.0, so the code won't work.  Hence, for maximum binary
** portability you should omit LFS.
**
** The previous paragraph was written in 2005.  (This paragraph is written
** on 2008-11-28.) These days, all Linux kernels support large files, so
** you should probably leave LFS enabled.  But some embedded platforms might
** lack LFS in which case the SQLITE_DISABLE_LFS macro might still be useful.
**
** Similar is true for Mac OS X.  LFS is only supported on Mac OS X 9 and later.
*/
#ifndef SQLITE_DISABLE_LFS
# define _LARGE_FILE       1
# ifndef _FILE_OFFSET_BITS
#   define _FILE_OFFSET_BITS 64
# endif
# define _LARGEFILE_SOURCE 1
#endif

/* What version of GCC is being used.  0 means GCC is not being used */
#ifdef __GNUC__
# define GCC_VERSION (__GNUC__*1000000+__GNUC_MINOR__*1000+__GNUC_PATCHLEVEL__)
#else
# define GCC_VERSION 0
#endif

/* Needed for various definitions... */
#if defined(__GNUC__) && !defined(_GNU_SOURCE)
# define _GNU_SOURCE
#endif

#if defined(__OpenBSD__) && !defined(_BSD_SOURCE)
# define _BSD_SOURCE
#endif

/*
** For MinGW, check to see if we can include the header file containing its
** version information, among other things.  Normally, this internal MinGW
** header file would [only] be included automatically by other MinGW header
** files; however, the contained version information is now required by this
** header file to work around binary compatibility issues (see below) and
** this is the only known way to reliably obtain it.  This entire #if block
** would be completely unnecessary if there was any other way of detecting
** MinGW via their preprocessor (e.g. if they customized their GCC to define
** some MinGW-specific macros).  When compiling for MinGW, either the
** _HAVE_MINGW_H or _HAVE__MINGW_H (note the extra underscore) macro must be
** defined; otherwise, detection of conditions specific to MinGW will be
** disabled.
*/
#if defined(_HAVE_MINGW_H)
# include "mingw.h"
#elif defined(_HAVE__MINGW_H)
# include "_mingw.h"
#endif

/*
** For MinGW version 4.x (and higher), check to see if the _USE_32BIT_TIME_T
** define is required to maintain binary compatibility with the MSVC runtime
** library in use (e.g. for Windows XP).
*/
#if !defined(_USE_32BIT_TIME_T) && !defined(_USE_64BIT_TIME_T) && \
    defined(_WIN32) && !defined(_WIN64) && \
    defined(__MINGW_MAJOR_VERSION) && __MINGW_MAJOR_VERSION >= 4 && \
    defined(__MSVCRT__)
# define _USE_32BIT_TIME_T
#endif

/* The public SQLite interface.  The _FILE_OFFSET_BITS macro must appear
** first in QNX.  Also, the _USE_32BIT_TIME_T macro must appear first for
** MinGW.
*/
/************** Include sqlite3.h in the middle of sqliteInt.h ***************/
/************** Begin file sqlite3.h *****************************************/
/*
** 2001 September 15
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This header file defines the interface that the SQLite library
** presents to client programs.  If a C-function, structure, datatype,
** or constant definition does not appear in this file, then it is
** not a published API of SQLite, is subject to change without
** notice, and should not be referenced by programs that use SQLite.
**
** Some of the definitions that are in this file are marked as
** "experimental".  Experimental interfaces are normally new
** features recently added to SQLite.  We do not anticipate changes
** to experimental interfaces but reserve the right to make minor changes
** if experience from use "in the wild" suggest such changes are prudent.
**
** The official C-language API documentation for SQLite is derived
** from comments in this file.  This file is the authoritative source
** on how SQLite interfaces are supposed to operate.
**
** The name of this file under configuration management is "sqlite.h.in".
** The makefile makes some minor changes to this file (such as inserting
** the version number) and changes its name to "sqlite3.h" as
** part of the build process.
*/
#ifndef _SQLITE3_H_
#define _SQLITE3_H_
#include <stdarg.h>     /* Needed for the definition of va_list */

/*
** Make sure we can call this stuff from C++.
*/
#if 0
extern "C" {
#endif


/*
** Provide the ability to override linkage features of the interface.
*/
#ifndef SQLITE_EXTERN
# define SQLITE_EXTERN extern
#endif
#ifndef SQLITE_API
# define SQLITE_API
#endif
#ifndef SQLITE_CDECL
# define SQLITE_CDECL
#endif
#ifndef SQLITE_STDCALL
# define SQLITE_STDCALL
#endif

/*
** These no-op macros are used in front of interfaces to mark those
** interfaces as either deprecated or experimental.  New applications
** should not use deprecated interfaces - they are supported for backwards
** compatibility only.  Application writers should be aware that
** experimental interfaces are subject to change in point releases.
**
** These macros used to resolve to various kinds of compiler magic that
** would generate warning messages when they were used.  But that
** compiler magic ended up generating such a flurry of bug reports
** that we have taken it all out and gone back to using simple
** noop macros.
*/
#define SQLITE_DEPRECATED
#define SQLITE_EXPERIMENTAL

/*
** Ensure these symbols were not defined by some previous header file.
*/
#ifdef SQLITE_VERSION
# undef SQLITE_VERSION
#endif
#ifdef SQLITE_VERSION_NUMBER
# undef SQLITE_VERSION_NUMBER
#endif

/*
** CAPI3REF: Compile-Time Library Version Numbers
**
** ^(The [SQLITE_VERSION] C preprocessor macro in the sqlite3.h header
** evaluates to a string literal that is the SQLite version in the
** format "X.Y.Z" where X is the major version number (always 3 for
** SQLite3) and Y is the minor version number and Z is the release number.)^
** ^(The [SQLITE_VERSION_NUMBER] C preprocessor macro resolves to an integer
** with the value (X*1000000 + Y*1000 + Z) where X, Y, and Z are the same
** numbers used in [SQLITE_VERSION].)^
** The SQLITE_VERSION_NUMBER for any given release of SQLite will also
** be larger than the release from which it is derived.  Either Y will
** be held constant and Z will be incremented or else Y will be incremented
** and Z will be reset to zero.
**
** Since version 3.6.18, SQLite source code has been stored in the
** <a href="http://www.fossil-scm.org/">Fossil configuration management
** system</a>.  ^The SQLITE_SOURCE_ID macro evaluates to
** a string which identifies a particular check-in of SQLite
** within its configuration management system.  ^The SQLITE_SOURCE_ID
** string contains the date and time of the check-in (UTC) and an SHA1
** hash of the entire source tree.
**
** See also: [sqlite3_libversion()],
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
** [sqlite_version()] and [sqlite_source_id()].
*/
#define SQLITE_VERSION        "3.12.0"
#define SQLITE_VERSION_NUMBER 3012000
#define SQLITE_SOURCE_ID      "2016-03-29 10:14:15 e9bb4cf40f4971974a74468ef922bdee481c988b"

/*
** CAPI3REF: Run-Time Library Version Numbers
** KEYWORDS: sqlite3_version, sqlite3_sourceid
**
** These interfaces provide the same information as the [SQLITE_VERSION],
** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros
** but are associated with the library instead of the header file.  ^(Cautious
** programmers might include assert() statements in their application to
** verify that values returned by these interfaces match the macros in
** the header, and thus ensure that the application is
** compiled with matching library and header files.
**
** <blockquote><pre>
** assert( sqlite3_libversion_number()==SQLITE_VERSION_NUMBER );
** assert( strcmp(sqlite3_sourceid(),SQLITE_SOURCE_ID)==0 );
** assert( strcmp(sqlite3_libversion(),SQLITE_VERSION)==0 );
** </pre></blockquote>)^
**
** ^The sqlite3_version[] string constant contains the text of [SQLITE_VERSION]
** macro.  ^The sqlite3_libversion() function returns a pointer to the
** to the sqlite3_version[] string constant.  The sqlite3_libversion()
** function is provided for use in DLLs since DLL users usually do not have
** direct access to string constants within the DLL.  ^The
** sqlite3_libversion_number() function returns an integer equal to
** [SQLITE_VERSION_NUMBER].  ^The sqlite3_sourceid() function returns 
** a pointer to a string constant whose value is the same as the 
** [SQLITE_SOURCE_ID] C preprocessor macro.
**
** See also: [sqlite_version()] and [sqlite_source_id()].
*/
SQLITE_API const char sqlite3_version[] = SQLITE_VERSION;
SQLITE_API const char *SQLITE_STDCALL sqlite3_libversion(void);
SQLITE_API const char *SQLITE_STDCALL sqlite3_sourceid(void);
SQLITE_API int SQLITE_STDCALL sqlite3_libversion_number(void);

/*
** CAPI3REF: Run-Time Library Compilation Options Diagnostics
**
** ^The sqlite3_compileoption_used() function returns 0 or 1 
** indicating whether the specified option was defined at 
** compile time.  ^The SQLITE_ prefix may be omitted from the 
** option name passed to sqlite3_compileoption_used().  
**
** ^The sqlite3_compileoption_get() function allows iterating
** over the list of options that were defined at compile time by
** returning the N-th compile time option string.  ^If N is out of range,
** sqlite3_compileoption_get() returns a NULL pointer.  ^The SQLITE_ 
** prefix is omitted from any strings returned by 
** sqlite3_compileoption_get().
**
** ^Support for the diagnostic functions sqlite3_compileoption_used()
** and sqlite3_compileoption_get() may be omitted by specifying the 
** [SQLITE_OMIT_COMPILEOPTION_DIAGS] option at compile time.
**
** See also: SQL functions [sqlite_compileoption_used()] and
** [sqlite_compileoption_get()] and the [compile_options pragma].
*/
#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
SQLITE_API int SQLITE_STDCALL sqlite3_compileoption_used(const char *zOptName);
SQLITE_API const char *SQLITE_STDCALL sqlite3_compileoption_get(int N);
#endif

/*
** CAPI3REF: Test To See If The Library Is Threadsafe
**
** ^The sqlite3_threadsafe() function returns zero if and only if
** SQLite was compiled with mutexing code omitted due to the
** [SQLITE_THREADSAFE] compile-time option being set to 0.
**
** SQLite can be compiled with or without mutexes.  When
** the [SQLITE_THREADSAFE] C preprocessor macro is 1 or 2, mutexes
** are enabled and SQLite is threadsafe.  When the
** [SQLITE_THREADSAFE] macro is 0, 
** the mutexes are omitted.  Without the mutexes, it is not safe
** to use SQLite concurrently from more than one thread.
**
** Enabling mutexes incurs a measurable performance penalty.
** So if speed is of utmost importance, it makes sense to disable
** the mutexes.  But for maximum safety, mutexes should be enabled.
** ^The default behavior is for mutexes to be enabled.
**
** This interface can be used by an application to make sure that the
** version of SQLite that it is linking against was compiled with
** the desired setting of the [SQLITE_THREADSAFE] macro.
**
** This interface only reports on the compile-time mutex setting
** of the [SQLITE_THREADSAFE] flag.  If SQLite is compiled with
** SQLITE_THREADSAFE=1 or =2 then mutexes are enabled by default but
** can be fully or partially disabled using a call to [sqlite3_config()]
** with the verbs [SQLITE_CONFIG_SINGLETHREAD], [SQLITE_CONFIG_MULTITHREAD],
** or [SQLITE_CONFIG_SERIALIZED].  ^(The return value of the
** sqlite3_threadsafe() function shows only the compile-time setting of
** thread safety, not any run-time changes to that setting made by
** sqlite3_config(). In other words, the return value from sqlite3_threadsafe()
** is unchanged by calls to sqlite3_config().)^
**
** See the [threading mode] documentation for additional information.
*/
SQLITE_API int SQLITE_STDCALL sqlite3_threadsafe(void);

/*
** CAPI3REF: Database Connection Handle
** KEYWORDS: {database connection} {database connections}
**
** Each open SQLite database is represented by a pointer to an instance of
** the opaque structure named "sqlite3".  It is useful to think of an sqlite3
** pointer as an object.  The [sqlite3_open()], [sqlite3_open16()], and
** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()]
** and [sqlite3_close_v2()] are its destructors.  There are many other
** interfaces (such as
** [sqlite3_prepare_v2()], [sqlite3_create_function()], and
** [sqlite3_busy_timeout()] to name but three) that are methods on an
** sqlite3 object.
*/
typedef struct sqlite3 sqlite3;

/*
** CAPI3REF: 64-Bit Integer Types
** KEYWORDS: sqlite_int64 sqlite_uint64
**
** Because there is no cross-platform way to specify 64-bit integer types
** SQLite includes typedefs for 64-bit signed and unsigned integers.
**
** The sqlite3_int64 and sqlite3_uint64 are the preferred type definitions.
** The sqlite_int64 and sqlite_uint64 types are supported for backwards
** compatibility only.
**
** ^The sqlite3_int64 and sqlite_int64 types can store integer values
** between -9223372036854775808 and +9223372036854775807 inclusive.  ^The
** sqlite3_uint64 and sqlite_uint64 types can store integer values 
** between 0 and +18446744073709551615 inclusive.
*/
#ifdef SQLITE_INT64_TYPE
  typedef SQLITE_INT64_TYPE sqlite_int64;
  typedef unsigned SQLITE_INT64_TYPE sqlite_uint64;
#elif defined(_MSC_VER) || defined(__BORLANDC__)
  typedef __int64 sqlite_int64;
  typedef unsigned __int64 sqlite_uint64;
#else
  typedef long long int sqlite_int64;
  typedef unsigned long long int sqlite_uint64;
#endif
typedef sqlite_int64 sqlite3_int64;
typedef sqlite_uint64 sqlite3_uint64;

/*
** If compiling for a processor that lacks floating point support,
** substitute integer for floating-point.
*/
#ifdef SQLITE_OMIT_FLOATING_POINT
# define double sqlite3_int64
#endif

/*
** CAPI3REF: Closing A Database Connection
** DESTRUCTOR: sqlite3
**
** ^The sqlite3_close() and sqlite3_close_v2() routines are destructors
** for the [sqlite3] object.
** ^Calls to sqlite3_close() and sqlite3_close_v2() return [SQLITE_OK] if
** the [sqlite3] object is successfully destroyed and all associated
** resources are deallocated.
**
** ^If the database connection is associated with unfinalized prepared
** statements or unfinished sqlite3_backup objects then sqlite3_close()
** will leave the database connection open and return [SQLITE_BUSY].
** ^If sqlite3_close_v2() is called with unfinalized prepared statements
** and/or unfinished sqlite3_backups, then the database connection becomes
** an unusable "zombie" which will automatically be deallocated when the
** last prepared statement is finalized or the last sqlite3_backup is
** finished.  The sqlite3_close_v2() interface is intended for use with
** host languages that are garbage collected, and where the order in which
** destructors are called is arbitrary.
**
** Applications should [sqlite3_finalize | finalize] all [prepared statements],
** [sqlite3_blob_close | close] all [BLOB handles], and 
** [sqlite3_backup_finish | finish] all [sqlite3_backup] objects associated
** with the [sqlite3] object prior to attempting to close the obje
Download .txt
gitextract_vmwbyjbq/

├── .gitignore
├── CMakeLists.txt
├── README.md
├── UnitTest/
│   ├── CMakeLists.txt
│   ├── InitializerTest.cpp
│   ├── MapBuilderTest.cpp
│   ├── RegisterGraphTest.cpp
│   └── TimerTest.cpp
├── config/
│   ├── NEU.yaml
│   ├── gerrard-hall.yaml
│   ├── person-hall.yaml
│   └── south-building.yaml
├── ext/
│   ├── CMakeLists.txt
│   └── SQLite/
│       ├── CMakeLists.txt
│       ├── shell.c
│       ├── sqlite3.c
│       ├── sqlite3.h
│       └── sqlite3ext.h
├── include/
│   ├── Common/
│   │   ├── Timer.h
│   │   └── Types.h
│   ├── Database/
│   │   └── Database.h
│   ├── Exportor/
│   │   ├── Exportor.h
│   │   ├── OpenMVSExportor.h
│   │   ├── OpenMVSInterface.h
│   │   └── PLYExportor.h
│   ├── Feature/
│   │   ├── FeatureExtraction.h
│   │   ├── FeatureMatching.h
│   │   └── FeatureUtils.h
│   ├── Optimizer/
│   │   ├── BundleData.h
│   │   └── CeresBundleOptimizer.h
│   ├── Reconstruction/
│   │   ├── Image.h
│   │   ├── Initializer.h
│   │   ├── Map.h
│   │   ├── MapBuilder.h
│   │   ├── Point2D.h
│   │   ├── Point3D.h
│   │   ├── Projection.h
│   │   ├── RegisterGraph.h
│   │   ├── Registrant.h
│   │   ├── SceneGraph.h
│   │   ├── Track.h
│   │   ├── Triangulator.h
│   │   └── Utils.h
│   └── Visualization/
│       └── Visualization.h
├── pipeline.py
├── sfm/
│   ├── CMakeLists.txt
│   ├── CheckMatches.cpp
│   ├── ComputeMatches.cpp
│   ├── FeatureExtraction.cpp
│   └── Reconstruction.cpp
└── src/
    ├── CMakeLists.txt
    ├── Common/
    │   ├── CMakeLists.txt
    │   └── Timer.cpp
    ├── Database/
    │   ├── CMakeLists.txt
    │   └── Database.cpp
    ├── Estimator/
    │   └── CMakeLists.txt
    ├── Exportor/
    │   ├── CMakeLists.txt
    │   ├── Exportor.cpp
    │   ├── OpenMVSExportor.cpp
    │   └── PLYExportor.cpp
    ├── Feature/
    │   ├── CMakeLists.txt
    │   ├── FeatureExtraction.cpp
    │   ├── FeatureMatching.cpp
    │   └── FeatureUtils.cpp
    ├── Optimizer/
    │   ├── BundleData.cpp
    │   ├── CMakeLists.txt
    │   └── CeresBundleOptimizer.cpp
    ├── Reconstruction/
    │   ├── CMakeLists.txt
    │   ├── Image.cpp
    │   ├── Initializer.cpp
    │   ├── Map.cpp
    │   ├── MapBuilder.cpp
    │   ├── Point2D.cpp
    │   ├── Point3D.cpp
    │   ├── Projection.cpp
    │   ├── RegisterGraph.cpp
    │   ├── Registrant.cpp
    │   ├── SceneGraph.cpp
    │   ├── Track.cpp
    │   ├── Triangulator.cpp
    │   └── Utils.cpp
    └── Visualization/
        ├── CMakeLists.txt
        └── Visualization.cpp
Download .txt
Showing preview only (386K chars total). Download the full file or copy to clipboard to get everything.
SYMBOL INDEX (4383 symbols across 49 files)

FILE: UnitTest/InitializerTest.cpp
  function GetAlignedPointsFromMatches (line 11) | void GetAlignedPointsFromMatches(const std::vector<cv::Point2f>& pts1,
  function main (line 30) | int main()

FILE: UnitTest/MapBuilderTest.cpp
  function main (line 6) | int main()

FILE: UnitTest/RegisterGraphTest.cpp
  function main (line 6) | int main()

FILE: UnitTest/TimerTest.cpp
  function main (line 5) | int main()

FILE: ext/SQLite/shell.c
  function setBinaryMode (line 146) | static void setBinaryMode(FILE *out){
  function setTextMode (line 150) | static void setTextMode(FILE *out){
  function sqlite3_int64 (line 164) | static sqlite3_int64 timeOfDay(void){
  type rusage (line 184) | struct rusage {
  type rusage (line 192) | struct rusage
  function beginTimer (line 198) | static void beginTimer(void){
  function timeDiff (line 206) | static double timeDiff(struct timeval *pStart, struct timeval *pEnd){
  function endTimer (line 214) | static void endTimer(void){
  type LPFILETIME (line 239) | typedef BOOL (WINAPI *GETPROCTIMES)(HANDLE, LPFILETIME, LPFILETIME,
  function hasTimer (line 247) | static int hasTimer(void){
  function beginTimer (line 274) | static void beginTimer(void){
  function timeDiff (line 284) | static double timeDiff(FILETIME *pStart, FILETIME *pEnd){
  function endTimer (line 293) | static void endTimer(void){
  function iotracePrintf (line 378) | static void SQLITE_CDECL iotracePrintf(const char *zFormat, ...){
  function isNumber (line 394) | static int isNumber(const char *z, int *realnum){
  function shellstaticFunc (line 427) | static void shellstaticFunc(
  function strlen30 (line 444) | static int strlen30(const char *z){
  function utf8_printf (line 548) | void utf8_printf(FILE *out, const char *zFormat, ...){
  type SavedModeInfo (line 579) | typedef struct SavedModeInfo SavedModeInfo;
  type SavedModeInfo (line 580) | struct SavedModeInfo {
  type ShellState (line 591) | typedef struct ShellState ShellState;
  type ShellState (line 592) | struct ShellState {
  function shellLog (line 685) | static void shellLog(void *pArg, int iErrCode, const char *zMsg){
  function output_hex_blob (line 695) | static void output_hex_blob(FILE *out, const void *pBlob, int nBlob){
  function output_quoted_string (line 706) | static void output_quoted_string(FILE *out, const char *z){
  function output_c_string (line 738) | static void output_c_string(FILE *out, const char *z){
  function output_html_string (line 770) | static void output_html_string(FILE *out, const char *z){
  function output_csv (line 830) | static void output_csv(ShellState *p, const char *z, int bSep){
  function interrupt_handler (line 865) | static void interrupt_handler(int NotUsed){
  function shell_callback (line 877) | static int shell_callback(
  function callback (line 1127) | static int callback(void *pArg, int nArg, char **azArg, char **azCol){
  function set_table_name (line 1137) | static void set_table_name(ShellState *p, const char *zName){
  function run_table_dump_query (line 1226) | static int run_table_dump_query(
  function displayLinuxIoStats (line 1291) | static void displayLinuxIoStats(FILE *out){
  function display_stats (line 1327) | static int display_stats(
  function display_scanstats (line 1458) | static void display_scanstats(
  function str_in_array (line 1509) | static int str_in_array(const char *zStr, const char **azArray){
  function explain_data_prepare (line 1535) | static void explain_data_prepare(ShellState *p, sqlite3_stmt *pSql){
  function explain_data_delete (line 1617) | static void explain_data_delete(ShellState *p){
  function shell_exec (line 1633) | static int shell_exec(
  function dump_callback (line 1808) | static int dump_callback(void *pArg, int nArg, char **azArg, char **azCol){
  function run_schema_dump_query (line 1909) | static int run_schema_dump_query(
  function readfileFunc (line 2023) | static void readfileFunc(
  function writefileFunc (line 2056) | static void writefileFunc(
  function open_db (line 2085) | static void open_db(ShellState *p, int keepAlive){
  function resolve_backslashes (line 2126) | static void resolve_backslashes(char *z){
  function hexDigitValue (line 2174) | static int hexDigitValue(char c){
  function sqlite3_int64 (line 2184) | static sqlite3_int64 integerValue(const char *zArg){
  function booleanValue (line 2231) | static int booleanValue(char *zArg){
  function output_file_close (line 2253) | static void output_file_close(FILE *f){
  function FILE (line 2262) | static FILE *output_file_open(const char *zFile){
  function sql_trace_callback (line 2282) | static void sql_trace_callback(void *pArg, const char *z){
  function test_breakpoint (line 2295) | static void test_breakpoint(void){
  type ImportCtx (line 2303) | typedef struct ImportCtx ImportCtx;
  type ImportCtx (line 2304) | struct ImportCtx {
  function import_append_char (line 2317) | static void import_append_char(ImportCtx *p, int c){
  function tryToCloneData (line 2443) | static void tryToCloneData(
  function tryToCloneSchema (line 2556) | static void tryToCloneSchema(
  function tryToClone (line 2631) | static void tryToClone(ShellState *p, const char *zNewDb){
  function output_reset (line 2656) | static void output_reset(ShellState *p){
  function db_int (line 2671) | static int db_int(ShellState *p, const char *zSql){
  function get2byteInt (line 2685) | unsigned int get2byteInt(unsigned char *a){
  function get4byteInt (line 2688) | unsigned int get4byteInt(unsigned char *a){
  function shell_dbinfo_command (line 2697) | static int shell_dbinfo_command(ShellState *p, int nArg, char **azArg){
  function shellDatabaseError (line 2779) | static int shellDatabaseError(sqlite3 *db){
  function shellNomemError (line 2788) | static int shellNomemError(void){
  function do_meta_command (line 2799) | static int do_meta_command(char *zLine, ShellState *p){
  function line_contains_semicolon (line 4314) | static int line_contains_semicolon(const char *z, int N){
  function _all_whitespace (line 4323) | static int _all_whitespace(const char *z){
  function line_is_command_terminator (line 4349) | static int line_is_command_terminator(const char *zLine){
  function line_is_complete (line 4365) | static int line_is_complete(char *zSql, int nSql){
  function process_input (line 4384) | static int process_input(ShellState *p, FILE *in){
  type passwd (line 4509) | struct passwd
  function process_sqliterc (line 4568) | static void process_sqliterc(
  function usage (line 4637) | static void usage(int showDetail){
  function main_init (line 4653) | static void main_init(ShellState *data) {
  function printBold (line 4672) | static void printBold(const char *zText){
  function printBold (line 4683) | static void printBold(const char *zText){
  function main (line 4701) | int SQLITE_CDECL main(int argc, char **argv){

FILE: ext/SQLite/sqlite3.c
  type sqlite3 (line 457) | typedef struct sqlite3 sqlite3;
  type SQLITE_INT64_TYPE (line 476) | typedef SQLITE_INT64_TYPE sqlite_int64;
  type sqlite_uint64 (line 477) | typedef unsigned SQLITE_INT64_TYPE sqlite_uint64;
  type __int64 (line 479) | typedef __int64 sqlite_int64;
  type sqlite_uint64 (line 480) | typedef unsigned __int64 sqlite_uint64;
  type sqlite_int64 (line 482) | typedef long long int sqlite_int64;
  type sqlite_uint64 (line 483) | typedef unsigned long long int sqlite_uint64;
  type sqlite_int64 (line 485) | typedef sqlite_int64 sqlite3_int64;
  type sqlite_uint64 (line 486) | typedef sqlite_uint64 sqlite3_uint64;
  type sqlite3_file (line 862) | typedef struct sqlite3_file sqlite3_file;
  type sqlite3_file (line 863) | struct sqlite3_file {
  type sqlite3_io_methods (line 957) | typedef struct sqlite3_io_methods sqlite3_io_methods;
  type sqlite3_io_methods (line 958) | struct sqlite3_io_methods {
  type sqlite3_mutex (line 1261) | typedef struct sqlite3_mutex sqlite3_mutex;
  type sqlite3_vfs (line 1420) | typedef struct sqlite3_vfs sqlite3_vfs;
  type sqlite3_vfs (line 1422) | struct sqlite3_vfs {
  type sqlite3_mem_methods (line 1718) | typedef struct sqlite3_mem_methods sqlite3_mem_methods;
  type sqlite3_mem_methods (line 1719) | struct sqlite3_mem_methods {
  type sqlite3_stmt (line 3384) | typedef struct sqlite3_stmt sqlite3_stmt;
  type sqlite3_value (line 3709) | typedef struct Mem sqlite3_value;
  type sqlite3_context (line 3723) | typedef struct sqlite3_context sqlite3_context;
  type sqlite3_vtab (line 5800) | typedef struct sqlite3_vtab sqlite3_vtab;
  type sqlite3_index_info (line 5801) | typedef struct sqlite3_index_info sqlite3_index_info;
  type sqlite3_vtab_cursor (line 5802) | typedef struct sqlite3_vtab_cursor sqlite3_vtab_cursor;
  type sqlite3_module (line 5803) | typedef struct sqlite3_module sqlite3_module;
  type sqlite3_module (line 5821) | struct sqlite3_module {
  type sqlite3_index_info (line 5950) | struct sqlite3_index_info {
  type sqlite3_vtab (line 6063) | struct sqlite3_vtab {
  type sqlite3_vtab_cursor (line 6087) | struct sqlite3_vtab_cursor {
  type sqlite3_blob (line 6143) | typedef struct sqlite3_blob sqlite3_blob;
  type sqlite3_mutex_methods (line 6581) | typedef struct sqlite3_mutex_methods sqlite3_mutex_methods;
  type sqlite3_mutex_methods (line 6582) | struct sqlite3_mutex_methods {
  type sqlite3_pcache (line 7093) | typedef struct sqlite3_pcache sqlite3_pcache;
  type sqlite3_pcache_page (line 7105) | typedef struct sqlite3_pcache_page sqlite3_pcache_page;
  type sqlite3_pcache_page (line 7106) | struct sqlite3_pcache_page {
  type sqlite3_pcache_methods2 (line 7270) | typedef struct sqlite3_pcache_methods2 sqlite3_pcache_methods2;
  type sqlite3_pcache_methods2 (line 7271) | struct sqlite3_pcache_methods2 {
  type sqlite3_pcache_methods (line 7293) | typedef struct sqlite3_pcache_methods sqlite3_pcache_methods;
  type sqlite3_pcache_methods (line 7294) | struct sqlite3_pcache_methods {
  type sqlite3_backup (line 7319) | typedef struct sqlite3_backup sqlite3_backup;
  type sqlite3_snapshot (line 8181) | typedef struct sqlite3_snapshot sqlite3_snapshot;
  type sqlite3_rtree_geometry (line 8285) | typedef struct sqlite3_rtree_geometry sqlite3_rtree_geometry;
  type sqlite3_rtree_query_info (line 8286) | typedef struct sqlite3_rtree_query_info sqlite3_rtree_query_info;
  type sqlite3_int64 (line 8292) | typedef sqlite3_int64 sqlite3_rtree_dbl;
  type sqlite3_rtree_dbl (line 8294) | typedef double sqlite3_rtree_dbl;
  type sqlite3_rtree_geometry (line 8315) | struct sqlite3_rtree_geometry {
  type sqlite3_rtree_query_info (line 8347) | struct sqlite3_rtree_query_info {
  type Fts5ExtensionApi (line 8416) | typedef struct Fts5ExtensionApi Fts5ExtensionApi;
  type Fts5Context (line 8417) | typedef struct Fts5Context Fts5Context;
  type Fts5PhraseIter (line 8418) | typedef struct Fts5PhraseIter Fts5PhraseIter;
  type Fts5PhraseIter (line 8428) | struct Fts5PhraseIter {
  type Fts5ExtensionApi (line 8646) | struct Fts5ExtensionApi {
  type Fts5Tokenizer (line 8880) | typedef struct Fts5Tokenizer Fts5Tokenizer;
  type fts5_tokenizer (line 8881) | typedef struct fts5_tokenizer fts5_tokenizer;
  type fts5_tokenizer (line 8882) | struct fts5_tokenizer {
  type fts5_api (line 8917) | typedef struct fts5_api fts5_api;
  type fts5_api (line 8918) | struct fts5_api {
  type Hash (line 9536) | typedef struct Hash Hash;
  type HashElem (line 9537) | typedef struct HashElem HashElem;
  type Hash (line 9560) | struct Hash {
  type HashElem (line 9576) | struct HashElem {
  type sqlite_int64 (line 9963) | typedef sqlite_int64 i64;
  type sqlite_uint64 (line 9964) | typedef sqlite_uint64 u64;
  type UINT32_TYPE (line 9965) | typedef UINT32_TYPE u32;
  type UINT16_TYPE (line 9966) | typedef UINT16_TYPE u16;
  type INT16_TYPE (line 9967) | typedef INT16_TYPE i16;
  type UINT8_TYPE (line 9968) | typedef UINT8_TYPE u8;
  type INT8_TYPE (line 9969) | typedef INT8_TYPE i8;
  type u64 (line 9986) | typedef u64 tRowcnt;
  type u32 (line 9988) | typedef u32 tRowcnt;
  type INT16_TYPE (line 10014) | typedef INT16_TYPE LogEst;
  type uptr (line 10033) | typedef uintptr_t uptr;
  type u32 (line 10035) | typedef u32 uptr;
  type u64 (line 10037) | typedef u64 uptr;
  type BusyHandler (line 10197) | typedef struct BusyHandler BusyHandler;
  type BusyHandler (line 10198) | struct BusyHandler {
  type AggInfo (line 10291) | typedef struct AggInfo AggInfo;
  type AuthContext (line 10292) | typedef struct AuthContext AuthContext;
  type AutoincInfo (line 10293) | typedef struct AutoincInfo AutoincInfo;
  type Bitvec (line 10294) | typedef struct Bitvec Bitvec;
  type CollSeq (line 10295) | typedef struct CollSeq CollSeq;
  type Column (line 10296) | typedef struct Column Column;
  type Db (line 10297) | typedef struct Db Db;
  type Schema (line 10298) | typedef struct Schema Schema;
  type Expr (line 10299) | typedef struct Expr Expr;
  type ExprList (line 10300) | typedef struct ExprList ExprList;
  type ExprSpan (line 10301) | typedef struct ExprSpan ExprSpan;
  type FKey (line 10302) | typedef struct FKey FKey;
  type FuncDestructor (line 10303) | typedef struct FuncDestructor FuncDestructor;
  type FuncDef (line 10304) | typedef struct FuncDef FuncDef;
  type FuncDefHash (line 10305) | typedef struct FuncDefHash FuncDefHash;
  type IdList (line 10306) | typedef struct IdList IdList;
  type Index (line 10307) | typedef struct Index Index;
  type IndexSample (line 10308) | typedef struct IndexSample IndexSample;
  type KeyClass (line 10309) | typedef struct KeyClass KeyClass;
  type KeyInfo (line 10310) | typedef struct KeyInfo KeyInfo;
  type Lookaside (line 10311) | typedef struct Lookaside Lookaside;
  type LookasideSlot (line 10312) | typedef struct LookasideSlot LookasideSlot;
  type Module (line 10313) | typedef struct Module Module;
  type NameContext (line 10314) | typedef struct NameContext NameContext;
  type Parse (line 10315) | typedef struct Parse Parse;
  type PrintfArguments (line 10316) | typedef struct PrintfArguments PrintfArguments;
  type RowSet (line 10317) | typedef struct RowSet RowSet;
  type Savepoint (line 10318) | typedef struct Savepoint Savepoint;
  type Select (line 10319) | typedef struct Select Select;
  type SQLiteThread (line 10320) | typedef struct SQLiteThread SQLiteThread;
  type SelectDest (line 10321) | typedef struct SelectDest SelectDest;
  type SrcList (line 10322) | typedef struct SrcList SrcList;
  type StrAccum (line 10323) | typedef struct StrAccum StrAccum;
  type Table (line 10324) | typedef struct Table Table;
  type TableLock (line 10325) | typedef struct TableLock TableLock;
  type Token (line 10326) | typedef struct Token Token;
  type TreeView (line 10327) | typedef struct TreeView TreeView;
  type Trigger (line 10328) | typedef struct Trigger Trigger;
  type TriggerPrg (line 10329) | typedef struct TriggerPrg TriggerPrg;
  type TriggerStep (line 10330) | typedef struct TriggerStep TriggerStep;
  type UnpackedRecord (line 10331) | typedef struct UnpackedRecord UnpackedRecord;
  type VTable (line 10332) | typedef struct VTable VTable;
  type VtabCtx (line 10333) | typedef struct VtabCtx VtabCtx;
  type Walker (line 10334) | typedef struct Walker Walker;
  type WhereInfo (line 10335) | typedef struct WhereInfo WhereInfo;
  type With (line 10336) | typedef struct With With;
  type Btree (line 10383) | typedef struct Btree Btree;
  type BtCursor (line 10384) | typedef struct BtCursor BtCursor;
  type BtShared (line 10385) | typedef struct BtShared BtShared;
  type KeyInfo (line 10571) | struct KeyInfo
  type Vdbe (line 10711) | typedef struct Vdbe Vdbe;
  type Mem (line 10717) | typedef struct Mem Mem;
  type SubProgram (line 10718) | typedef struct SubProgram SubProgram;
  type VdbeOp (line 10725) | struct VdbeOp {
  type VdbeOp (line 10763) | typedef struct VdbeOp VdbeOp;
  type SubProgram (line 10769) | struct SubProgram {
  type VdbeOpList (line 10783) | struct VdbeOpList {
  type VdbeOpList (line 10789) | typedef struct VdbeOpList VdbeOpList;
  type u32 (line 11233) | typedef u32 Pgno;
  type Pager (line 11238) | typedef struct Pager Pager;
  type DbPage (line 11243) | typedef struct PgHdr DbPage;
  type PgHdr (line 11447) | typedef struct PgHdr PgHdr;
  type PCache (line 11448) | typedef struct PCache PCache;
  type PgHdr (line 11454) | struct PgHdr {
  type Db (line 11999) | struct Db {
  type Schema (line 12024) | struct Schema {
  type Lookaside (line 12087) | struct Lookaside {
  type LookasideSlot (line 12098) | struct LookasideSlot {
  type FuncDefHash (line 12110) | struct FuncDefHash {
  type sqlite3_userauth (line 12119) | typedef struct sqlite3_userauth sqlite3_userauth;
  type sqlite3_userauth (line 12120) | struct sqlite3_userauth {
  type sqlite3 (line 12156) | struct sqlite3 {
  type FuncDef (line 12376) | struct FuncDef {
  type FuncDestructor (line 12404) | struct FuncDestructor {
  type Savepoint (line 12496) | struct Savepoint {
  type Module (line 12517) | struct Module {
  type Column (line 12529) | struct Column {
  type CollSeq (line 12554) | struct CollSeq {
  type VTable (line 12653) | struct VTable {
  type Table (line 12667) | struct Table {
  type FKey (line 12780) | struct FKey {
  type KeyInfo (line 12846) | struct KeyInfo {
  type UnpackedRecord (line 12891) | struct UnpackedRecord {
  type Index (line 12937) | struct Index {
  type IndexSample (line 12994) | struct IndexSample {
  type Token (line 13010) | struct Token {
  type AggInfo (line 13028) | struct AggInfo {
  type i16 (line 13070) | typedef i16 ynVar;
  type ynVar (line 13072) | typedef int ynVar;
  type Expr (line 13138) | struct Expr {
  type ExprList (line 13264) | struct ExprList {
  type ExprSpan (line 13289) | struct ExprSpan {
  type IdList (line 13310) | struct IdList {
  type SQLITE_BITMASK_TYPE (line 13326) | typedef SQLITE_BITMASK_TYPE Bitmask;
  type u64 (line 13328) | typedef u64 Bitmask;
  type SrcList (line 13362) | struct SrcList {
  type NameContext (line 13460) | struct NameContext {
  type Select (line 13506) | struct Select {
  type SelectDest (line 13638) | struct SelectDest {
  type AutoincInfo (line 13656) | struct AutoincInfo {
  type TriggerPrg (line 13688) | struct TriggerPrg {
  type yDbMask (line 13707) | typedef unsigned int yDbMask;
  type Parse (line 13731) | struct Parse {
  type AuthContext (line 13851) | struct AuthContext {
  type Trigger (line 13891) | struct Trigger {
  type TriggerStep (line 13953) | struct TriggerStep {
  type DbFixer (line 13971) | typedef struct DbFixer DbFixer;
  type DbFixer (line 13972) | struct DbFixer {
  type StrAccum (line 13985) | struct StrAccum {
  type InitData (line 14008) | typedef struct {
  type Sqlite3Config (line 14020) | struct Sqlite3Config {
  type Walker (line 14097) | struct Walker {
  type With (line 14135) | struct With {
  type TreeView (line 14151) | struct TreeView {
  type PrintfArguments (line 14333) | struct PrintfArguments {
  type SrcList_item (line 14472) | struct SrcList_item
  type SrcList_item (line 14532) | struct SrcList_item
  type Sqlite3Config (line 14764) | struct Sqlite3Config
  type Sqlite3Config (line 15276) | struct Sqlite3Config
  function SQLITE_STDCALL (line 15788) | SQLITE_STDCALL sqlite3_compileoption_used(const char *zOptName){
  function SQLITE_API (line 15816) | SQLITE_API const char *SQLITE_STDCALL sqlite3_compileoption_get(int N){
  type Op (line 15889) | typedef struct VdbeOp Op;
  type Bool (line 15894) | typedef unsigned Bool;
  type VdbeSorter (line 15897) | typedef struct VdbeSorter VdbeSorter;
  type Explain (line 15900) | typedef struct Explain Explain;
  type AuxData (line 15903) | typedef struct AuxData AuxData;
  type VdbeCursor (line 15921) | typedef struct VdbeCursor VdbeCursor;
  type VdbeCursor (line 15922) | struct VdbeCursor {
  type VdbeFrame (line 15997) | typedef struct VdbeFrame VdbeFrame;
  type VdbeFrame (line 15998) | struct VdbeFrame {
  type Mem (line 16032) | struct Mem {
  type AuxData (line 16133) | struct AuxData {
  type sqlite3_context (line 16154) | struct sqlite3_context {
  type Explain (line 16171) | struct Explain {
  type bft (line 16182) | typedef unsigned bft;
  type ScanStatus (line 16184) | typedef struct ScanStatus ScanStatus;
  type ScanStatus (line 16185) | struct ScanStatus {
  type Vdbe (line 16201) | struct Vdbe {
  type sqlite3_int64 (line 16392) | typedef sqlite3_int64 sqlite3StatValueType;
  type u32 (line 16394) | typedef u32 sqlite3StatValueType;
  type sqlite3StatType (line 16396) | typedef struct sqlite3StatType sqlite3StatType;
  function SQLITE_WSD (line 16397) | static SQLITE_WSD struct sqlite3StatType {
  function SQLITE_PRIVATE (line 16438) | SQLITE_PRIVATE sqlite3_int64 sqlite3StatusValue(int op){
  function SQLITE_PRIVATE (line 16458) | SQLITE_PRIVATE void sqlite3StatusUp(int op, int N){
  function SQLITE_PRIVATE (line 16469) | SQLITE_PRIVATE void sqlite3StatusDown(int op, int N){
  function SQLITE_PRIVATE (line 16483) | SQLITE_PRIVATE void sqlite3StatusHighwater(int op, int X){
  function SQLITE_STDCALL (line 16504) | SQLITE_STDCALL sqlite3_status64(
  function SQLITE_STDCALL (line 16529) | SQLITE_STDCALL sqlite3_status(int op, int *pCurrent, int *pHighwater, in...
  function SQLITE_STDCALL (line 16546) | SQLITE_STDCALL sqlite3_db_status(
  type DateTime (line 16775) | typedef struct DateTime DateTime;
  type DateTime (line 16776) | struct DateTime {
  function getDigits (line 16817) | static int getDigits(const char *zDate, const char *zFormat, ...){
  function parseTimezone (line 16871) | static int parseTimezone(const char *zDate, DateTime *p){
  function parseHhMmSs (line 16907) | static int parseHhMmSs(const char *zDate, DateTime *p){
  function computeJD (line 16949) | static void computeJD(DateTime *p){
  function parseYyyyMmDd (line 16995) | static int parseYyyyMmDd(const char *zDate, DateTime *p){
  function setDateTimeToCurrent (line 17032) | static int setDateTimeToCurrent(sqlite3_context *context, DateTime *p){
  function parseDateOrTime (line 17058) | static int parseDateOrTime(
  function computeYMD (line 17081) | static void computeYMD(DateTime *p){
  function computeHMS (line 17107) | static void computeHMS(DateTime *p){
  function computeYMD_HMS (line 17125) | static void computeYMD_HMS(DateTime *p){
  function clearYMD_HMS_TZ (line 17133) | static void clearYMD_HMS_TZ(DateTime *p){
  function osLocaltime (line 17171) | static int osLocaltime(time_t *t, struct tm *pTm){
  function sqlite3_int64 (line 17210) | static sqlite3_int64 localtimeOffset(
  function parseModifier (line 17289) | static int parseModifier(sqlite3_context *pCtx, const char *zMod, DateTi...
  function isDate (line 17499) | static int isDate(
  function juliandayFunc (line 17540) | static void juliandayFunc(
  function datetimeFunc (line 17557) | static void datetimeFunc(
  function timeFunc (line 17577) | static void timeFunc(
  function dateFunc (line 17596) | static void dateFunc(
  function strftimeFunc (line 17629) | static void strftimeFunc(
  function ctimeFunc (line 17767) | static void ctimeFunc(
  function cdateFunc (line 17781) | static void cdateFunc(
  function ctimestampFunc (line 17795) | static void ctimestampFunc(
  function currentTimeFunc (line 17817) | static void currentTimeFunc(
  function SQLITE_PRIVATE (line 17856) | SQLITE_PRIVATE void sqlite3RegisterDateTimeFunctions(void){
  function SQLITE_PRIVATE (line 17961) | SQLITE_PRIVATE int sqlite3OsClose(sqlite3_file *pId){
  function SQLITE_PRIVATE (line 17969) | SQLITE_PRIVATE int sqlite3OsRead(sqlite3_file *id, void *pBuf, int amt, ...
  function SQLITE_PRIVATE (line 17973) | SQLITE_PRIVATE int sqlite3OsWrite(sqlite3_file *id, const void *pBuf, in...
  function SQLITE_PRIVATE (line 17977) | SQLITE_PRIVATE int sqlite3OsTruncate(sqlite3_file *id, i64 size){
  function SQLITE_PRIVATE (line 17980) | SQLITE_PRIVATE int sqlite3OsSync(sqlite3_file *id, int flags){
  function SQLITE_PRIVATE (line 17984) | SQLITE_PRIVATE int sqlite3OsFileSize(sqlite3_file *id, i64 *pSize){
  function SQLITE_PRIVATE (line 17988) | SQLITE_PRIVATE int sqlite3OsLock(sqlite3_file *id, int lockType){
  function SQLITE_PRIVATE (line 17992) | SQLITE_PRIVATE int sqlite3OsUnlock(sqlite3_file *id, int lockType){
  function SQLITE_PRIVATE (line 17995) | SQLITE_PRIVATE int sqlite3OsCheckReservedLock(sqlite3_file *id, int *pRe...
  function SQLITE_PRIVATE (line 18008) | SQLITE_PRIVATE int sqlite3OsFileControl(sqlite3_file *id, int op, void *...
  function SQLITE_PRIVATE (line 18026) | SQLITE_PRIVATE void sqlite3OsFileControlHint(sqlite3_file *id, int op, v...
  function SQLITE_PRIVATE (line 18030) | SQLITE_PRIVATE int sqlite3OsSectorSize(sqlite3_file *id){
  function SQLITE_PRIVATE (line 18034) | SQLITE_PRIVATE int sqlite3OsDeviceCharacteristics(sqlite3_file *id){
  function SQLITE_PRIVATE (line 18037) | SQLITE_PRIVATE int sqlite3OsShmLock(sqlite3_file *id, int offset, int n,...
  function SQLITE_PRIVATE (line 18040) | SQLITE_PRIVATE void sqlite3OsShmBarrier(sqlite3_file *id){
  function SQLITE_PRIVATE (line 18043) | SQLITE_PRIVATE int sqlite3OsShmUnmap(sqlite3_file *id, int deleteFlag){
  function SQLITE_PRIVATE (line 18046) | SQLITE_PRIVATE int sqlite3OsShmMap(
  function SQLITE_PRIVATE (line 18059) | SQLITE_PRIVATE int sqlite3OsFetch(sqlite3_file *id, i64 iOff, int iAmt, ...
  function SQLITE_PRIVATE (line 18063) | SQLITE_PRIVATE int sqlite3OsUnfetch(sqlite3_file *id, i64 iOff, void *p){
  function SQLITE_PRIVATE (line 18068) | SQLITE_PRIVATE int sqlite3OsFetch(sqlite3_file *id, i64 iOff, int iAmt, ...
  function SQLITE_PRIVATE (line 18072) | SQLITE_PRIVATE int sqlite3OsUnfetch(sqlite3_file *id, i64 iOff, void *p){
  function SQLITE_PRIVATE (line 18081) | SQLITE_PRIVATE int sqlite3OsOpen(
  function SQLITE_PRIVATE (line 18098) | SQLITE_PRIVATE int sqlite3OsDelete(sqlite3_vfs *pVfs, const char *zPath,...
  function SQLITE_PRIVATE (line 18103) | SQLITE_PRIVATE int sqlite3OsAccess(
  function SQLITE_PRIVATE (line 18112) | SQLITE_PRIVATE int sqlite3OsFullPathname(
  function SQLITE_PRIVATE (line 18123) | SQLITE_PRIVATE void *sqlite3OsDlOpen(sqlite3_vfs *pVfs, const char *zPath){
  function SQLITE_PRIVATE (line 18126) | SQLITE_PRIVATE void sqlite3OsDlError(sqlite3_vfs *pVfs, int nByte, char ...
  function SQLITE_PRIVATE (line 18129) | SQLITE_PRIVATE void (*sqlite3OsDlSym(sqlite3_vfs *pVfs, void *pHdle, con...
  function SQLITE_PRIVATE (line 18132) | SQLITE_PRIVATE void sqlite3OsDlClose(sqlite3_vfs *pVfs, void *pHandle){
  function SQLITE_PRIVATE (line 18136) | SQLITE_PRIVATE int sqlite3OsRandomness(sqlite3_vfs *pVfs, int nByte, cha...
  function SQLITE_PRIVATE (line 18139) | SQLITE_PRIVATE int sqlite3OsSleep(sqlite3_vfs *pVfs, int nMicro){
  function SQLITE_PRIVATE (line 18142) | SQLITE_PRIVATE int sqlite3OsGetLastError(sqlite3_vfs *pVfs){
  function SQLITE_PRIVATE (line 18145) | SQLITE_PRIVATE int sqlite3OsCurrentTimeInt64(sqlite3_vfs *pVfs, sqlite3_...
  function SQLITE_PRIVATE (line 18163) | SQLITE_PRIVATE int sqlite3OsOpenMalloc(
  function SQLITE_PRIVATE (line 18185) | SQLITE_PRIVATE int sqlite3OsCloseFree(sqlite3_file *pFile){
  function SQLITE_PRIVATE (line 18199) | SQLITE_PRIVATE int sqlite3OsInit(void){
  function vfsUnlink (line 18240) | static void vfsUnlink(sqlite3_vfs *pVfs){
  function SQLITE_STDCALL (line 18262) | SQLITE_STDCALL sqlite3_vfs_register(sqlite3_vfs *pVfs, int makeDflt){
  function SQLITE_STDCALL (line 18290) | SQLITE_STDCALL sqlite3_vfs_unregister(sqlite3_vfs *pVfs){
  type BenignMallocHooks (line 18335) | typedef struct BenignMallocHooks BenignMallocHooks;
  function SQLITE_WSD (line 18336) | static SQLITE_WSD struct BenignMallocHooks {
  function SQLITE_PRIVATE (line 18361) | SQLITE_PRIVATE void sqlite3BenignMallocHooks(
  function SQLITE_PRIVATE (line 18375) | SQLITE_PRIVATE void sqlite3BeginBenignMalloc(void){
  function SQLITE_PRIVATE (line 18381) | SQLITE_PRIVATE void sqlite3EndBenignMalloc(void){
  function sqlite3MemFree (line 18423) | static void sqlite3MemFree(void *pPrior){ return; }
  function sqlite3MemSize (line 18425) | static int sqlite3MemSize(void *pPrior){ return 0; }
  function sqlite3MemRoundup (line 18426) | static int sqlite3MemRoundup(int n){ return n; }
  function sqlite3MemInit (line 18427) | static int sqlite3MemInit(void *NotUsed){ return SQLITE_OK; }
  function sqlite3MemShutdown (line 18428) | static void sqlite3MemShutdown(void *NotUsed){ return; }
  function SQLITE_PRIVATE (line 18436) | SQLITE_PRIVATE void sqlite3MemSetDefault(void){
  function sqlite3MemFree (line 18611) | static void sqlite3MemFree(void *pPrior){
  function sqlite3MemSize (line 18626) | static int sqlite3MemSize(void *pPrior){
  function sqlite3MemRoundup (line 18681) | static int sqlite3MemRoundup(int n){
  function sqlite3MemInit (line 18688) | static int sqlite3MemInit(void *NotUsed){
  function sqlite3MemShutdown (line 18724) | static void sqlite3MemShutdown(void *NotUsed){
  function SQLITE_PRIVATE (line 18735) | SQLITE_PRIVATE void sqlite3MemSetDefault(void){
  type MemBlockHdr (line 18807) | struct MemBlockHdr {
  type MemBlockHdr (line 18844) | struct MemBlockHdr
  type MemBlockHdr (line 18845) | struct MemBlockHdr
  function adjustStats (line 18881) | static void adjustStats(int iSize, int increment){
  type MemBlockHdr (line 18904) | struct MemBlockHdr
  type MemBlockHdr (line 18905) | struct MemBlockHdr
  type MemBlockHdr (line 18910) | struct MemBlockHdr
  function sqlite3MemSize (line 18928) | static int sqlite3MemSize(void *p){
  function sqlite3MemInit (line 18940) | static int sqlite3MemInit(void *NotUsed){
  function sqlite3MemShutdown (line 18954) | static void sqlite3MemShutdown(void *NotUsed){
  function sqlite3MemRoundup (line 18962) | static int sqlite3MemRoundup(int n){
  function randomFill (line 18971) | static void randomFill(char *pBuf, int nByte){
  type MemBlockHdr (line 18995) | struct MemBlockHdr
  type MemBlockHdr (line 19011) | struct MemBlockHdr
  function sqlite3MemFree (line 19053) | static void sqlite3MemFree(void *pPrior){
  type MemBlockHdr (line 19096) | struct MemBlockHdr
  function SQLITE_PRIVATE (line 19116) | SQLITE_PRIVATE void sqlite3MemSetDefault(void){
  function SQLITE_PRIVATE (line 19133) | SQLITE_PRIVATE void sqlite3MemdebugSetType(void *p, u8 eType){
  function SQLITE_PRIVATE (line 19151) | SQLITE_PRIVATE int sqlite3MemdebugHasType(void *p, u8 eType){
  function SQLITE_PRIVATE (line 19173) | SQLITE_PRIVATE int sqlite3MemdebugNoType(void *p, u8 eType){
  function SQLITE_PRIVATE (line 19191) | SQLITE_PRIVATE void sqlite3MemdebugBacktrace(int depth){
  function SQLITE_PRIVATE (line 19198) | SQLITE_PRIVATE void sqlite3MemdebugBacktraceCallback(void (*xBacktrace)(...
  function SQLITE_PRIVATE (line 19205) | SQLITE_PRIVATE void sqlite3MemdebugSettitle(const char *zTitle){
  function SQLITE_PRIVATE (line 19215) | SQLITE_PRIVATE void sqlite3MemdebugSync(){
  function SQLITE_PRIVATE (line 19228) | SQLITE_PRIVATE void sqlite3MemdebugDump(const char *zFilename){
  function SQLITE_PRIVATE (line 19270) | SQLITE_PRIVATE int sqlite3MemdebugMallocCount(){
  type Mem3Block (line 19363) | typedef struct Mem3Block Mem3Block;
  type Mem3Block (line 19364) | struct Mem3Block {
  function SQLITE_WSD (line 19383) | static SQLITE_WSD struct Mem3Global {
  function memsys3UnlinkFromList (line 19430) | static void memsys3UnlinkFromList(u32 i, u32 *pRoot){
  function memsys3Unlink (line 19450) | static void memsys3Unlink(u32 i){
  function memsys3LinkIntoList (line 19470) | static void memsys3LinkIntoList(u32 i, u32 *pRoot){
  function memsys3Link (line 19484) | static void memsys3Link(u32 i){
  function memsys3Enter (line 19505) | static void memsys3Enter(void){
  function memsys3Leave (line 19511) | static void memsys3Leave(void){
  function memsys3OutOfMemory (line 19518) | static void memsys3OutOfMemory(int nByte){
  function memsys3Merge (line 19598) | static void memsys3Merge(u32 *pRoot){
  function memsys3FreeUnsafe (line 19719) | static void memsys3FreeUnsafe(void *pOld){
  function memsys3Size (line 19760) | static int memsys3Size(void *p){
  function memsys3Roundup (line 19771) | static int memsys3Roundup(int n){
  function memsys3Free (line 19794) | static void memsys3Free(void *pPrior){
  function memsys3Init (line 19835) | static int memsys3Init(void *NotUsed){
  function memsys3Shutdown (line 19860) | static void memsys3Shutdown(void *NotUsed){
  function SQLITE_PRIVATE (line 19872) | SQLITE_PRIVATE void sqlite3Memsys3Dump(const char *zFilename){
  function SQLITE_PRIVATE (line 19956) | SQLITE_PRIVATE const sqlite3_mem_methods *sqlite3MemGetMemsys3(void){
  type Mem5Link (line 20040) | typedef struct Mem5Link Mem5Link;
  type Mem5Link (line 20041) | struct Mem5Link {
  function SQLITE_WSD (line 20065) | static SQLITE_WSD struct Mem5Global {
  function memsys5Unlink (line 20122) | static void memsys5Unlink(int i, int iLogsize){
  function memsys5Link (line 20144) | static void memsys5Link(int i, int iLogsize){
  function memsys5Enter (line 20163) | static void memsys5Enter(void){
  function memsys5Leave (line 20166) | static void memsys5Leave(void){
  function memsys5Size (line 20174) | static int memsys5Size(void *p){
  function memsys5FreeUnsafe (line 20263) | static void memsys5FreeUnsafe(void *pOld){
  function memsys5Free (line 20345) | static void memsys5Free(void *pPrior){
  function memsys5Roundup (line 20394) | static int memsys5Roundup(int n){
  function memsys5Log (line 20411) | static int memsys5Log(int iValue){
  function memsys5Init (line 20423) | static int memsys5Init(void *NotUsed){
  function memsys5Shutdown (line 20481) | static void memsys5Shutdown(void *NotUsed){
  function SQLITE_PRIVATE (line 20492) | SQLITE_PRIVATE void sqlite3Memsys5Dump(const char *zFilename){
  function SQLITE_PRIVATE (line 20535) | SQLITE_PRIVATE const sqlite3_mem_methods *sqlite3MemGetMemsys5(void){
  function SQLITE_PRIVATE (line 20584) | SQLITE_PRIVATE int sqlite3MutexInit(void){
  function SQLITE_PRIVATE (line 20625) | SQLITE_PRIVATE int sqlite3MutexEnd(void){
  function SQLITE_PRIVATE (line 20650) | SQLITE_PRIVATE sqlite3_mutex *sqlite3MutexAlloc(int id){
  function SQLITE_STDCALL (line 20662) | SQLITE_STDCALL sqlite3_mutex_free(sqlite3_mutex *p){
  function SQLITE_STDCALL (line 20673) | SQLITE_STDCALL sqlite3_mutex_enter(sqlite3_mutex *p){
  function SQLITE_STDCALL (line 20684) | SQLITE_STDCALL sqlite3_mutex_try(sqlite3_mutex *p){
  function SQLITE_STDCALL (line 20699) | SQLITE_STDCALL sqlite3_mutex_leave(sqlite3_mutex *p){
  function SQLITE_STDCALL (line 20711) | SQLITE_STDCALL sqlite3_mutex_held(sqlite3_mutex *p){
  function SQLITE_STDCALL (line 20715) | SQLITE_STDCALL sqlite3_mutex_notheld(sqlite3_mutex *p){
  function noopMutexInit (line 20762) | static int noopMutexInit(void){ return SQLITE_OK; }
  function noopMutexEnd (line 20763) | static int noopMutexEnd(void){ return SQLITE_OK; }
  function sqlite3_mutex (line 20764) | static sqlite3_mutex *noopMutexAlloc(int id){
  function noopMutexFree (line 20768) | static void noopMutexFree(sqlite3_mutex *p){ UNUSED_PARAMETER(p); return; }
  function noopMutexEnter (line 20769) | static void noopMutexEnter(sqlite3_mutex *p){ UNUSED_PARAMETER(p); retur...
  function noopMutexTry (line 20770) | static int noopMutexTry(sqlite3_mutex *p){
  function noopMutexLeave (line 20774) | static void noopMutexLeave(sqlite3_mutex *p){ UNUSED_PARAMETER(p); retur...
  function SQLITE_PRIVATE (line 20776) | SQLITE_PRIVATE sqlite3_mutex_methods const *sqlite3NoopMutex(void){
  type sqlite3_debug_mutex (line 20804) | typedef struct sqlite3_debug_mutex {
  function debugMutexHeld (line 20813) | static int debugMutexHeld(sqlite3_mutex *pX){
  function debugMutexNotheld (line 20817) | static int debugMutexNotheld(sqlite3_mutex *pX){
  function debugMutexInit (line 20825) | static int debugMutexInit(void){ return SQLITE_OK; }
  function debugMutexEnd (line 20826) | static int debugMutexEnd(void){ return SQLITE_OK; }
  function sqlite3_mutex (line 20833) | static sqlite3_mutex *debugMutexAlloc(int id){
  function debugMutexFree (line 20864) | static void debugMutexFree(sqlite3_mutex *pX){
  function debugMutexEnter (line 20887) | static void debugMutexEnter(sqlite3_mutex *pX){
  function debugMutexTry (line 20892) | static int debugMutexTry(sqlite3_mutex *pX){
  function debugMutexLeave (line 20905) | static void debugMutexLeave(sqlite3_mutex *pX){
  function SQLITE_PRIVATE (line 20912) | SQLITE_PRIVATE sqlite3_mutex_methods const *sqlite3NoopMutex(void){
  function SQLITE_PRIVATE (line 20935) | SQLITE_PRIVATE sqlite3_mutex_methods const *sqlite3DefaultMutex(void){
  type sqlite3_mutex (line 20983) | struct sqlite3_mutex {
  function pthreadMutexHeld (line 21019) | static int pthreadMutexHeld(sqlite3_mutex *p){
  function pthreadMutexNotheld (line 21022) | static int pthreadMutexNotheld(sqlite3_mutex *p){
  function SQLITE_PRIVATE (line 21032) | SQLITE_PRIVATE void sqlite3MemoryBarrier(void){
  function pthreadMutexInit (line 21043) | static int pthreadMutexInit(void){ return SQLITE_OK; }
  function pthreadMutexEnd (line 21044) | static int pthreadMutexEnd(void){ return SQLITE_OK; }
  function sqlite3_mutex (line 21094) | static sqlite3_mutex *pthreadMutexAlloc(int iType){
  function pthreadMutexFree (line 21159) | static void pthreadMutexFree(sqlite3_mutex *p){
  function pthreadMutexEnter (line 21186) | static void pthreadMutexEnter(sqlite3_mutex *p){
  function pthreadMutexTry (line 21228) | static int pthreadMutexTry(sqlite3_mutex *p){
  function pthreadMutexLeave (line 21285) | static void pthreadMutexLeave(sqlite3_mutex *p){
  function SQLITE_PRIVATE (line 21308) | SQLITE_PRIVATE sqlite3_mutex_methods const *sqlite3DefaultMutex(void){
  function sqlite_uint64 (line 21426) | __inline__ sqlite_uint64 sqlite3Hwtime(void){
  function sqlite_uint64 (line 21434) | __declspec(naked) __inline sqlite_uint64 __cdecl sqlite3Hwtime(void){
  function sqlite_uint64 (line 21445) | __inline__ sqlite_uint64 sqlite3Hwtime(void){
  function sqlite_uint64 (line 21453) | __inline__ sqlite_uint64 sqlite3Hwtime(void){
  function sqlite3Hwtime (line 21477) | sqlite3Hwtime(void){ return ((sqlite_uint64)0); }
  function local_ioerr (line 21515) | static void local_ioerr(){
  type sqlite3_mutex (line 21659) | struct sqlite3_mutex {
  function winMutexHeld (line 21688) | static int winMutexHeld(sqlite3_mutex *p){
  function winMutexNotheld2 (line 21692) | static int winMutexNotheld2(sqlite3_mutex *p, DWORD tid){
  function winMutexNotheld (line 21696) | static int winMutexNotheld(sqlite3_mutex *p){
  function SQLITE_PRIVATE (line 21707) | SQLITE_PRIVATE void sqlite3MemoryBarrier(void){
  function winMutexInit (line 21750) | static int winMutexInit(void){
  function winMutexEnd (line 21772) | static int winMutexEnd(void){
  function sqlite3_mutex (line 21835) | static sqlite3_mutex *winMutexAlloc(int iType){
  function winMutexFree (line 21883) | static void winMutexFree(sqlite3_mutex *p){
  function winMutexEnter (line 21907) | static void winMutexEnter(sqlite3_mutex *p){
  function winMutexTry (line 21930) | static int winMutexTry(sqlite3_mutex *p){
  function winMutexLeave (line 21980) | static void winMutexLeave(sqlite3_mutex *p){
  function SQLITE_PRIVATE (line 22002) | SQLITE_PRIVATE sqlite3_mutex_methods const *sqlite3DefaultMutex(void){
  function SQLITE_STDCALL (line 22048) | SQLITE_STDCALL sqlite3_release_memory(int n){
  type ScratchFreeslot (line 22064) | typedef struct ScratchFreeslot {
  function SQLITE_WSD (line 22071) | static SQLITE_WSD struct Mem0Global {
  function SQLITE_PRIVATE (line 22097) | SQLITE_PRIVATE sqlite3_mutex *sqlite3MallocMutex(void){
  function SQLITE_STDCALL (line 22107) | SQLITE_STDCALL sqlite3_memory_alarm(
  function SQLITE_STDCALL (line 22123) | SQLITE_STDCALL sqlite3_soft_heap_limit64(sqlite3_int64 n){
  function SQLITE_STDCALL (line 22145) | SQLITE_STDCALL sqlite3_soft_heap_limit(int n){
  function SQLITE_PRIVATE (line 22153) | SQLITE_PRIVATE int sqlite3MallocInit(void){
  function SQLITE_PRIVATE (line 22197) | SQLITE_PRIVATE int sqlite3HeapNearlyFull(void){
  function SQLITE_PRIVATE (line 22204) | SQLITE_PRIVATE void sqlite3MallocEnd(void){
  function SQLITE_STDCALL (line 22214) | SQLITE_STDCALL sqlite3_memory_used(void){
  function SQLITE_STDCALL (line 22225) | SQLITE_STDCALL sqlite3_memory_highwater(int resetFlag){
  function sqlite3MallocAlarm (line 22234) | static void sqlite3MallocAlarm(int nByte){
  function mallocWithAlarm (line 22245) | static int mallocWithAlarm(int n, void **pp){
  function SQLITE_PRIVATE (line 22280) | SQLITE_PRIVATE void *sqlite3Malloc(u64 n){
  function SQLITE_API (line 22305) | SQLITE_API void *SQLITE_STDCALL sqlite3_malloc(int n){
  function SQLITE_API (line 22311) | SQLITE_API void *SQLITE_STDCALL sqlite3_malloc64(sqlite3_uint64 n){
  function SQLITE_PRIVATE (line 22337) | SQLITE_PRIVATE void *sqlite3ScratchMalloc(int n){
  function SQLITE_PRIVATE (line 22374) | SQLITE_PRIVATE void sqlite3ScratchFree(void *p){
  function isLookaside (line 22421) | static int isLookaside(sqlite3 *db, void *p){
  function SQLITE_PRIVATE (line 22432) | SQLITE_PRIVATE int sqlite3MallocSize(void *p){
  function SQLITE_PRIVATE (line 22436) | SQLITE_PRIVATE int sqlite3DbMallocSize(sqlite3 *db, void *p){
  function SQLITE_STDCALL (line 22454) | SQLITE_STDCALL sqlite3_msize(void *p){
  function SQLITE_STDCALL (line 22463) | SQLITE_STDCALL sqlite3_free(void *p){
  function SQLITE_NOINLINE (line 22482) | static SQLITE_NOINLINE void measureAllocationSize(sqlite3 *db, void *p){
  function SQLITE_PRIVATE (line 22490) | SQLITE_PRIVATE void sqlite3DbFree(sqlite3 *db, void *p){
  function SQLITE_PRIVATE (line 22520) | SQLITE_PRIVATE void *sqlite3Realloc(void *pOld, u64 nBytes){
  function SQLITE_API (line 22572) | SQLITE_API void *SQLITE_STDCALL sqlite3_realloc(void *pOld, int n){
  function SQLITE_API (line 22579) | SQLITE_API void *SQLITE_STDCALL sqlite3_realloc64(void *pOld, sqlite3_ui...
  function SQLITE_PRIVATE (line 22590) | SQLITE_PRIVATE void *sqlite3MallocZero(u64 n){
  function SQLITE_PRIVATE (line 22602) | SQLITE_PRIVATE void *sqlite3DbMallocZero(sqlite3 *db, u64 n){
  function SQLITE_NOINLINE (line 22614) | static SQLITE_NOINLINE void *dbMallocRawFinish(sqlite3 *db, u64 n){
  function SQLITE_PRIVATE (line 22646) | SQLITE_PRIVATE void *sqlite3DbMallocRaw(sqlite3 *db, u64 n){
  function SQLITE_PRIVATE (line 22653) | SQLITE_PRIVATE void *sqlite3DbMallocRawNN(sqlite3 *db, u64 n){
  function SQLITE_PRIVATE (line 22695) | SQLITE_PRIVATE void *sqlite3DbRealloc(sqlite3 *db, void *p, u64 n){
  function SQLITE_NOINLINE (line 22702) | static SQLITE_NOINLINE void *dbReallocFinish(sqlite3 *db, void *p, u64 n){
  function SQLITE_PRIVATE (line 22732) | SQLITE_PRIVATE void *sqlite3DbReallocOrFree(sqlite3 *db, void *p, u64 n){
  function SQLITE_PRIVATE (line 22748) | SQLITE_PRIVATE char *sqlite3DbStrDup(sqlite3 *db, const char *z){
  function SQLITE_PRIVATE (line 22762) | SQLITE_PRIVATE char *sqlite3DbStrNDup(sqlite3 *db, const char *z, u64 n){
  function SQLITE_PRIVATE (line 22780) | SQLITE_PRIVATE void sqlite3SetString(char **pz, sqlite3 *db, const char ...
  function SQLITE_PRIVATE (line 22791) | SQLITE_PRIVATE void sqlite3OomFault(sqlite3 *db){
  function SQLITE_PRIVATE (line 22808) | SQLITE_PRIVATE void sqlite3OomClear(sqlite3 *db){
  function SQLITE_NOINLINE (line 22820) | static SQLITE_NOINLINE int apiOomError(sqlite3 *db){
  function SQLITE_PRIVATE (line 22838) | SQLITE_PRIVATE int sqlite3ApiExit(sqlite3* db, int rc){
  type etByte (line 22895) | typedef unsigned char etByte;
  type et_info (line 22901) | typedef struct et_info {   /* Information about each format field */
  function et_getdigit (line 22973) | static char et_getdigit(LONGDOUBLE_TYPE *val, int *cnt){
  function setStrAccumError (line 22989) | static void setStrAccumError(StrAccum *p, u8 eError){
  function sqlite3_int64 (line 22998) | static sqlite3_int64 getIntArg(PrintfArguments *p){
  function getDoubleArg (line 23002) | static double getDoubleArg(PrintfArguments *p){
  function SQLITE_PRIVATE (line 23024) | SQLITE_PRIVATE void sqlite3VXPrintf(
  function sqlite3StrAccumEnlarge (line 23607) | static int sqlite3StrAccumEnlarge(StrAccum *p, int N){
  function SQLITE_PRIVATE (line 23659) | SQLITE_PRIVATE void sqlite3AppendChar(StrAccum *p, int N, char c){
  function enlargeAndAppend (line 23676) | static void SQLITE_NOINLINE enlargeAndAppend(StrAccum *p, const char *z,...
  function SQLITE_PRIVATE (line 23689) | SQLITE_PRIVATE void sqlite3StrAccumAppend(StrAccum *p, const char *z, in...
  function SQLITE_PRIVATE (line 23706) | SQLITE_PRIVATE void sqlite3StrAccumAppendAll(StrAccum *p, const char *z){
  function SQLITE_PRIVATE (line 23716) | SQLITE_PRIVATE char *sqlite3StrAccumFinish(StrAccum *p){
  function SQLITE_PRIVATE (line 23736) | SQLITE_PRIVATE void sqlite3StrAccumReset(StrAccum *p){
  function SQLITE_PRIVATE (line 23759) | SQLITE_PRIVATE void sqlite3StrAccumInit(StrAccum *p, sqlite3 *db, char *...
  function SQLITE_PRIVATE (line 23773) | SQLITE_PRIVATE char *sqlite3VMPrintf(sqlite3 *db, const char *zFormat, v...
  function SQLITE_PRIVATE (line 23793) | SQLITE_PRIVATE char *sqlite3MPrintf(sqlite3 *db, const char *zFormat, ...){
  function SQLITE_API (line 23806) | SQLITE_API char *SQLITE_STDCALL sqlite3_vmprintf(const char *zFormat, va...
  function SQLITE_API (line 23830) | SQLITE_API char *SQLITE_CDECL sqlite3_mprintf(const char *zFormat, ...){
  function SQLITE_API (line 23855) | SQLITE_API char *SQLITE_STDCALL sqlite3_vsnprintf(int n, char *zBuf, con...
  function SQLITE_API (line 23869) | SQLITE_API char *SQLITE_CDECL sqlite3_snprintf(int n, char *zBuf, const ...
  function renderLogMsg (line 23892) | static void renderLogMsg(int iErrCode, const char *zFormat, va_list ap){
  function SQLITE_CDECL (line 23905) | SQLITE_CDECL sqlite3_log(int iErrCode, const char *zFormat, ...){
  function SQLITE_PRIVATE (line 23920) | SQLITE_PRIVATE void sqlite3DebugPrintf(const char *zFormat, ...){
  function SQLITE_PRIVATE (line 23939) | SQLITE_PRIVATE void sqlite3XPrintf(StrAccum *p, const char *zFormat, ...){
  function TreeView (line 23974) | static TreeView *sqlite3TreeViewPush(TreeView *p, u8 moreToFollow){
  function sqlite3TreeViewPop (line 23990) | static void sqlite3TreeViewPop(TreeView *p){
  function sqlite3TreeViewLine (line 24000) | static void sqlite3TreeViewLine(TreeView *p, const char *zFormat, ...){
  function sqlite3TreeViewItem (line 24024) | static void sqlite3TreeViewItem(TreeView *p, const char *zLabel,u8 moreF...
  function SQLITE_PRIVATE (line 24032) | SQLITE_PRIVATE void sqlite3TreeViewWith(TreeView *pView, const With *pWi...
  function SQLITE_PRIVATE (line 24072) | SQLITE_PRIVATE void sqlite3TreeViewSelect(TreeView *pView, const Select ...
  function SQLITE_PRIVATE (line 24180) | SQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView *pView, const Expr *pEx...
  function SQLITE_PRIVATE (line 24414) | SQLITE_PRIVATE void sqlite3TreeViewExprList(
  function SQLITE_WSD (line 24467) | static SQLITE_WSD struct sqlite3PrngType {
  function SQLITE_STDCALL (line 24476) | SQLITE_STDCALL sqlite3_randomness(int N, void *pBuf){
  function SQLITE_PRIVATE (line 24563) | SQLITE_PRIVATE void sqlite3PrngSaveState(void){
  function SQLITE_PRIVATE (line 24570) | SQLITE_PRIVATE void sqlite3PrngRestoreState(void){
  type SQLiteThread (line 24622) | struct SQLiteThread {
  function SQLITE_PRIVATE (line 24631) | SQLITE_PRIVATE int sqlite3ThreadCreate(
  function SQLITE_PRIVATE (line 24668) | SQLITE_PRIVATE int sqlite3ThreadJoin(SQLiteThread *p, void **ppOut){
  type SQLiteThread (line 24694) | struct SQLiteThread {
  function sqlite3ThreadProc (line 24703) | static unsigned __stdcall sqlite3ThreadProc(
  function SQLITE_PRIVATE (line 24726) | SQLITE_PRIVATE int sqlite3ThreadCreate(
  function SQLITE_PRIVATE (line 24764) | SQLITE_PRIVATE int sqlite3ThreadJoin(SQLiteThread *p, void **ppOut){
  type SQLiteThread (line 24799) | struct SQLiteThread {
  function SQLITE_PRIVATE (line 24806) | SQLITE_PRIVATE int sqlite3ThreadCreate(
  function SQLITE_PRIVATE (line 24830) | SQLITE_PRIVATE int sqlite3ThreadJoin(SQLiteThread *p, void **ppOut){
  function SQLITE_PRIVATE (line 25023) | SQLITE_PRIVATE u32 sqlite3Utf8Read(
  function sqlite3VdbeMemTranslate (line 25059) | int sqlite3VdbeMemTranslate(Mem *pMem, u8 desiredEnc){
  function SQLITE_PRIVATE (line 25202) | SQLITE_PRIVATE int sqlite3VdbeMemHandleBom(Mem *pMem){
  function SQLITE_PRIVATE (line 25240) | SQLITE_PRIVATE int sqlite3Utf8CharLen(const char *zIn, int nByte){
  function SQLITE_PRIVATE (line 25270) | SQLITE_PRIVATE int sqlite3Utf8To8(unsigned char *zIn){
  function SQLITE_PRIVATE (line 25294) | SQLITE_PRIVATE char *sqlite3Utf16to8(sqlite3 *db, const void *z, int nBy...
  function SQLITE_PRIVATE (line 25315) | SQLITE_PRIVATE int sqlite3Utf16ByteLen(const void *zIn, int nChar){
  function SQLITE_PRIVATE (line 25340) | SQLITE_PRIVATE void sqlite3UtfSelfTest(void){
  function SQLITE_PRIVATE (line 25418) | SQLITE_PRIVATE void sqlite3Coverage(int x){
  function SQLITE_PRIVATE (line 25436) | SQLITE_PRIVATE int sqlite3FaultSim(int iTest){
  function SQLITE_PRIVATE (line 25449) | SQLITE_PRIVATE int sqlite3IsNaN(double x){
  function SQLITE_PRIVATE (line 25497) | SQLITE_PRIVATE int sqlite3Strlen30(const char *z){
  function SQLITE_PRIVATE (line 25509) | SQLITE_PRIVATE char *sqlite3ColumnType(Column *pCol, char *zDflt){
  function SQLITE_NOINLINE (line 25519) | static SQLITE_NOINLINE void  sqlite3ErrorFinish(sqlite3 *db, int err_code){
  function SQLITE_PRIVATE (line 25529) | SQLITE_PRIVATE void sqlite3Error(sqlite3 *db, int err_code){
  function SQLITE_PRIVATE (line 25539) | SQLITE_PRIVATE void sqlite3SystemError(sqlite3 *db, int rc){
  function SQLITE_PRIVATE (line 25568) | SQLITE_PRIVATE void sqlite3ErrorWithMsg(sqlite3 *db, int err_code, const...
  function SQLITE_PRIVATE (line 25601) | SQLITE_PRIVATE void sqlite3ErrorMsg(Parse *pParse, const char *zFormat, ...
  function SQLITE_PRIVATE (line 25635) | SQLITE_PRIVATE int sqlite3Dequote(char *z){
  function SQLITE_PRIVATE (line 25667) | SQLITE_PRIVATE void sqlite3TokenInit(Token *p, char *z){
  function SQLITE_STDCALL (line 25685) | SQLITE_STDCALL sqlite3_stricmp(const char *zLeft, const char *zRight){
  function SQLITE_PRIVATE (line 25693) | SQLITE_PRIVATE int sqlite3StrICmp(const char *zLeft, const char *zRight){
  function SQLITE_STDCALL (line 25706) | SQLITE_STDCALL sqlite3_strnicmp(const char *zLeft, const char *zRight, i...
  function SQLITE_PRIVATE (line 25741) | SQLITE_PRIVATE int sqlite3AtoF(const char *z, double *pResult, int lengt...
  function compare2pow63 (line 25922) | static int compare2pow63(const char *zNum, int incr){
  function SQLITE_PRIVATE (line 25958) | SQLITE_PRIVATE int sqlite3Atoi64(const char *zNum, i64 *pNum, int length...
  function SQLITE_PRIVATE (line 26041) | SQLITE_PRIVATE int sqlite3DecOrHexToI64(const char *z, i64 *pOut){
  function SQLITE_PRIVATE (line 26072) | SQLITE_PRIVATE int sqlite3GetInt32(const char *zNum, int *pValue){
  function SQLITE_PRIVATE (line 26130) | SQLITE_PRIVATE int sqlite3Atoi(const char *z){
  function putVarint64 (line 26165) | static int SQLITE_NOINLINE putVarint64(unsigned char *p, u64 v){
  function SQLITE_PRIVATE (line 26189) | SQLITE_PRIVATE int sqlite3PutVarint(unsigned char *p, u64 v){
  function SQLITE_PRIVATE (line 26219) | SQLITE_PRIVATE u8 sqlite3GetVarint(const unsigned char *p, u64 *v){
  function SQLITE_PRIVATE (line 26390) | SQLITE_PRIVATE u8 sqlite3GetVarint32(const unsigned char *p, u32 *v){
  function SQLITE_PRIVATE (line 26513) | SQLITE_PRIVATE int sqlite3VarintLen(u64 v){
  function SQLITE_PRIVATE (line 26523) | SQLITE_PRIVATE u32 sqlite3Get4byte(const u8 *p){
  function SQLITE_PRIVATE (line 26543) | SQLITE_PRIVATE void sqlite3Put4byte(unsigned char *p, u32 v){
  function SQLITE_PRIVATE (line 26569) | SQLITE_PRIVATE u8 sqlite3HexToInt(int h){
  function SQLITE_PRIVATE (line 26587) | SQLITE_PRIVATE void *sqlite3HexToBlob(sqlite3 *db, const char *z, int n){
  function logBadConnection (line 26608) | static void logBadConnection(const char *zType){
  function SQLITE_PRIVATE (line 26629) | SQLITE_PRIVATE int sqlite3SafetyCheckOk(sqlite3 *db){
  function SQLITE_PRIVATE (line 26646) | SQLITE_PRIVATE int sqlite3SafetyCheckSickOrOk(sqlite3 *db){
  function SQLITE_PRIVATE (line 26666) | SQLITE_PRIVATE int sqlite3AddInt64(i64 *pA, i64 iB){
  function SQLITE_PRIVATE (line 26682) | SQLITE_PRIVATE int sqlite3SubInt64(i64 *pA, i64 iB){
  function SQLITE_PRIVATE (line 26695) | SQLITE_PRIVATE int sqlite3MulInt64(i64 *pA, i64 iB){
  function SQLITE_PRIVATE (line 26730) | SQLITE_PRIVATE int sqlite3AbsInt32(int x){
  function SQLITE_PRIVATE (line 26754) | SQLITE_PRIVATE void sqlite3FileSuffix3(const char *zBaseFilename, char *z){
  function SQLITE_PRIVATE (line 26773) | SQLITE_PRIVATE LogEst sqlite3LogEstAdd(LogEst a, LogEst b){
  function SQLITE_PRIVATE (line 26800) | SQLITE_PRIVATE LogEst sqlite3LogEst(u64 x){
  function SQLITE_PRIVATE (line 26818) | SQLITE_PRIVATE LogEst sqlite3LogEstFromDouble(double x){
  function SQLITE_PRIVATE (line 26839) | SQLITE_PRIVATE u64 sqlite3LogEstToInt(LogEst x){
  function SQLITE_PRIVATE (line 26882) | SQLITE_PRIVATE void sqlite3HashInit(Hash *pNew){
  function SQLITE_PRIVATE (line 26894) | SQLITE_PRIVATE void sqlite3HashClear(Hash *pH){
  function strHash (line 26914) | static unsigned int strHash(const char *z){
  function insertElement (line 26927) | static void insertElement(
  function rehash (line 26961) | static int rehash(Hash *pH, unsigned int new_size){
  function HashElem (line 27001) | static HashElem *findElementWithHash(
  function removeElementGivenHash (line 27035) | static void removeElementGivenHash(
  function SQLITE_PRIVATE (line 27070) | SQLITE_PRIVATE void *sqlite3HashFind(const Hash *pH, const char *pKey){
  function SQLITE_PRIVATE (line 27094) | SQLITE_PRIVATE void *sqlite3HashInsert(Hash *pH, const char *pKey, void ...
  function SQLITE_PRIVATE (line 27140) | SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){
  type unixShm (line 27491) | typedef struct unixShm unixShm;
  type unixShmNode (line 27492) | typedef struct unixShmNode unixShmNode;
  type unixInodeInfo (line 27493) | typedef struct unixInodeInfo unixInodeInfo;
  type UnixUnusedFd (line 27494) | typedef struct UnixUnusedFd UnixUnusedFd;
  type UnixUnusedFd (line 27502) | struct UnixUnusedFd {
  type unixFile (line 27512) | typedef struct unixFile unixFile;
  type unixFile (line 27513) | struct unixFile {
  function sqlite_uint64 (line 27667) | __inline__ sqlite_uint64 sqlite3Hwtime(void){
  function sqlite_uint64 (line 27675) | __declspec(naked) __inline sqlite_uint64 __cdecl sqlite3Hwtime(void){
  function sqlite_uint64 (line 27686) | __inline__ sqlite_uint64 sqlite3Hwtime(void){
  function sqlite_uint64 (line 27694) | __inline__ sqlite_uint64 sqlite3Hwtime(void){
  function sqlite3Hwtime (line 27718) | sqlite3Hwtime(void){ return ((sqlite_uint64)0); }
  function local_ioerr (line 27756) | static void local_ioerr(){
  function posixOpen (line 27847) | static int posixOpen(const char *zFile, int flags, int mode){
  type unix_syscall (line 27861) | struct unix_syscall {
  type stat (line 27879) | struct stat
  type stat (line 27892) | struct stat
  type stat (line 28009) | struct stat
  function robustFchown (line 28019) | static int robustFchown(int fd, uid_t uid, gid_t gid){
  function unixSetSystemCall (line 28033) | static int unixSetSystemCall(
  function sqlite3_syscall_ptr (line 28076) | static sqlite3_syscall_ptr unixGetSystemCall(
  function robust_open (line 28136) | static int robust_open(const char *z, int f, mode_t m){
  function unixEnterMutex (line 28187) | static void unixEnterMutex(void){
  function unixLeaveMutex (line 28190) | static void unixLeaveMutex(void){
  function unixMutexHeld (line 28194) | static int unixMutexHeld(void) {
  function lockTrace (line 28227) | static int lockTrace(int fd, int op, struct flock *p){
  function robust_ftruncate (line 28285) | static int robust_ftruncate(int h, sqlite3_int64 sz){
  function sqliteErrorFromPosixError (line 28310) | static int sqliteErrorFromPosixError(int posixError, int sqliteIOErr) {
  type vxworksFileId (line 28352) | struct vxworksFileId {
  type vxworksFileId (line 28364) | struct vxworksFileId
  function vxworksSimplifyName (line 28379) | static int vxworksSimplifyName(char *z, int n){
  type vxworksFileId (line 28413) | struct vxworksFileId
  type vxworksFileId (line 28414) | struct vxworksFileId
  type vxworksFileId (line 28415) | struct vxworksFileId
  function vxworksReleaseFileId (line 28455) | static void vxworksReleaseFileId(struct vxworksFileId *pId){
  type unixFileId (line 28567) | struct unixFileId {
  type unixInodeInfo (line 28585) | struct unixInodeInfo {
  function unixLogErrorAtLine (line 28627) | static int unixLogErrorAtLine(
  function robust_close (line 28692) | static void robust_close(unixFile *pFile, int h, int lineno){
  function storeLastErrno (line 28703) | static void storeLastErrno(unixFile *pFile, int error){
  function closePendingFds (line 28710) | static void closePendingFds(unixFile *pFile){
  function releaseInodeInfo (line 28728) | static void releaseInodeInfo(unixFile *pFile){
  function findInodeInfo (line 28762) | static int findInodeInfo(
  function fileHasMoved (line 28845) | static int fileHasMoved(unixFile *pFile){
  function verifyDbFile (line 28865) | static void verifyDbFile(unixFile *pFile){
  function unixCheckReservedLock (line 28898) | static int unixCheckReservedLock(sqlite3_file *id, int *pResOut){
  function unixFileLock (line 28958) | static int unixFileLock(unixFile *pFile, struct flock *pLock){
  function unixLock (line 29008) | static int unixLock(sqlite3_file *id, int eFileLock){
  function setPendingFd (line 29234) | static void setPendingFd(unixFile *pFile){
  function posixUnlock (line 29256) | static int posixUnlock(sqlite3_file *id, int eFileLock, int handleNFSUnl...
  function unixUnlock (line 29416) | static int unixUnlock(sqlite3_file *id, int eFileLock){
  function closeUnixFile (line 29438) | static int closeUnixFile(sqlite3_file *id){
  function unixClose (line 29473) | static int unixClose(sqlite3_file *id){
  function nolockCheckReservedLock (line 29518) | static int nolockCheckReservedLock(sqlite3_file *NotUsed, int *pResOut){
  function nolockLock (line 29523) | static int nolockLock(sqlite3_file *NotUsed, int NotUsed2){
  function nolockUnlock (line 29527) | static int nolockUnlock(sqlite3_file *NotUsed, int NotUsed2){
  function nolockClose (line 29535) | static int nolockClose(sqlite3_file *id) {
  function dotlockCheckReservedLock (line 29580) | static int dotlockCheckReservedLock(sqlite3_file *id, int *pResOut) {
  function dotlockLock (line 29621) | static int dotlockLock(sqlite3_file *id, int eFileLock) {
  function dotlockUnlock (line 29671) | static int dotlockUnlock(sqlite3_file *id, int eFileLock) {
  function dotlockClose (line 29714) | static int dotlockClose(sqlite3_file *id) {
  function robust_flock (line 29744) | static int robust_flock(int fd, int op){
  function flockCheckReservedLock (line 29760) | static int flockCheckReservedLock(sqlite3_file *id, int *pResOut){
  function flockLock (line 29840) | static int flockLock(sqlite3_file *id, int eFileLock) {
  function flockUnlock (line 29884) | static int flockUnlock(sqlite3_file *id, int eFileLock) {
  function flockClose (line 29918) | static int flockClose(sqlite3_file *id) {
  function semXCheckReservedLock (line 29947) | static int semXCheckReservedLock(sqlite3_file *id, int *pResOut) {
  function semXLock (line 30014) | static int semXLock(sqlite3_file *id, int eFileLock) {
  function semXUnlock (line 30047) | static int semXUnlock(sqlite3_file *id, int eFileLock) {
  function semXClose (line 30084) | static int semXClose(sqlite3_file *id) {
  type afpLockingContext (line 30119) | typedef struct afpLockingContext afpLockingContext;
  type afpLockingContext (line 30120) | struct afpLockingContext {
  type ByteRangeLockPB2 (line 30125) | struct ByteRangeLockPB2
  function afpSetLock (line 30143) | static int afpSetLock(
  function afpCheckReservedLock (line 30189) | static int afpCheckReservedLock(sqlite3_file *id, int *pResOut){
  function afpLock (line 30259) | static int afpLock(sqlite3_file *id, int eFileLock){
  function afpUnlock (line 30441) | static int afpUnlock(sqlite3_file *id, int eFileLock) {
  function afpClose (line 30544) | static int afpClose(sqlite3_file *id) {
  function nfsUnlock (line 30586) | static int nfsUnlock(sqlite3_file *id, int eFileLock){
  function seekAndRead (line 30622) | static int seekAndRead(unixFile *id, sqlite3_int64 offset, void *pBuf, i...
  function unixRead (line 30671) | static int unixRead(
  function seekAndWriteFd (line 30730) | static int seekAndWriteFd(
  function seekAndWrite (line 30776) | static int seekAndWrite(unixFile *id, i64 offset, const void *pBuf, int ...
  function unixWrite (line 30785) | static int unixWrite(
  function full_fsync (line 30920) | static int full_fsync(int fd, int fullSync, int dataOnly){
  function openDirectory (line 31016) | static int openDirectory(const char *zFilename, int *pFd){
  function unixSync (line 31053) | static int unixSync(sqlite3_file *id, int flags){
  function unixTruncate (line 31103) | static int unixTruncate(sqlite3_file *id, i64 nByte){
  function unixFileSize (line 31153) | static int unixFileSize(sqlite3_file *id, i64 *pSize){
  function fcntlSizeHint (line 31191) | static int fcntlSizeHint(unixFile *pFile, i64 nByte){
  function unixModeBit (line 31260) | static void unixModeBit(unixFile *pFile, unsigned char mask, int *pArg){
  function unixFileControl (line 31276) | static int unixFileControl(sqlite3_file *id, int op, void *pArg){
  function unixSectorSize (line 31372) | static int unixSectorSize(sqlite3_file *NotUsed){
  function unixSectorSize (line 31384) | static int unixSectorSize(sqlite3_file *id){
  function unixDeviceCharacteristics (line 31471) | static int unixDeviceCharacteristics(sqlite3_file *id){
  function unixGetpagesize (line 31492) | static int unixGetpagesize(void){
  type unixShmNode (line 31535) | struct unixShmNode {
  type unixShm (line 31566) | struct unixShm {
  function unixShmSystemLock (line 31587) | static int unixShmSystemLock(
  function unixShmRegionPerMap (line 31666) | static int unixShmRegionPerMap(void){
  function unixShmPurge (line 31680) | static void unixShmPurge(unixFile *pFd){
  function unixOpenSharedMemory (line 31740) | static int unixOpenSharedMemory(unixFile *pDbFd){
  function unixShmMap (line 31887) | static int unixShmMap(
  function unixShmLock (line 32025) | static int unixShmLock(
  function unixShmBarrier (line 32137) | static void unixShmBarrier(
  function unixShmUnmap (line 32153) | static int unixShmUnmap(
  function unixUnmapfile (line 32209) | static void unixUnmapfile(unixFile *pFd){
  function unixRemapfile (line 32234) | static void unixRemapfile(
  function unixMapfile (line 32326) | static int unixMapfile(unixFile *pFd, i64 nMap){
  function unixFetch (line 32363) | static int unixFetch(sqlite3_file *fd, i64 iOff, int nAmt, void **pp){
  function unixUnfetch (line 32394) | static int unixUnfetch(sqlite3_file *fd, i64 iOff, void *p){
  function sqlite3_io_methods (line 32614) | static const sqlite3_io_methods *autolockIoFinderImpl(
  function sqlite3_io_methods (line 32678) | static const sqlite3_io_methods *vxworksIoFinderImpl(
  type sqlite3_io_methods (line 32711) | typedef const sqlite3_io_methods *(*finder_type)(const char*,unixFile*);
  function fillInUnixFile (line 32724) | static int fillInUnixFile(
  type stat (line 32921) | struct stat
  function unixGetTempname (line 32941) | static int unixGetTempname(int nBuf, char *zBuf){
  function UnixUnusedFd (line 32989) | static UnixUnusedFd *findReusableFd(const char *zPath, int flags){
  function findCreateFileMode (line 33052) | static int findCreateFileMode(
  function unixOpen (line 33132) | static int unixOpen(
  function unixDelete (line 33388) | static int unixDelete(
  function unixAccess (line 33436) | static int unixAccess(
  function mkFullPathname (line 33462) | static int mkFullPathname(
  function unixFullPathname (line 33495) | static int unixFullPathname(
  function unixDlError (line 33597) | static void unixDlError(sqlite3_vfs *NotUsed, int nBuf, char *zBufOut){
  function unixDlClose (line 33630) | static void unixDlClose(sqlite3_vfs *NotUsed, void *pHandle){
  function unixRandomness (line 33644) | static int unixRandomness(sqlite3_vfs *NotUsed, int nBuf, char *zBuf){
  function unixSleep (line 33691) | static int unixSleep(sqlite3_vfs *NotUsed, int microseconds){
  function unixCurrentTimeInt64 (line 33731) | static int unixCurrentTimeInt64(sqlite3_vfs *NotUsed, sqlite3_int64 *piN...
  function unixCurrentTime (line 33763) | static int unixCurrentTime(sqlite3_vfs *NotUsed, double *prNow){
  function unixGetLastError (line 33781) | static int unixGetLastError(sqlite3_vfs *NotUsed, int NotUsed2, char *No...
  type proxyLockingContext (line 33952) | typedef struct proxyLockingContext proxyLockingContext;
  type proxyLockingContext (line 33953) | struct proxyLockingContext {
  function proxyGetLockPath (line 33970) | static int proxyGetLockPath(const char *dbPath, char *lPath, size_t maxL...
  function proxyCreateLockPath (line 34011) | static int proxyCreateLockPath(const char *lockPath){
  function proxyCreateUnixFile (line 34051) | static int proxyCreateUnixFile(
  type timespec (line 34142) | struct timespec
  function proxyGetHostID (line 34148) | static int proxyGetHostID(unsigned char *pHostID, int *pError){
  function proxyBreakConchLock (line 34188) | static int proxyBreakConchLock(unixFile *pFile, uuid_t myHostID){
  function proxyConchLock (line 34248) | static int proxyConchLock(unixFile *pFile, uuid_t myHostID, int lockType){
  function proxyTakeConch (line 34326) | static int proxyTakeConch(unixFile *pFile){
  function proxyReleaseConch (line 34548) | static int proxyReleaseConch(unixFile *pFile){
  function proxyCreateConchPathname (line 34578) | static int proxyCreateConchPathname(char *dbPath, char **pConchPath){
  function switchLockProxyPath (line 34615) | static int switchLockProxyPath(unixFile *pFile, const char *path) {
  function proxyGetDbPathForUnixFile (line 34651) | static int proxyGetDbPathForUnixFile(unixFile *pFile, char *dbPath){
  function proxyTransformUnixFile (line 34682) | static int proxyTransformUnixFile(unixFile *pFile, const char *path) {
  function proxyFileControl (line 34769) | static int proxyFileControl(sqlite3_file *id, int op, void *pArg){
  function proxyCheckReservedLock (line 34842) | static int proxyCheckReservedLock(sqlite3_file *id, int *pResOut) {
  function proxyLock (line 34881) | static int proxyLock(sqlite3_file *id, int eFileLock) {
  function proxyUnlock (line 34905) | static int proxyUnlock(sqlite3_file *id, int eFileLock) {
  function proxyClose (line 34924) | static int proxyClose(sqlite3_file *id) {
  function SQLITE_STDCALL (line 34986) | SQLITE_STDCALL sqlite3_os_init(void){
  function SQLITE_STDCALL (line 35085) | SQLITE_STDCALL sqlite3_os_end(void){
  function sqlite_uint64 (line 35187) | __inline__ sqlite_uint64 sqlite3Hwtime(void){
  function sqlite_uint64 (line 35195) | __declspec(naked) __inline sqlite_uint64 __cdecl sqlite3Hwtime(void){
  function sqlite_uint64 (line 35206) | __inline__ sqlite_uint64 sqlite3Hwtime(void){
  function sqlite_uint64 (line 35214) | __inline__ sqlite_uint64 sqlite3Hwtime(void){
  function sqlite3Hwtime (line 35238) | sqlite3Hwtime(void){ return ((sqlite_uint64)0); }
  function local_ioerr (line 35276) | static void local_ioerr(){
  type winShm (line 35531) | typedef struct winShm winShm;
  type winShmNode (line 35532) | typedef struct winShmNode winShmNode;
  type winceLock (line 35540) | typedef struct winceLock {
  type winFile (line 35552) | typedef struct winFile winFile;
  type winFile (line 35553) | struct winFile {
  type winMemData (line 35677) | typedef struct winMemData winMemData;
  type winMemData (line 35678) | struct winMemData {
  type winMemData (line 35694) | struct winMemData
  type win_syscall (line 35763) | struct win_syscall {
  function winSetSystemCall (line 36424) | static int winSetSystemCall(
  function sqlite3_syscall_ptr (line 36467) | static sqlite3_syscall_ptr winGetSystemCall(
  function SQLITE_STDCALL (line 36509) | SQLITE_STDCALL sqlite3_win32_compact_heap(LPUINT pnLargest){
  function SQLITE_STDCALL (line 36549) | SQLITE_STDCALL sqlite3_win32_reset_heap(){
  function SQLITE_STDCALL (line 36594) | SQLITE_STDCALL sqlite3_win32_write_debug(const char *zBuf, int nBuf){
  function SQLITE_STDCALL (line 36634) | SQLITE_STDCALL sqlite3_win32_sleep(DWORD milliseconds){
  function SQLITE_PRIVATE (line 36649) | SQLITE_PRIVATE DWORD sqlite3Win32Wait(HANDLE hObject){
  function SQLITE_STDCALL (line 36683) | SQLITE_STDCALL sqlite3_win32_is_nt(void){
  function winMemFree (line 36745) | static void winMemFree(void *pPrior){
  function winMemSize (line 36793) | static int winMemSize(void *p){
  function winMemRoundup (line 36817) | static int winMemRoundup(int n){
  function winMemInit (line 36824) | static int winMemInit(void *pAppData){
  function winMemShutdown (line 36873) | static void winMemShutdown(void *pAppData){
  function SQLITE_PRIVATE (line 36904) | SQLITE_PRIVATE const sqlite3_mem_methods *sqlite3MemGetWin32(void){
  function SQLITE_PRIVATE (line 36918) | SQLITE_PRIVATE void sqlite3MemSetDefault(void){
  function LPWSTR (line 36928) | static LPWSTR winUtf8ToUnicode(const char *zFilename){
  function LPWSTR (line 36981) | static LPWSTR winMbcsToUnicode(const char *zFilename){
  function SQLITE_API (line 37037) | SQLITE_API char *SQLITE_STDCALL sqlite3_win32_mbcs_to_utf8(const char *z...
  function SQLITE_API (line 37054) | SQLITE_API char *SQLITE_STDCALL sqlite3_win32_utf8_to_mbcs(const char *z...
  function SQLITE_STDCALL (line 37074) | SQLITE_STDCALL sqlite3_win32_set_directory(DWORD type, LPCWSTR zValue){
  function winGetLastErrorMsg (line 37109) | static int winGetLastErrorMsg(DWORD lastErrno, int nBuf, char *zBuf){
  function winLogErrorAtLine (line 37200) | static int winLogErrorAtLine(
  function winRetryIoerr (line 37270) | static int winRetryIoerr(int *pnRetry, DWORD *pError){
  function winLogIoerr (line 37299) | static void winLogIoerr(int nRetry, int lineno){
  type tm (line 37318) | struct tm
  type tm (line 37320) | struct tm
  function winceMutexAcquire (line 37346) | static void winceMutexAcquire(HANDLE h){
  function winceCreateLock (line 37361) | static int winceCreateLock(const char *zFilename, winFile *pFile){
  function winceDestroyLock (line 37455) | static void winceDestroyLock(winFile *pFile){
  function BOOL (line 37489) | static BOOL winceLockFile(
  function BOOL (line 37555) | static BOOL winceUnlockFile(
  function BOOL (line 37624) | static BOOL winLockFile(
  function BOOL (line 37656) | static BOOL winUnlockFile(
  function winSeekFile (line 37701) | static int winSeekFile(winFile *pFile, sqlite3_int64 iOffset){
  function winClose (line 37774) | static int winClose(sqlite3_file *id){
  function winTruncate (line 38014) | static int winTruncate(sqlite3_file *id, sqlite3_int64 nByte){
  function winSync (line 38071) | static int winSync(sqlite3_file *id, int flags){
  function winFileSize (line 38156) | static int winFileSize(sqlite3_file *id, sqlite3_int64 *pSize){
  function winGetReadLock (line 38234) | static int winGetReadLock(winFile *pFile){
  function winUnlockReadLock (line 38269) | static int winUnlockReadLock(winFile *pFile){
  function winLock (line 38316) | static int winLock(sqlite3_file *id, int locktype){
  function winCheckReservedLock (line 38460) | static int winCheckReservedLock(sqlite3_file *id, int *pResOut){
  function winUnlock (line 38496) | static int winUnlock(sqlite3_file *id, int locktype){
  function winModeBit (line 38535) | static void winModeBit(winFile *pFile, unsigned char mask, int *pArg){
  function winFileControl (line 38553) | static int winFileControl(sqlite3_file *id, int op, void *pArg){
  function winSectorSize (line 38674) | static int winSectorSize(sqlite3_file *id){
  function winDeviceCharacteristics (line 38682) | static int winDeviceCharacteristics(sqlite3_file *id){
  function winShmEnterMutex (line 38711) | static void winShmEnterMutex(void){
  function winShmLeaveMutex (line 38714) | static void winShmLeaveMutex(void){
  function winShmMutexHeld (line 38718) | static int winShmMutexHeld(void) {
  type winShmNode (line 38746) | struct winShmNode {
  type winShm (line 38787) | struct winShm {
  function winShmSystemLock (line 38810) | static int winShmSystemLock(
  function winShmPurge (line 38858) | static void winShmPurge(sqlite3_vfs *pVfs, int deleteFlag){
  function winOpenSharedMemory (line 38907) | static int winOpenSharedMemory(winFile *pDbFd){
  function winShmUnmap (line 39018) | static int winShmUnmap(
  function winShmLock (line 39059) | static int winShmLock(
  function winShmBarrier (line 39168) | static void winShmBarrier(
  function winShmMap (line 39196) | static int winShmMap(
  function winUnmapfile (line 39336) | static int winUnmapfile(winFile *pFile){
  function winMapfile (line 39386) | static int winMapfile(winFile *pFd, sqlite3_int64 nByte){
  function winFetch (line 39485) | static int winFetch(sqlite3_file *fd, i64 iOff, int nAmt, void **pp){
  function winUnfetch (line 39526) | static int winUnfetch(sqlite3_file *fd, i64 iOff, void *p){
  function winMakeEndInDirSep (line 39644) | static int winMakeEndInDirSep(int nBuf, char *zBuf){
  function winGetTempname (line 39664) | static int winGetTempname(sqlite3_vfs *pVfs, char **pzBuf){
  function winIsDir (line 39895) | static int winIsDir(const void *zConverted){
  function winOpen (line 39922) | static int winOpen(
  function winDelete (line 40213) | static int winDelete(
  function winAccess (line 40321) | static int winAccess(
  function BOOL (line 40399) | static BOOL winIsDriveLetterAndColon(
  function BOOL (line 40411) | static BOOL winIsVerbatimPathname(
  function winFullPathname (line 40447) | static int winFullPathname(
  function winDlError (line 40671) | static void winDlError(sqlite3_vfs *pVfs, int nBuf, char *zBufOut){
  function winDlClose (line 40683) | static void winDlClose(sqlite3_vfs *pVfs, void *pHandle){
  type EntropyGatherer (line 40696) | typedef struct EntropyGatherer EntropyGatherer;
  type EntropyGatherer (line 40697) | struct EntropyGatherer {
  function xorMemory (line 40706) | static void xorMemory(EntropyGatherer *p, unsigned char *x, int sz){
  function winRandomness (line 40720) | static int winRandomness(sqlite3_vfs *pVfs, int nBuf, char *zBuf){
  function winSleep (line 40780) | static int winSleep(sqlite3_vfs *pVfs, int microsec){
  function winCurrentTimeInt64 (line 40805) | static int winCurrentTimeInt64(sqlite3_vfs *pVfs, sqlite3_int64 *piNow){
  function winCurrentTime (line 40848) | static int winCurrentTime(sqlite3_vfs *pVfs, double *prNow){
  function winGetLastError (line 40888) | static int winGetLastError(sqlite3_vfs *pVfs, int nBuf, char *zBuf){
  function SQLITE_STDCALL (line 40898) | SQLITE_STDCALL sqlite3_os_init(void){
  function SQLITE_STDCALL (line 40973) | SQLITE_STDCALL sqlite3_os_end(void){
  type Bitvec (line 41080) | struct Bitvec {
  function SQLITE_PRIVATE (line 41101) | SQLITE_PRIVATE Bitvec *sqlite3BitvecCreate(u32 iSize){
  function SQLITE_PRIVATE (line 41116) | SQLITE_PRIVATE int sqlite3BitvecTestNotNull(Bitvec *p, u32 i){
  function SQLITE_PRIVATE (line 41139) | SQLITE_PRIVATE int sqlite3BitvecTest(Bitvec *p, u32 i){
  function SQLITE_PRIVATE (line 41155) | SQLITE_PRIVATE int sqlite3BitvecSet(Bitvec *p, u32 i){
  function SQLITE_PRIVATE (line 41226) | SQLITE_PRIVATE void sqlite3BitvecClear(Bitvec *p, u32 i, void *pBuf){
  function SQLITE_PRIVATE (line 41263) | SQLITE_PRIVATE void sqlite3BitvecDestroy(Bitvec *p){
  function SQLITE_PRIVATE (line 41278) | SQLITE_PRIVATE u32 sqlite3BitvecSize(Bitvec *p){
  function SQLITE_PRIVATE (line 41323) | SQLITE_PRIVATE int sqlite3BitvecBuiltinTest(int sz, int *aOp){
  type PCache (line 41419) | struct PCache {
  function pcacheManageDirtyList (line 41447) | static void pcacheManageDirtyList(PgHdr *pPage, u8 addRemove){
  function pcacheUnpin (line 41507) | static void pcacheUnpin(PgHdr *p){
  function numberOfCachePages (line 41517) | static int numberOfCachePages(PCache *p){
  function SQLITE_PRIVATE (line 41535) | SQLITE_PRIVATE int sqlite3PcacheInitialize(void){
  function SQLITE_PRIVATE (line 41544) | SQLITE_PRIVATE void sqlite3PcacheShutdown(void){
  function SQLITE_PRIVATE (line 41554) | SQLITE_PRIVATE int sqlite3PcacheSize(void){ return sizeof(PCache); }
  function SQLITE_PRIVATE (line 41562) | SQLITE_PRIVATE int sqlite3PcacheOpen(
  function SQLITE_PRIVATE (line 41586) | SQLITE_PRIVATE int sqlite3PcacheSetPageSize(PCache *pCache, int szPage){
  function SQLITE_PRIVATE (line 41629) | SQLITE_PRIVATE sqlite3_pcache_page *sqlite3PcacheFetch(
  function SQLITE_PRIVATE (line 41666) | SQLITE_PRIVATE int sqlite3PcacheFetchStress(
  function SQLITE_NOINLINE (line 41716) | static SQLITE_NOINLINE PgHdr *pcacheFetchFinishWithInit(
  function SQLITE_PRIVATE (line 41742) | SQLITE_PRIVATE PgHdr *sqlite3PcacheFetchFinish(
  function SQLITE_NOINLINE (line 41764) | SQLITE_NOINLINE sqlite3PcacheRelease(PgHdr *p){
  function SQLITE_PRIVATE (line 41780) | SQLITE_PRIVATE void sqlite3PcacheRef(PgHdr *p){
  function SQLITE_PRIVATE (line 41791) | SQLITE_PRIVATE void sqlite3PcacheDrop(PgHdr *p){
  function SQLITE_PRIVATE (line 41804) | SQLITE_PRIVATE void sqlite3PcacheMakeDirty(PgHdr *p){
  function SQLITE_PRIVATE (line 41820) | SQLITE_PRIVATE void sqlite3PcacheMakeClean(PgHdr *p){
  function SQLITE_PRIVATE (line 41835) | SQLITE_PRIVATE void sqlite3PcacheCleanAll(PCache *pCache){
  function SQLITE_PRIVATE (line 41845) | SQLITE_PRIVATE void sqlite3PcacheClearSyncFlags(PCache *pCache){
  function SQLITE_PRIVATE (line 41856) | SQLITE_PRIVATE void sqlite3PcacheMove(PgHdr *p, Pgno newPgno){
  function SQLITE_PRIVATE (line 41876) | SQLITE_PRIVATE void sqlite3PcacheTruncate(PCache *pCache, Pgno pgno){
  function SQLITE_PRIVATE (line 41908) | SQLITE_PRIVATE void sqlite3PcacheClose(PCache *pCache){
  function SQLITE_PRIVATE (line 41916) | SQLITE_PRIVATE void sqlite3PcacheClear(PCache *pCache){
  function PgHdr (line 41924) | static PgHdr *pcacheMergeDirtyList(PgHdr *pA, PgHdr *pB){
  function PgHdr (line 41959) | static PgHdr *pcacheSortDirtyList(PgHdr *pIn){
  function SQLITE_PRIVATE (line 41993) | SQLITE_PRIVATE PgHdr *sqlite3PcacheDirtyList(PCache *pCache){
  function SQLITE_PRIVATE (line 42007) | SQLITE_PRIVATE int sqlite3PcacheRefCount(PCache *pCache){
  function SQLITE_PRIVATE (line 42014) | SQLITE_PRIVATE int sqlite3PcachePageRefcount(PgHdr *p){
  function SQLITE_PRIVATE (line 42021) | SQLITE_PRIVATE int sqlite3PcachePagecount(PCache *pCache){
  function SQLITE_PRIVATE (line 42030) | SQLITE_PRIVATE int sqlite3PcacheGetCachesize(PCache *pCache){
  function SQLITE_PRIVATE (line 42038) | SQLITE_PRIVATE void sqlite3PcacheSetCachesize(PCache *pCache, int mxPage){
  function SQLITE_PRIVATE (line 42050) | SQLITE_PRIVATE int sqlite3PcacheSetSpillsize(PCache *p, int mxPage){
  function SQLITE_PRIVATE (line 42067) | SQLITE_PRIVATE void sqlite3PcacheShrink(PCache *pCache){
  function SQLITE_PRIVATE (line 42076) | SQLITE_PRIVATE int sqlite3HeaderSizePcache(void){ return ROUND8(sizeof(P...
  function SQLITE_PRIVATE (line 42085) | SQLITE_PRIVATE void sqlite3PcacheIterateDirty(PCache *pCache, void (*xIt...
  type PCache1 (line 42179) | typedef struct PCache1 PCache1;
  type PgHdr1 (line 42180) | typedef struct PgHdr1 PgHdr1;
  type PgFreeslot (line 42181) | typedef struct PgFreeslot PgFreeslot;
  type PGroup (line 42182) | typedef struct PGroup PGroup;
  type PgHdr1 (line 42190) | struct PgHdr1 {
  type PGroup (line 42224) | struct PGroup {
  type PCache1 (line 42241) | struct PCache1 {
  type PgFreeslot (line 42272) | struct PgFreeslot {
  function SQLITE_WSD (line 42279) | static SQLITE_WSD struct PCacheGlobal {
  function SQLITE_PRIVATE (line 42338) | SQLITE_PRIVATE void sqlite3PCacheBufferSetup(void *pBuf, int sz, int n){
  function pcache1InitBulk (line 42363) | static int pcache1InitBulk(PCache1 *pCache){
  function pcache1Free (line 42444) | static void pcache1Free(void *p){
  function pcache1MemSize (line 42477) | static int pcache1MemSize(void *p){
  function PgHdr1 (line 42494) | static PgHdr1 *pcache1AllocPage(PCache1 *pCache, int benignMalloc){
  function pcache1FreePage (line 42544) | static void pcache1FreePage(PgHdr1 *p){
  function SQLITE_PRIVATE (line 42568) | SQLITE_PRIVATE void *sqlite3PageMalloc(int sz){
  function SQLITE_PRIVATE (line 42575) | SQLITE_PRIVATE void sqlite3PageFree(void *p){
  function pcache1UnderMemoryPressure (line 42596) | static int pcache1UnderMemoryPressure(PCache1 *pCache){
  function pcache1ResizeHash (line 42613) | static void pcache1ResizeHash(PCache1 *p){
  function PgHdr1 (line 42654) | static PgHdr1 *pcache1PinPage(PgHdr1 *pPage){
  function pcache1RemoveFromHash (line 42682) | static void pcache1RemoveFromHash(PgHdr1 *pPage, int freeFlag){
  function pcache1EnforceMaxPage (line 42700) | static void pcache1EnforceMaxPage(PCache1 *pCache){
  function pcache1TruncateUnsafe (line 42725) | static void pcache1TruncateUnsafe(
  function pcache1Init (line 42756) | static int pcache1Init(void *NotUsed){
  function pcache1Shutdown (line 42809) | static void pcache1Shutdown(void *NotUsed){
  function sqlite3_pcache (line 42823) | static sqlite3_pcache *pcache1Create(int szPage, int szExtra, int bPurge...
  function pcache1Cachesize (line 42870) | static void pcache1Cachesize(sqlite3_pcache *p, int nMax){
  function pcache1Shrink (line 42889) | static void pcache1Shrink(sqlite3_pcache *p){
  function pcache1Pagecount (line 42906) | static int pcache1Pagecount(sqlite3_pcache *p){
  function SQLITE_NOINLINE (line 42924) | static SQLITE_NOINLINE PgHdr1 *pcache1FetchStage2(
  function PgHdr1 (line 43052) | static PgHdr1 *pcache1FetchNoMutex(
  function PgHdr1 (line 43082) | static PgHdr1 *pcache1FetchWithMutex(
  function sqlite3_pcache_page (line 43097) | static sqlite3_pcache_page *pcache1Fetch(
  function pcache1Unpin (line 43128) | static void pcache1Unpin(
  function pcache1Rekey (line 43164) | static void pcache1Rekey(
  function pcache1Truncate (line 43204) | static void pcache1Truncate(sqlite3_pcache *p, unsigned int iLimit){
  function pcache1Destroy (line 43219) | static void pcache1Destroy(sqlite3_pcache *p){
  function SQLITE_PRIVATE (line 43242) | SQLITE_PRIVATE void sqlite3PCacheSetDefault(void){
  function SQLITE_PRIVATE (line 43264) | SQLITE_PRIVATE int sqlite3HeaderSizePcache1(void){ return ROUND8(sizeof(...
  function SQLITE_PRIVATE (line 43270) | SQLITE_PRIVATE sqlite3_mutex *sqlite3Pcache1Mutex(void){
  function SQLITE_PRIVATE (line 43284) | SQLITE_PRIVATE int sqlite3PcacheReleaseMemory(int nReq){
  function SQLITE_PRIVATE (line 43314) | SQLITE_PRIVATE void sqlite3PcacheStats(
  type RowSetEntry (line 43419) | struct RowSetEntry {
  type RowSetChunk (line 43431) | struct RowSetChunk {
  type RowSet (line 43441) | struct RowSet {
  function SQLITE_PRIVATE (line 43471) | SQLITE_PRIVATE RowSet *sqlite3RowSetInit(sqlite3 *db, void *pSpace, unsi...
  function SQLITE_PRIVATE (line 43492) | SQLITE_PRIVATE void sqlite3RowSetClear(RowSet *p){
  type RowSetEntry (line 43514) | struct RowSetEntry
  type RowSetChunk (line 43517) | struct RowSetChunk
  function SQLITE_PRIVATE (line 43537) | SQLITE_PRIVATE void sqlite3RowSetInsert(RowSet *p, i64 rowid){
  type RowSetEntry (line 43566) | struct RowSetEntry
  type RowSetEntry (line 43567) | struct RowSetEntry
  type RowSetEntry (line 43568) | struct RowSetEntry
  type RowSetEntry (line 43570) | struct RowSetEntry
  type RowSetEntry (line 43571) | struct RowSetEntry
  type RowSetEntry (line 43603) | struct RowSetEntry
  type RowSetEntry (line 43603) | struct RowSetEntry
  type RowSetEntry (line 43605) | struct RowSetEntry
  function rowSetTreeToList (line 43631) | static void rowSetTreeToList(
  type RowSetEntry (line 43666) | struct RowSetEntry
  type RowSetEntry (line 43667) | struct RowSetEntry
  type RowSetEntry (line 43670) | struct RowSetEntry
  type RowSetEntry (line 43671) | struct RowSetEntry
  type RowSetEntry (line 43696) | struct RowSetEntry
  type RowSetEntry (line 43696) | struct RowSetEntry
  type RowSetEntry (line 43698) | struct RowSetEntry
  type RowSetEntry (line 43699) | struct RowSetEntry
  function rowSetToList (line 43721) | static void rowSetToList(RowSet *p){
  function SQLITE_PRIVATE (line 43757) | SQLITE_PRIVATE int sqlite3RowSetNext(RowSet *p, i64 *pRowid){
  function SQLITE_PRIVATE (line 43784) | SQLITE_PRIVATE int sqlite3RowSetTest(RowSet *pRowSet, int iBatch, sqlite...
  type Wal (line 43924) | typedef struct Wal Wal;
  type PagerSavepoint (line 44440) | typedef struct PagerSavepoint PagerSavepoint;
  type PagerSavepoint (line 44441) | struct PagerSavepoint {
  type Pager (line 44615) | struct Pager {
  function pagerUseWal (line 44815) | static int pagerUseWal(Pager *pPager){
  function assert_pager_state (line 44835) | static int assert_pager_state(Pager *p){
  function subjRequiresPage (line 45024) | static int subjRequiresPage(PgHdr *pPg){
  function pageInJournal (line 45042) | static int pageInJournal(Pager *pPager, PgHdr *pPg){
  function read32bits (line 45054) | static int read32bits(sqlite3_file *fd, i64 offset, u32 *pRes){
  function write32bits (line 45073) | static int write32bits(sqlite3_file *fd, i64 offset, u32 val){
  function pagerUnlockDb (line 45088) | static int pagerUnlockDb(Pager *pPager, int eLock){
  function pagerLockDb (line 45115) | static int pagerLockDb(Pager *pPager, int eLock){
  function jrnlBufferSize (line 45147) | static int jrnlBufferSize(Pager *pPager){
  function u32 (line 45179) | static u32 pager_datahash(int nByte, unsigned char *pData){
  function u32 (line 45187) | static u32 pager_pagehash(PgHdr *pPage){
  function pager_set_pagehash (line 45190) | static void pager_set_pagehash(PgHdr *pPage){
  function checkPage (line 45200) | static void checkPage(PgHdr *pPg){
  function readMasterJournal (line 45238) | static int readMasterJournal(sqlite3_file *pJrnl, char *zMaster, u32 nMa...
  function i64 (line 45292) | static i64 journalHdrOffset(Pager *pPager){
  function zeroJournalHdr (line 45325) | static int zeroJournalHdr(Pager *pPager, int doTruncate){
  function writeJournalHdr (line 45375) | static int writeJournalHdr(Pager *pPager){
  function readJournalHdr (line 45493) | static int readJournalHdr(
  function writeMasterJournal (line 45618) | static int writeMasterJournal(Pager *pPager, const char *zMaster){
  function pager_reset (line 45686) | static void pager_reset(Pager *pPager){
  function SQLITE_PRIVATE (line 45695) | SQLITE_PRIVATE u32 sqlite3PagerDataVersion(Pager *pPager){
  function releaseAllSavepoints (line 45705) | static void releaseAllSavepoints(Pager *pPager){
  function addToSavepointBitvecs (line 45724) | static int addToSavepointBitvecs(Pager *pPager, Pgno pgno){
  function pager_unlock (line 45756) | static void pager_unlock(Pager *pPager){
  function pager_error (line 45849) | static int pager_error(Pager *pPager, int rc){
  function pager_end_transaction (line 45919) | static int pager_end_transaction(Pager *pPager, int hasMaster, int bComm...
  function pagerUnlockAndRollback (line 46059) | static void pagerUnlockAndRollback(Pager *pPager){
  function u32 (line 46093) | static u32 pager_cksum(Pager *pPager, const u8 *aData){
  function pagerReportSize (line 46108) | static void pagerReportSize(Pager *pPager){
  function SQLITE_PRIVATE (line 46124) | SQLITE_PRIVATE void sqlite3PagerAlignReserve(Pager *pDest, Pager *pSrc){
  function pager_playback_one_page (line 46169) | static int pager_playback_one_page(
  function pager_delmaster (line 46434) | static int pager_delmaster(Pager *pPager, const char *zMaster){
  function pager_truncate (line 46544) | static int pager_truncate(Pager *pPager, Pgno nPage){
  function SQLITE_PRIVATE (line 46580) | SQLITE_PRIVATE int sqlite3SectorSize(sqlite3_file *pFile){
  function setSectorSize (line 46614) | static void setSectorSize(Pager *pPager){
  function pager_playback (line 46687) | static int pager_playback(Pager *pPager, int isHot){
  function readDbPage (line 46895) | static int readDbPage(PgHdr *pPg, u32 iFrame){
  function pager_write_changecounter (line 46957) | static void pager_write_changecounter(PgHdr *pPg){
  function pagerUndoCallback (line 46984) | static int pagerUndoCallback(void *pCtx, Pgno iPg){
  function pagerRollbackWal (line 47023) | static int pagerRollbackWal(Pager *pPager){
  function pagerWalFrames (line 47055) | static int pagerWalFrames(
  function pagerBeginReadTransaction (line 47122) | static int pagerBeginReadTransaction(Pager *pPager){
  function pagerPagecount (line 47155) | static int pagerPagecount(Pager *pPager, Pgno *pnPage){
  function pagerOpenWalIfPresent (line 47216) | static int pagerOpenWalIfPresent(Pager *pPager){
  function pagerPlaybackSavepoint (line 47285) | static int pagerPlaybackSavepoint(Pager *pPager, PagerSavepoint *pSavepo...
  function SQLITE_PRIVATE (line 47397) | SQLITE_PRIVATE void sqlite3PagerSetCachesize(Pager *pPager, int mxPage){
  function SQLITE_PRIVATE (line 47405) | SQLITE_PRIVATE int sqlite3PagerSetSpillsize(Pager *pPager, int mxPage){
  function pagerFixMaplimit (line 47412) | static void pagerFixMaplimit(Pager *pPager){
  function SQLITE_PRIVATE (line 47427) | SQLITE_PRIVATE void sqlite3PagerSetMmapLimit(Pager *pPager, sqlite3_int6...
  function SQLITE_PRIVATE (line 47435) | SQLITE_PRIVATE void sqlite3PagerShrink(Pager *pPager){
  function SQLITE_PRIVATE (line 47491) | SQLITE_PRIVATE void sqlite3PagerSetFlags(
  function pagerOpentemp (line 47554) | static int pagerOpentemp(
  function SQLITE_PRIVATE (line 47593) | SQLITE_PRIVATE void sqlite3PagerSetBusyhandler(
  function SQLITE_PRIVATE (line 47639) | SQLITE_PRIVATE int sqlite3PagerSetPagesize(Pager *pPager, u32 *pPageSize...
  function SQLITE_PRIVATE (line 47702) | SQLITE_PRIVATE void *sqlite3PagerTempSpace(Pager *pPager){
  function SQLITE_PRIVATE (line 47713) | SQLITE_PRIVATE int sqlite3PagerMaxPageCount(Pager *pPager, int mxPage){
  function disable_simulated_io_errors (line 47734) | void disable_simulated_io_errors(void){
  function enable_simulated_io_errors (line 47738) | void enable_simulated_io_errors(void){
  function SQLITE_PRIVATE (line 47760) | SQLITE_PRIVATE int sqlite3PagerReadFileheader(Pager *pPager, int N, unsi...
  function SQLITE_PRIVATE (line 47788) | SQLITE_PRIVATE void sqlite3PagerPagecount(Pager *pPager, int *pnPage){
  function pager_wait_on_lock (line 47809) | static int pager_wait_on_lock(Pager *pPager, int locktype){
  function assertTruncateConstraintCb (line 47851) | static void assertTruncateConstraintCb(PgHdr *pPg){
  function assertTruncateConstraint (line 47855) | static void assertTruncateConstraint(Pager *pPager){
  function SQLITE_PRIVATE (line 47873) | SQLITE_PRIVATE void sqlite3PagerTruncateImage(Pager *pPager, Pgno nPage){
  function pagerSyncHotJournal (line 47904) | static int pagerSyncHotJournal(Pager *pPager){
  function pagerAcquireMapPage (line 47925) | static int pagerAcquireMapPage(
  function pagerReleaseMapPage (line 47967) | static void pagerReleaseMapPage(PgHdr *pPg){
  function pagerFreeMapHdrs (line 47980) | static void pagerFreeMapHdrs(Pager *pPager){
  function SQLITE_PRIVATE (line 48004) | SQLITE_PRIVATE int sqlite3PagerClose(Pager *pPager){
  function SQLITE_PRIVATE (line 48061) | SQLITE_PRIVATE Pgno sqlite3PagerPagenumber(DbPage *pPg){
  function SQLITE_PRIVATE (line 48069) | SQLITE_PRIVATE void sqlite3PagerRef(DbPage *pPg){
  function syncJournal (line 48108) | static int syncJournal(Pager *pPager, int newHdr){
  function pager_write_pagelist (line 48251) | static int pager_write_pagelist(Pager *pPager, PgHdr *pList){
  function openSubJournal (line 48342) | static int openSubJournal(Pager *pPager){
  function subjournalPage (line 48368) | static int subjournalPage(PgHdr *pPg){
  function subjournalPageIfRequired (line 48405) | static int subjournalPageIfRequired(PgHdr *pPg){
  function pagerStress (line 48432) | static int pagerStress(void *p, PgHdr *pPg){
  function SQLITE_PRIVATE (line 48501) | SQLITE_PRIVATE int sqlite3PagerFlush(Pager *pPager){
  function SQLITE_PRIVATE (line 48548) | SQLITE_PRIVATE int sqlite3PagerOpen(
  function databaseIsUnmoved (line 48841) | static int databaseIsUnmoved(Pager *pPager){
  function hasHotJournal (line 48892) | static int hasHotJournal(Pager *pPager, int *pExists){
  function SQLITE_PRIVATE (line 49011) | SQLITE_PRIVATE int sqlite3PagerSharedLock(Pager *pPager){
  function pagerUnlockIfUnused (line 49233) | static void pagerUnlockIfUnused(Pager *pPager){
  function SQLITE_PRIVATE (line 49289) | SQLITE_PRIVATE int sqlite3PagerGet(
  function SQLITE_PRIVATE (line 49471) | SQLITE_PRIVATE DbPage *sqlite3PagerLookup(Pager *pPager, Pgno pgno){
  function SQLITE_PRIVATE (line 49490) | SQLITE_PRIVATE void sqlite3PagerUnrefNotNull(DbPage *pPg){
  function SQLITE_PRIVATE (line 49501) | SQLITE_PRIVATE void sqlite3PagerUnref(DbPage *pPg){
  function pager_open_journal (line 49527) | static int pager_open_journal(Pager *pPager){
  function SQLITE_PRIVATE (line 49616) | SQLITE_PRIVATE int sqlite3PagerBegin(Pager *pPager, int exFlag, int subj...
  function SQLITE_NOINLINE (line 49685) | static SQLITE_NOINLINE int pagerAddPageToRollbackJournal(PgHdr *pPg){
  function pager_write (line 49742) | static int pager_write(PgHdr *pPg){
  function SQLITE_NOINLINE (line 49834) | static SQLITE_NOINLINE int pagerWriteLargeSector(PgHdr *pPg){
  function SQLITE_PRIVATE (line 49928) | SQLITE_PRIVATE int sqlite3PagerWrite(PgHdr *pPg){
  function SQLITE_PRIVATE (line 49951) | SQLITE_PRIVATE int sqlite3PagerIswriteable(DbPage *pPg){
  function SQLITE_PRIVATE (line 49970) | SQLITE_PRIVATE void sqlite3PagerDontWrite(PgHdr *pPg){
  function pager_incr_changecounter (line 50003) | static int pager_incr_changecounter(Pager *pPager, int isDirectMode){
  function SQLITE_PRIVATE (line 50086) | SQLITE_PRIVATE int sqlite3PagerSync(Pager *pPager, const char *zMaster){
  function SQLITE_PRIVATE (line 50112) | SQLITE_PRIVATE int sqlite3PagerExclusiveLock(Pager *pPager){
  function SQLITE_PRIVATE (line 50154) | SQLITE_PRIVATE int sqlite3PagerCommitPhaseOne(
  function SQLITE_PRIVATE (line 50327) | SQLITE_PRIVATE int sqlite3PagerCommitPhaseTwo(Pager *pPager){
  function SQLITE_PRIVATE (line 50393) | SQLITE_PRIVATE int sqlite3PagerRollback(Pager *pPager){
  function SQLITE_PRIVATE (line 50442) | SQLITE_PRIVATE u8 sqlite3PagerIsreadonly(Pager *pPager){
  function SQLITE_PRIVATE (line 50450) | SQLITE_PRIVATE int sqlite3PagerRefcount(Pager *pPager){
  function SQLITE_PRIVATE (line 50459) | SQLITE_PRIVATE int sqlite3PagerMemUsed(Pager *pPager){
  function SQLITE_PRIVATE (line 50470) | SQLITE_PRIVATE int sqlite3PagerPageRefcount(DbPage *pPage){
  function SQLITE_PRIVATE (line 50478) | SQLITE_PRIVATE int *sqlite3PagerStats(Pager *pPager){
  function SQLITE_PRIVATE (line 50502) | SQLITE_PRIVATE void sqlite3PagerCacheStat(Pager *pPager, int eStat, int ...
  function SQLITE_PRIVATE (line 50522) | SQLITE_PRIVATE int sqlite3PagerIsMemdb(Pager *pPager){
  function SQLITE_NOINLINE (line 50536) | static SQLITE_NOINLINE int pagerOpenSavepoint(Pager *pPager, int nSavepo...
  function SQLITE_PRIVATE (line 50581) | SQLITE_PRIVATE int sqlite3PagerOpenSavepoint(Pager *pPager, int nSavepoi...
  function SQLITE_PRIVATE (line 50623) | SQLITE_PRIVATE int sqlite3PagerSavepoint(Pager *pPager, int op, int iSav...
  function SQLITE_PRIVATE (line 50680) | SQLITE_PRIVATE const char *sqlite3PagerFilename(Pager *pPager, int nullI...
  function SQLITE_PRIVATE (line 50687) | SQLITE_PRIVATE sqlite3_vfs *sqlite3PagerVfs(Pager *pPager){
  function SQLITE_PRIVATE (line 50696) | SQLITE_PRIVATE sqlite3_file *sqlite3PagerFile(Pager *pPager){
  function SQLITE_PRIVATE (line 50704) | SQLITE_PRIVATE sqlite3_file *sqlite3PagerJrnlFile(Pager *pPager){
  function SQLITE_PRIVATE (line 50715) | SQLITE_PRIVATE const char *sqlite3PagerJournalname(Pager *pPager){
  function SQLITE_PRIVATE (line 50723) | SQLITE_PRIVATE void sqlite3PagerSetCodec(
  function SQLITE_PRIVATE (line 50737) | SQLITE_PRIVATE void *sqlite3PagerGetCodec(Pager *pPager){
  function SQLITE_PRIVATE (line 50748) | SQLITE_PRIVATE void *sqlite3PagerCodec(PgHdr *pPg){
  function SQLITE_PRIVATE (line 50757) | SQLITE_PRIVATE int sqlite3PagerState(Pager *pPager){
  function SQLITE_PRIVATE (line 50788) | SQLITE_PRIVATE int sqlite3PagerMovepage(Pager *pPager, DbPage *pPg, Pgno...
  function SQLITE_PRIVATE (line 50922) | SQLITE_PRIVATE void sqlite3PagerRekey(DbPage *pPg, Pgno iNew, u16 flags){
  function SQLITE_PRIVATE (line 50931) | SQLITE_PRIVATE void *sqlite3PagerGetData(DbPage *pPg){
  function SQLITE_PRIVATE (line 50940) | SQLITE_PRIVATE void *sqlite3PagerGetExtra(DbPage *pPg){
  function SQLITE_PRIVATE (line 50954) | SQLITE_PRIVATE int sqlite3PagerLockingMode(Pager *pPager, int eMode){
  function SQLITE_PRIVATE (line 50987) | SQLITE_PRIVATE int sqlite3PagerSetJournalMode(Pager *pPager, int eMode){
  function SQLITE_PRIVATE (line 51085) | SQLITE_PRIVATE int sqlite3PagerGetJournalMode(Pager *pPager){
  function SQLITE_PRIVATE (line 51094) | SQLITE_PRIVATE int sqlite3PagerOkToChangeJournalMode(Pager *pPager){
  function SQLITE_PRIVATE (line 51107) | SQLITE_PRIVATE i64 sqlite3PagerJournalSizeLimit(Pager *pPager, i64 iLimit){
  function SQLITE_PRIVATE (line 51121) | SQLITE_PRIVATE sqlite3_backup **sqlite3PagerBackupPtr(Pager *pPager){
  function SQLITE_PRIVATE (line 51129) | SQLITE_PRIVATE void sqlite3PagerClearCache(Pager *pPager){
  function SQLITE_PRIVATE (line 51142) | SQLITE_PRIVATE int sqlite3PagerCheckpoint(Pager *pPager, int eMode, int ...
  function SQLITE_PRIVATE (line 51155) | SQLITE_PRIVATE int sqlite3PagerWalCallback(Pager *pPager){
  function SQLITE_PRIVATE (line 51163) | SQLITE_PRIVATE int sqlite3PagerWalSupported(Pager *pPager){
  function pagerExclusiveLock (line 51173) | static int pagerExclusiveLock(Pager *pPager){
  function pagerOpenWal (line 51193) | static int pagerOpenWal(Pager *pPager){
  function SQLITE_PRIVATE (line 51238) | SQLITE_PRIVATE int sqlite3PagerOpenWal(
  function SQLITE_PRIVATE (line 51277) | SQLITE_PRIVATE int sqlite3PagerCloseWal(Pager *pPager){
  function SQLITE_PRIVATE (line 51319) | SQLITE_PRIVATE int sqlite3PagerSnapshotGet(Pager *pPager, sqlite3_snapsh...
  function SQLITE_PRIVATE (line 51332) | SQLITE_PRIVATE int sqlite3PagerSnapshotOpen(Pager *pPager, sqlite3_snaps...
  function SQLITE_PRIVATE (line 51352) | SQLITE_PRIVATE int sqlite3PagerWalFramesize(Pager *pPager){
  type WalIndexHdr (line 51649) | typedef struct WalIndexHdr WalIndexHdr;
  type WalIterator (line 51650) | typedef struct WalIterator WalIterator;
  type WalCkptInfo (line 51651) | typedef struct WalCkptInfo WalCkptInfo;
  type WalIndexHdr (line 51667) | struct WalIndexHdr {
  type WalCkptInfo (line 51740) | struct WalCkptInfo {
  type Wal (line 51789) | struct Wal {
  type u16 (line 51839) | typedef u16 ht_slot;
  type WalIterator (line 51856) | struct WalIterator {
  function walIndexPage (line 51901) | static int walIndexPage(Wal *pWal, int iPage, volatile u32 **ppPage){
  function WalCkptInfo (line 51943) | static volatile WalCkptInfo *walCkptInfo(Wal *pWal){
  function WalIndexHdr (line 51951) | static volatile WalIndexHdr *walIndexHdr(Wal *pWal){
  function walChecksumBytes (line 51977) | static void walChecksumBytes(
  function walShmBarrier (line 52015) | static void walShmBarrier(Wal *pWal){
  function walIndexWriteHdr (line 52026) | static void walIndexWriteHdr(Wal *pWal){
  function walEncodeFrame (line 52052) | static void walEncodeFrame(
  function walDecodeFrame (line 52083) | static int walDecodeFrame(
  function walLockShared (line 52162) | static int walLockShared(Wal *pWal, int lockIdx){
  function walUnlockShared (line 52172) | static void walUnlockShared(Wal *pWal, int lockIdx){
  function walLockExclusive (line 52178) | static int walLockExclusive(Wal *pWal, int lockIdx, int n){
  function walUnlockExclusive (line 52188) | static void walUnlockExclusive(Wal *pWal, int lockIdx, int n){
  function walHash (line 52201) | static int walHash(u32 iPage){
  function walNextHash (line 52206) | static int walNextHash(int iPriorHash){
  function walHashGet (line 52224) | static int walHashGet(
  function walFramePage (line 52262) | static int walFramePage(u32 iFrame){
  function u32 (line 52276) | static u32 walFramePgno(Wal *pWal, u32 iFrame){
  function walCleanupHash (line 52296) | static void walCleanupHash(Wal *pWal){
  function walIndexAppend (line 52358) | static int walIndexAppend(Wal *pWal, u32 iFrame, u32 iPage){
  function walIndexRecover (line 52447) | static int walIndexRecover(Wal *pWal){
  function walIndexClose (line 52614) | static void walIndexClose(Wal *pWal, int isDelete){
  function SQLITE_PRIVATE (line 52641) | SQLITE_PRIVATE int sqlite3WalOpen(
  function SQLITE_PRIVATE (line 52715) | SQLITE_PRIVATE void sqlite3WalLimit(Wal *pWal, i64 iLimit){
  function walIteratorNext (line 52729) | static int walIteratorNext(
  function walMerge (line 52782) | static void walMerge(
  function walMergesort (line 52839) | static void walMergesort(
  function walIteratorFree (line 52902) | static void walIteratorFree(WalIterator *p){
  function walIteratorInit (line 52918) | static int walIteratorInit(Wal *pWal, WalIterator **pp){
  function walBusyLock (line 53000) | static int walBusyLock(
  function walPagesize (line 53018) | static int walPagesize(Wal *pWal){
  function walRestartHdr (line 53039) | static void walRestartHdr(Wal *pWal, u32 salt1){
  function walCheckpoint (line 53086) | static int walCheckpoint(
  function walLimitSize (line 53267) | static void walLimitSize(Wal *pWal, i64 nMax){
  function SQLITE_PRIVATE (line 53284) | SQLITE_PRIVATE int sqlite3WalClose(
  function walIndexTryHdr (line 53363) | static int walIndexTryHdr(Wal *pWal, int *pChanged){
  function walIndexReadHdr (line 53421) | static int walIndexReadHdr(Wal *pWal, int *pChanged){
  function walTryBeginRead (line 53538) | static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int cnt){
  function SQLITE_PRIVATE (line 53751) | SQLITE_PRIVATE int sqlite3WalBeginReadTransaction(Wal *pWal, int *pChang...
  function SQLITE_PRIVATE (line 53837) | SQLITE_PRIVATE void sqlite3WalEndReadTransaction(Wal *pWal){
  function SQLITE_PRIVATE (line 53853) | SQLITE_PRIVATE int sqlite3WalFindFrame(
  function SQLITE_PRIVATE (line 53955) | SQLITE_PRIVATE int sqlite3WalReadFrame(
  function SQLITE_PRIVATE (line 53975) | SQLITE_PRIVATE Pgno sqlite3WalDbsize(Wal *pWal){
  function SQLITE_PRIVATE (line 53996) | SQLITE_PRIVATE int sqlite3WalBeginWriteTransaction(Wal *pWal){
  function SQLITE_PRIVATE (line 54034) | SQLITE_PRIVATE int sqlite3WalEndWriteTransaction(Wal *pWal){
  function SQLITE_PRIVATE (line 54056) | SQLITE_PRIVATE int sqlite3WalUndo(Wal *pWal, int (*xUndo)(void *, Pgno),...
  function SQLITE_PRIVATE (line 54096) | SQLITE_PRIVATE void sqlite3WalSavepoint(Wal *pWal, u32 *aWalData){
  function SQLITE_PRIVATE (line 54110) | SQLITE_PRIVATE int sqlite3WalSavepointUndo(Wal *pWal, u32 *aWalData){
  function walRestartLog (line 54147) | static int walRestartLog(Wal *pWal){
  type WalWriter (line 54194) | typedef struct WalWriter {
  function walWriteToLog (line 54210) | static int walWriteToLog(
  function walWriteOneFrame (line 54235) | static int walWriteOneFrame(
  function walRewriteChecksums (line 54265) | static int walRewriteChecksums(Wal *pWal, u32 iLast){
  function SQLITE_PRIVATE (line 54314) | SQLITE_PRIVATE int sqlite3WalFrames(
  function SQLITE_PRIVATE (line 54549) | SQLITE_PRIVATE int sqlite3WalCheckpoint(
  function SQLITE_PRIVATE (line 54658) | SQLITE_PRIVATE int sqlite3WalCallback(Wal *pWal){
  function SQLITE_PRIVATE (line 54691) | SQLITE_PRIVATE int sqlite3WalExclusiveMode(Wal *pWal, int op){
  function SQLITE_PRIVATE (line 54733) | SQLITE_PRIVATE int sqlite3WalHeapMemory(Wal *pWal){
  function SQLITE_PRIVATE (line 54742) | SQLITE_PRIVATE int sqlite3WalSnapshotGet(Wal *pWal, sqlite3_snapshot **p...
  function SQLITE_PRIVATE (line 54761) | SQLITE_PRIVATE void sqlite3WalSnapshotOpen(Wal *pWal, sqlite3_snapshot *...
  function SQLITE_PRIVATE (line 54772) | SQLITE_PRIVATE int sqlite3WalFramesize(Wal *pWal){
  function SQLITE_PRIVATE (line 54780) | SQLITE_PRIVATE sqlite3_file *sqlite3WalFile(Wal *pWal){
  type MemPage (line 55038) | typedef struct MemPage MemPage;
  type BtLock (line 55039) | typedef struct BtLock BtLock;
  type CellInfo (line 55040) | typedef struct CellInfo CellInfo;
  type MemPage (line 55080) | struct MemPage {
  type BtLock (line 55124) | struct BtLock {
  type Btree (line 55156) | struct Btree {
  type BtShared (line 55219) | struct BtShared {
  type CellInfo (line 55273) | struct CellInfo {
  type BtCursor (line 55311) | struct BtCursor {
  type IntegrityCk (line 55477) | typedef struct IntegrityCk IntegrityCk;
  type IntegrityCk (line 55478) | struct IntegrityCk {
  function lockBtreeMutex (line 55527) | static void lockBtreeMutex(Btree *p){
  function unlockBtreeMutex (line 55541) | static void SQLITE_NOINLINE unlockBtreeMutex(Btree *p){
  function SQLITE_PRIVATE (line 55571) | SQLITE_PRIVATE void sqlite3BtreeEnter(Btree *p){
  function btreeLockCarefully (line 55605) | static void SQLITE_NOINLINE btreeLockCarefully(Btree *p){
  function SQLITE_PRIVATE (line 55643) | SQLITE_PRIVATE void sqlite3BtreeLeave(Btree *p){
  function SQLITE_PRIVATE (line 55661) | SQLITE_PRIVATE int sqlite3BtreeHoldsMutex(Btree *p){
  function SQLITE_PRIVATE (line 55686) | SQLITE_PRIVATE void sqlite3BtreeEnterAll(sqlite3 *db){
  function SQLITE_PRIVATE (line 55695) | SQLITE_PRIVATE void sqlite3BtreeLeaveAll(sqlite3 *db){
  function SQLITE_PRIVATE (line 55712) | SQLITE_PRIVATE int sqlite3BtreeHoldsAllMutexes(sqlite3 *db){
  function SQLITE_PRIVATE (line 55741) | SQLITE_PRIVATE int sqlite3SchemaMutexHeld(sqlite3 *db, int iDb, Schema *...
  function SQLITE_PRIVATE (line 55765) | SQLITE_PRIVATE void sqlite3BtreeEnter(Btree *p){
  function SQLITE_PRIVATE (line 55768) | SQLITE_PRIVATE void sqlite3BtreeEnterAll(sqlite3 *db){
  function SQLITE_PRIVATE (line 55787) | SQLITE_PRIVATE void sqlite3BtreeEnterCursor(BtCursor *pCur){
  function SQLITE_PRIVATE (line 55791) | SQLITE_PRIVATE void sqlite3BtreeLeaveCursor(BtCursor *pCur){
  function SQLITE_STDCALL (line 55889) | SQLITE_STDCALL sqlite3_enable_shared_cache(int enable){
  function hasSharedCacheTableLock (line 55940) | static int hasSharedCacheTableLock(
  function hasReadConflicts (line 56027) | static int hasReadConflicts(Btree *pBtree, Pgno iRoot){
  function querySharedCacheTableLock (line 56047) | static int querySharedCacheTableLock(Btree *p, Pgno iTab, u8 eLock){
  function setSharedCacheTableLock (line 56119) | static int setSharedCacheTableLock(Btree *p, Pgno iTable, u8 eLock){
  function clearAllSharedCacheTableLocks (line 56183) | static void clearAllSharedCacheTableLocks(Btree *p){
  function downgradeAllSharedCacheTableLocks (line 56227) | static void downgradeAllSharedCacheTableLocks(Btree *p){
  function cursorHoldsMutex (line 56250) | static int cursorHoldsMutex(BtCursor *p){
  function cursorOwnsBtShared (line 56253) | static int cursorOwnsBtShared(BtCursor *p){
  function invalidateAllOverflowCache (line 56269) | static void invalidateAllOverflowCache(BtShared *pBt){
  function invalidateIncrblobCursors (line 56291) | static void invalidateIncrblobCursors(
  function btreeSetHasContent (line 56350) | static int btreeSetHasContent(BtShared *pBt, Pgno pgno){
  function btreeGetHasContent (line 56372) | static int btreeGetHasContent(BtShared *pBt, Pgno pgno){
  function btreeClearHasContent (line 56381) | static void btreeClearHasContent(BtShared *pBt){
  function btreeReleaseAllCursorPages (line 56389) | static void btreeReleaseAllCursorPages(BtCursor *pCur){
  function saveCursorKey (line 56411) | static int saveCursorKey(BtCursor *pCur){
  function saveCursorPosition (line 56449) | static int saveCursorPosition(BtCursor *pCur){
  function saveAllCursors (line 56496) | static int saveAllCursors(BtShared *pBt, Pgno iRoot, BtCursor *pExcept){
  function saveCursorsOnList (line 56513) | static int SQLITE_NOINLINE saveCursorsOnList(
  function SQLITE_PRIVATE (line 56538) | SQLITE_PRIVATE void sqlite3BtreeClearCursor(BtCursor *pCur){
  function btreeMoveto (line 56550) | static int btreeMoveto(
  function btreeRestoreCursorPosition (line 56590) | static int btreeRestoreCursorPosition(BtCursor *pCur){
  function SQLITE_PRIVATE (line 56629) | SQLITE_PRIVATE int sqlite3BtreeCursorHasMoved(BtCursor *pCur){
  function SQLITE_PRIVATE (line 56646) | SQLITE_PRIVATE int sqlite3BtreeCursorRestore(BtCursor *pCur, int *pDiffe...
  function SQLITE_PRIVATE (line 56671) | SQLITE_PRIVATE void sqlite3BtreeCursorHint(BtCursor *pCur, int eHintType...
  function SQLITE_PRIVATE (line 56679) | SQLITE_PRIVATE void sqlite3BtreeCursorHintFlags(BtCursor *pCur, unsigned...
  function Pgno (line 56695) | static Pgno ptrmapPageno(BtShared *pBt, Pgno pgno){
  function ptrmapPut (line 56719) | static void ptrmapPut(BtShared *pBt, Pgno key, u8 eType, Pgno parent, in...
  function ptrmapGet (line 56771) | static int ptrmapGet(BtShared *pBt, Pgno key, u8 *pEType, Pgno *pPgno){
  function SQLITE_NOINLINE (line 56830) | static SQLITE_NOINLINE void btreeParseCellAdjustSizeForOverflow(
  function btreeParseCellPtrNoPayload (line 56875) | static void btreeParseCellPtrNoPayload(
  function btreeParseCellPtr (line 56892) | static void btreeParseCellPtr(
  function btreeParseCellPtrIndex (line 56960) | static void btreeParseCellPtrIndex(
  function btreeParseCell (line 56997) | static void btreeParseCell(
  function u16 (line 57017) | static u16 cellSizePtr(MemPage *pPage, u8 *pCell){
  function u16 (line 57065) | static u16 cellSizePtrNoPayload(MemPage *pPage, u8 *pCell){
  function u16 (line 57091) | static u16 cellSize(MemPage *pPage, int iCell){
  function ptrmapPutOvflPtr (line 57102) | static void ptrmapPutOvflPtr(MemPage *pPage, u8 *pCell, int *pRC){
  function defragmentPage (line 57126) | static int defragmentPage(MemPage *pPage){
  function u8 (line 57216) | static u8 *pageFindSlot(MemPage *pPg, int nByte, int *pRc){
  function allocateSpace (line 57279) | static int allocateSpace(MemPage *pPage, int nByte, int *pIdx){
  function freeSpace (line 57369) | static int freeSpace(MemPage *pPage, u16 iStart, u16 iSize){
  function decodeFlags (line 57468) | static int decodeFlags(MemPage *pPage, int flagByte){
  function btreeInitPage (line 57526) | static int btreeInitPage(MemPage *pPage){
  function zeroPage (line 57657) | static void zeroPage(MemPage *pPage, int flags){
  function MemPage (line 57694) | static MemPage *btreePageFromDbPage(DbPage *pDbPage, Pgno pgno, BtShared...
  function btreeGetPage (line 57718) | static int btreeGetPage(
  function MemPage (line 57740) | static MemPage *btreePageLookup(BtShared *pBt, Pgno pgno){
  function Pgno (line 57754) | static Pgno btreePagecount(BtShared *pBt){
  function SQLITE_PRIVATE (line 57757) | SQLITE_PRIVATE u32 sqlite3BtreeLastPage(Btree *p){
  function getAndInitPage (line 57776) | static int getAndInitPage(
  function releasePageNotNull (line 57830) | static void releasePageNotNull(MemPage *pPage){
  function releasePage (line 57839) | static void releasePage(MemPage *pPage){
  function btreeGetUnusedPage (line 57852) | static int btreeGetUnusedPage(
  function pageReinit (line 57881) | static void pageReinit(DbPage *pData){
  function btreeInvokeBusyHandler (line 57903) | static int btreeInvokeBusyHandler(void *pArg){
  function SQLITE_PRIVATE (line 57931) | SQLITE_PRIVATE int sqlite3BtreeOpen(
  function removeFromSharingList (line 58215) | static int removeFromSharingList(BtShared *pBt){
  function allocateTempSpace (line 58254) | static void allocateTempSpace(BtShared *pBt){
  function freeTempSpace (line 58283) | static void freeTempSpace(BtShared *pBt){
  function SQLITE_PRIVATE (line 58294) | SQLITE_PRIVATE int sqlite3BtreeClose(Btree *p){
  function SQLITE_PRIVATE (line 58356) | SQLITE_PRIVATE int sqlite3BtreeSetCacheSize(Btree *p, int mxPage){
  function SQLITE_PRIVATE (line 58375) | SQLITE_PRIVATE int sqlite3BtreeSetSpillSize(Btree *p, int mxPage){
  function SQLITE_PRIVATE (line 58390) | SQLITE_PRIVATE int sqlite3BtreeSetMmapLimit(Btree *p, sqlite3_int64 szMm...
  function SQLITE_PRIVATE (line 58409) | SQLITE_PRIVATE int sqlite3BtreeSetPagerFlags(
  function SQLITE_PRIVATE (line 58442) | SQLITE_PRIVATE int sqlite3BtreeSetPageSize(Btree *p, int pageSize, int n...
  function SQLITE_PRIVATE (line 58475) | SQLITE_PRIVATE int sqlite3BtreeGetPageSize(Btree *p){
  function SQLITE_PRIVATE (line 58490) | SQLITE_PRIVATE int sqlite3BtreeGetReserveNoMutex(Btree *p){
  function SQLITE_PRIVATE (line 58506) | SQLITE_PRIVATE int sqlite3BtreeGetOptimalReserve(Btree *p){
  function SQLITE_PRIVATE (line 58523) | SQLITE_PRIVATE int sqlite3BtreeMaxPageCount(Btree *p, int mxPage){
  function SQLITE_PRIVATE (line 58536) | SQLITE_PRIVATE int sqlite3BtreeSecureDelete(Btree *p, int newFlag){
  function SQLITE_PRIVATE (line 58555) | SQLITE_PRIVATE int sqlite3BtreeSetAutoVacuum(Btree *p, int autoVacuum){
  function SQLITE_PRIVATE (line 58579) | SQLITE_PRIVATE int sqlite3BtreeGetAutoVacuum(Btree *p){
  function lockBtree (line 58605) | static int lockBtree(BtShared *pBt){
  function countValidCursors (line 58800) | static int countValidCursors(BtShared *pBt, int wrOnly){
  function unlockBtreeIfUnused (line 58819) | static void unlockBtreeIfUnused(BtShared *pBt){
  function newDatabase (line 58836) | static int newDatabase(BtShared *pBt){
  function SQLITE_PRIVATE (line 58880) | SQLITE_PRIVATE int sqlite3BtreeNewDb(Btree *p){
  function SQLITE_PRIVATE (line 58924) | SQLITE_PRIVATE int sqlite3BtreeBeginTrans(Btree *p, int wrflag){
  function setChildPtrmaps (line 59071) | static int setChildPtrmaps(MemPage *pPage){
  function modifyPagePointer (line 59121) | static int modifyPagePointer(MemPage *pPage, Pgno iFrom, Pgno iTo, u8 eT...
  function relocatePage (line 59183) | static int relocatePage(
  function incrVacuumStep (line 59276) | static int incrVacuumStep(BtShared *pBt, Pgno nFin, Pgno iLastPg, int bC...
  function Pgno (line 59372) | static Pgno finalDbSize(BtShared *pBt, Pgno nOrig, Pgno nFree){
  function SQLITE_PRIVATE (line 59398) | SQLITE_PRIVATE int sqlite3BtreeIncrVacuum(Btree *p){
  function autoVacuumCommit (line 59440) | static int autoVacuumCommit(BtShared *pBt){
  function SQLITE_PRIVATE (line 59519) | SQLITE_PRIVATE int sqlite3BtreeCommitPhaseOne(Btree *p, const char *zMas...
  function btreeEndTransaction (line 59546) | static void btreeEndTransaction(Btree *p){
  function SQLITE_PRIVATE (line 59608) | SQLITE_PRIVATE int sqlite3BtreeCommitPhaseTwo(Btree *p, int bCleanup){
  function SQLITE_PRIVATE (line 59640) | SQLITE_PRIVATE int sqlite3BtreeCommit(Btree *p){
  function SQLITE_PRIVATE (line 59677) | SQLITE_PRIVATE int sqlite3BtreeTripAllCursors(Btree *pBtree, int errCode...
  function SQLITE_PRIVATE (line 59720) | SQLITE_PRIVATE int sqlite3BtreeRollback(Btree *p, int tripCode, int writ...
  function SQLITE_PRIVATE (line 59789) | SQLITE_PRIVATE int sqlite3BtreeBeginStmt(Btree *p, int iStatement){
  function SQLITE_PRIVATE (line 59820) | SQLITE_PRIVATE int sqlite3BtreeSavepoint(Btree *p, int op, int iSavepoint){
  function btreeCursor (line 59887) | static int btreeCursor(
  function SQLITE_PRIVATE (line 59947) | SQLITE_PRIVATE int sqlite3BtreeCursor(
  function SQLITE_PRIVATE (line 59973) | SQLITE_PRIVATE int sqlite3BtreeCursorSize(void){
  function SQLITE_PRIVATE (line 59985) | SQLITE_PRIVATE void sqlite3BtreeCursorZero(BtCursor *p){
  function SQLITE_PRIVATE (line 59993) | SQLITE_PRIVATE int sqlite3BtreeCloseCursor(BtCursor *pCur){
  function assertCellInfo (line 60033) | static void assertCellInfo(BtCursor *pCur){
  function SQLITE_NOINLINE (line 60043) | static SQLITE_NOINLINE void getCellInfo(BtCursor *pCur){
  function SQLITE_PRIVATE (line 60059) | SQLITE_PRIVATE int sqlite3BtreeCursorIsValid(BtCursor *pCur){
  function SQLITE_PRIVATE (line 60076) | SQLITE_PRIVATE int sqlite3BtreeKeySize(BtCursor *pCur, i64 *pSize){
  function SQLITE_PRIVATE (line 60096) | SQLITE_PRIVATE int sqlite3BtreeDataSize(BtCursor *pCur, u32 *pSize){
  function getOverflowPage (line 60126) | static int getOverflowPage(
  function copyPayload (line 60194) | static int copyPayload(
  function accessPayload (line 60245) | static int accessPayload(
  function SQLITE_PRIVATE (line 60456) | SQLITE_PRIVATE int sqlite3BtreeKey(BtCursor *pCur, u32 offset, u32 amt, ...
  function SQLITE_PRIVATE (line 60473) | SQLITE_PRIVATE int sqlite3BtreeData(BtCursor *pCur, u32 offset, u32 amt,...
  function SQLITE_PRIVATE (line 60546) | SQLITE_PRIVATE const void *sqlite3BtreeKeyFetch(BtCursor *pCur, u32 *pAmt){
  function SQLITE_PRIVATE (line 60549) | SQLITE_PRIVATE const void *sqlite3BtreeDataFetch(BtCursor *pCur, u32 *pA...
  function moveToChild (line 60563) | static int moveToChild(BtCursor *pCur, u32 newPgno){
  function assertParentIndex (line 60589) | static void assertParentIndex(MemPage *pParent, int iIdx, Pgno iChild){
  function moveToParent (line 60611) | static void moveToParent(BtCursor *pCur){
  function moveToRoot (line 60648) | static int moveToRoot(BtCursor *pCur){
  function moveToLeftmost (line 60726) | static int moveToLeftmost(BtCursor *pCur){
  function moveToRightmost (line 60751) | static int moveToRightmost(BtCursor *pCur){
  function SQLITE_PRIVATE (line 60774) | SQLITE_PRIVATE int sqlite3BtreeFirst(BtCursor *pCur, int *pRes){
  function SQLITE_PRIVATE (line 60797) | SQLITE_PRIVATE int sqlite3BtreeLast(BtCursor *pCur, int *pRes){
  function SQLITE_PRIVATE (line 60868) | SQLITE_PRIVATE int sqlite3BtreeMovetoUnpacked(
  function SQLITE_PRIVATE (line 61092) | SQLITE_PRIVATE int sqlite3BtreeEof(BtCursor *pCur){
  function SQLITE_NOINLINE (line 61121) | static SQLITE_NOINLINE int btreeNext(BtCursor *pCur, int *pRes){
  function SQLITE_PRIVATE (line 61188) | SQLITE_PRIVATE int sqlite3BtreeNext(BtCursor *pCur, int *pRes){
  function SQLITE_NOINLINE (line 61231) | static SQLITE_NOINLINE int btreePrevious(BtCursor *pCur, int *pRes){
  function SQLITE_PRIVATE (line 61290) | SQLITE_PRIVATE int sqlite3BtreePrevious(BtCursor *pCur, int *pRes){
  function allocateBtreePage (line 61330) | static int allocateBtreePage(
  function freePage2 (line 61652) | static int freePage2(BtShared *pBt, MemPage *pMemPage, Pgno iPage){
  function freePage (line 61780) | static void freePage(MemPage *pPage, int *pRC){
  function clearCell (line 61791) | static int clearCell(
  function fillInCell (line 61872) | static int fillInCell(
  function dropCell (line 62060) | static void dropCell(MemPage *pPage, int idx, int sz, int *pRC){
  function insertCell (line 62114) | static void insertCell(
  type CellArray (line 62205) | typedef struct CellArray CellArray;
  type CellArray (line 62206) | struct CellArray {
  function populateCellCache (line 62217) | static void populateCellCache(CellArray *p, int idx, int N){
  function SQLITE_NOINLINE (line 62235) | static SQLITE_NOINLINE u16 computeCellSize(CellArray *p, int N){
  function u16 (line 62241) | static u16 cachedCellSize(CellArray *p, int N){
  function rebuildPage (line 62260) | static int rebuildPage(
  function pageInsertArray (line 62329) | static int pageInsertArray(
  function pageFreeArray (line 62375) | static int pageFreeArray(
  function editPage (line 62432) | static int editPage(
  function balance_quick (line 62566) | static int balance_quick(MemPage *pParent, MemPage *pPage, u8 *pSpace){
  function ptrmapCheckPages (line 62655) | static int ptrmapCheckPages(MemPage **apPage, int nPage){
  function copyNodeContent (line 62708) | static void copyNodeContent(MemPage *pFrom, MemPage *pTo, int *pRC){
  function balance_nonroot (line 62789) | static int balance_nonroot(
  function balance_deeper (line 63553) | static int balance_deeper(MemPage *pRoot, MemPage **ppChild){
  function balance (line 63610) | static int balance(BtCursor *pCur){
  function SQLITE_PRIVATE (line 63749) | SQLITE_PRIVATE int sqlite3BtreeInsert(
  function SQLITE_PRIVATE (line 63916) | SQLITE_PRIVATE int sqlite3BtreeDelete(BtCursor *pCur, u8 flags){
  function btreeCreateTable (line 64079) | static int btreeCreateTable(Btree *p, int *piTable, int createTabFlags){
  function SQLITE_PRIVATE (line 64222) | SQLITE_PRIVATE int sqlite3BtreeCreateTable(Btree *p, int *piTable, int f...
  function clearDatabasePage (line 64234) | static int clearDatabasePage(
  function SQLITE_PRIVATE (line 64301) | SQLITE_PRIVATE int sqlite3BtreeClearTable(Btree *p, int iTable, int *pnC...
  function SQLITE_PRIVATE (line 64325) | SQLITE_PRIVATE int sqlite3BtreeClearTableOfCursor(BtCursor *pCur){
  function btreeDropTable (line 64349) | static int btreeDropTable(Btree *p, Pgno iTable, int *piMoved){
  function SQLITE_PRIVATE (line 64451) | SQLITE_PRIVATE int sqlite3BtreeDropTable(Btree *p, int iTable, int *piMo...
  function SQLITE_PRIVATE (line 64480) | SQLITE_PRIVATE void sqlite3BtreeGetMeta(Btree *p, int idx, u32 *pMeta){
  function SQLITE_PRIVATE (line 64510) | SQLITE_PRIVATE int sqlite3BtreeUpdateMeta(Btree *p, int idx, u32 iMeta){
  function SQLITE_PRIVATE (line 64543) | SQLITE_PRIVATE int sqlite3BtreeCount(BtCursor *pCur, i64 *pnEntry){
  function SQLITE_PRIVATE (line 64613) | SQLITE_PRIVATE Pager *sqlite3BtreePager(Btree *p){
  function checkAppendMsg (line 64621) | static void checkAppendMsg(
  function getPageReferenced (line 64651) | static int getPageReferenced(IntegrityCk *pCheck, Pgno iPg){
  function setPageReferenced (line 64659) | static void setPageReferenced(IntegrityCk *pCheck, Pgno iPg){
  function checkRef (line 64673) | static int checkRef(IntegrityCk *pCheck, Pgno iPage){
  function checkPtrmap (line 64693) | static void checkPtrmap(
  function checkList (line 64722) | static void checkList(
  function btreeHeapInsert (line 64814) | static void btreeHeapInsert(u32 *aHeap, u32 x){
  function btreeHeapPull (line 64824) | static int btreeHeapPull(u32 *aHeap, u32 *pOut){
  function checkTreePage (line 64858) | static int checkTreePage(
  function SQLITE_PRIVATE (line 65122) | SQLITE_PRIVATE char *sqlite3BtreeIntegrityCheck(
  function SQLITE_PRIVATE (line 65241) | SQLITE_PRIVATE const char *sqlite3BtreeGetFilename(Btree *p){
  function SQLITE_PRIVATE (line 65254) | SQLITE_PRIVATE const char *sqlite3BtreeGetJournalname(Btree *p){
  function SQLITE_PRIVATE (line 65262) | SQLITE_PRIVATE int sqlite3BtreeIsInTrans(Btree *p){
  function SQLITE_PRIVATE (line 65276) | SQLITE_PRIVATE int sqlite3BtreeCheckpoint(Btree *p, int eMode, int *pnLo...
  function SQLITE_PRIVATE (line 65295) | SQLITE_PRIVATE int sqlite3BtreeIsInReadTrans(Btree *p){
  function SQLITE_PRIVATE (line 65301) | SQLITE_PRIVATE int sqlite3BtreeIsInBackup(Btree *p){
  function SQLITE_PRIVATE (line 65327) | SQLITE_PRIVATE void *sqlite3BtreeSchema(Btree *p, int nBytes, void(*xFre...
  function SQLITE_PRIVATE (line 65343) | SQLITE_PRIVATE int sqlite3BtreeSchemaLocked(Btree *p){
  function SQLITE_PRIVATE (line 65360) | SQLITE_PRIVATE int sqlite3BtreeLockTable(Btree *p, int iTab, u8 isWriteL...
  function SQLITE_PRIVATE (line 65390) | SQLITE_PRIVATE int sqlite3BtreePutData(BtCursor *pCsr, u32 offset, u32 a...
  function SQLITE_PRIVATE (line 65438) | SQLITE_PRIVATE void sqlite3BtreeIncrblobCursor(BtCursor *pCur){
  function SQLITE_PRIVATE (line 65449) | SQLITE_PRIVATE int sqlite3BtreeSetVersion(Btree *pBtree, int iVersion){
  function SQLITE_PRIVATE (line 65484) | SQLITE_PRIVATE int sqlite3BtreeCursorHasHint(BtCursor *pCsr, unsigned in...
  function SQLITE_PRIVATE (line 65491) | SQLITE_PRIVATE int sqlite3BtreeIsReadonly(Btree *p){
  function SQLITE_PRIVATE (line 65498) | SQLITE_PRIVATE int sqlite3HeaderSizeBtree(void){ return ROUND8(sizeof(Me...
  function SQLITE_PRIVATE (line 65504) | SQLITE_PRIVATE int sqlite3BtreeSharable(Btree *p){
  type sqlite3_backup (line 65531) | struct sqlite3_backup {
  function Btree (line 65592) | static Btree *findBtree(sqlite3 *pErrorDb, sqlite3 *pDb, const char *zDb){
  function setDestPgsz (line 65629) | static int setDestPgsz(sqlite3_backup *p){
  function checkReadTransaction (line 65641) | static int checkReadTransaction(sqlite3 *db, Btree *p){
  function isFatalError (line 65735) | static int isFatalError(int rc){
  function backupOnePage (line 65744) | static int backupOnePage(
  function backupTruncateFile (line 65840) | static int backupTruncateFile(sqlite3_file *pFile, i64 iSize){
  function attachBackupObject (line 65853) | static void attachBackupObject(sqlite3_backup *p){
  function SQLITE_STDCALL (line 65865) | SQLITE_STDCALL sqlite3_backup_step(sqlite3_backup *p, int nPage){
  function SQLITE_STDCALL (line 66109) | SQLITE_STDCALL sqlite3_backup_finish(sqlite3_backup *p){
  function SQLITE_STDCALL (line 66161) | SQLITE_STDCALL sqlite3_backup_remaining(sqlite3_backup *p){
  function SQLITE_STDCALL (line 66175) | SQLITE_STDCALL sqlite3_backup_pagecount(sqlite3_backup *p){
  function SQLITE_NOINLINE (line 66197) | static SQLITE_NOINLINE void backupUpdate(
  function SQLITE_PRIVATE (line 66222) | SQLITE_PRIVATE void sqlite3BackupUpdate(sqlite3_backup *pBackup, Pgno iP...
  function SQLITE_PRIVATE (line 66237) | SQLITE_PRIVATE void sqlite3BackupRestart(sqlite3_backup *pBackup){
  function SQLITE_PRIVATE (line 66254) | SQLITE_PRIVATE int sqlite3BtreeCopyFile(Btree *pTo, Btree *pFrom){
  function SQLITE_PRIVATE (line 66338) | SQLITE_PRIVATE int sqlite3VdbeCheckMemInvariants(Mem *p){
  function SQLITE_PRIVATE (line 66391) | SQLITE_PRIVATE int sqlite3VdbeChangeEncoding(Mem *pMem, int desiredEnc){
  function sqlite3VdbeMemGrow (line 66426) | int sqlite3VdbeMemGrow(Mem *pMem, int n, int bPreserve){
  function SQLITE_PRIVATE (line 66483) | SQLITE_PRIVATE int sqlite3VdbeMemClearAndResize(Mem *pMem, int szNew){
  function SQLITE_PRIVATE (line 66501) | SQLITE_PRIVATE int sqlite3VdbeMemMakeWriteable(Mem *pMem){
  function SQLITE_PRIVATE (line 66528) | SQLITE_PRIVATE int sqlite3VdbeMemExpandBlob(Mem *pMem){
  function SQLITE_NOINLINE (line 66556) | static SQLITE_NOINLINE int vdbeMemAddTerminator(Mem *pMem){
  function SQLITE_PRIVATE (line 66569) | SQLITE_PRIVATE int sqlite3VdbeMemNulTerminate(Mem *pMem){
  function SQLITE_PRIVATE (line 66594) | SQLITE_PRIVATE int sqlite3VdbeMemStringify(Mem *pMem, u8 enc, u8 bForce){
  function SQLITE_PRIVATE (line 66638) | SQLITE_PRIVATE int sqlite3VdbeMemFinalize(Mem *pMem, FuncDef *pFunc){
  function SQLITE_NOINLINE (line 66670) | static SQLITE_NOINLINE void vdbeMemClearExternAndSetNull(Mem *p){
  function SQLITE_NOINLINE (line 66700) | static SQLITE_NOINLINE void vdbeMemClear(Mem *p){
  function SQLITE_PRIVATE (line 66721) | SQLITE_PRIVATE void sqlite3VdbeMemRelease(Mem *p){
  function i64 (line 66733) | static i64 doubleToInt64(double r){
  function SQLITE_PRIVATE (line 66769) | SQLITE_PRIVATE i64 sqlite3VdbeIntValue(Mem *pMem){
  function SQLITE_PRIVATE (line 66794) | SQLITE_PRIVATE double sqlite3VdbeRealValue(Mem *pMem){
  function SQLITE_PRIVATE (line 66816) | SQLITE_PRIVATE void sqlite3VdbeIntegerAffinity(Mem *pMem){
  function SQLITE_PRIVATE (line 66844) | SQLITE_PRIVATE int sqlite3VdbeMemIntegerify(Mem *pMem){
  function SQLITE_PRIVATE (line 66858) | SQLITE_PRIVATE int sqlite3VdbeMemRealify(Mem *pMem){
  function SQLITE_PRIVATE (line 66875) | SQLITE_PRIVATE int sqlite3VdbeMemNumerify(Mem *pMem){
  function SQLITE_PRIVATE (line 66899) | SQLITE_PRIVATE void sqlite3VdbeMemCast(Mem *pMem, u8 aff, u8 encoding){
  function SQLITE_PRIVATE (line 66941) | SQLITE_PRIVATE void sqlite3VdbeMemInit(Mem *pMem, sqlite3 *db, u16 flags){
  function SQLITE_PRIVATE (line 66961) | SQLITE_PRIVATE void sqlite3VdbeMemSetNull(Mem *pMem){
  function SQLITE_PRIVATE (line 66968) | SQLITE_PRIVATE void sqlite3ValueSetNull(sqlite3_value *p){
  function SQLITE_PRIVATE (line 66976) | SQLITE_PRIVATE void sqlite3VdbeMemSetZeroBlob(Mem *pMem, int n){
  function SQLITE_NOINLINE (line 66991) | static SQLITE_NOINLINE void vdbeReleaseAndSetInt64(Mem *pMem, i64 val){
  function SQLITE_PRIVATE (line 67001) | SQLITE_PRIVATE void sqlite3VdbeMemSetInt64(Mem *pMem, i64 val){
  function SQLITE_PRIVATE (line 67015) | SQLITE_PRIVATE void sqlite3VdbeMemSetDouble(Mem *pMem, double val){
  function SQLITE_PRIVATE (line 67028) | SQLITE_PRIVATE void sqlite3VdbeMemSetRowSet(Mem *pMem){
  function SQLITE_PRIVATE (line 67050) | SQLITE_PRIVATE int sqlite3VdbeMemTooBig(Mem *p){
  function SQLITE_PRIVATE (line 67071) | SQLITE_PRIVATE void sqlite3VdbeMemAboutToChange(Vdbe *pVdbe, Mem *pMem){
  function SQLITE_NOINLINE (line 67091) | static SQLITE_NOINLINE void vdbeClrCopy(Mem *pTo, const Mem *pFrom, int ...
  function SQLITE_PRIVATE (line 67096) | SQLITE_PRIVATE void sqlite3VdbeMemShallowCopy(Mem *pTo, const Mem *pFrom...
  function SQLITE_PRIVATE (line 67112) | SQLITE_PRIVATE int sqlite3VdbeMemCopy(Mem *pTo, const Mem *pFrom){
  function SQLITE_PRIVATE (line 67139) | SQLITE_PRIVATE void sqlite3VdbeMemMove(Mem *pTo, Mem *pFrom){
  function SQLITE_PRIVATE (line 67165) | SQLITE_PRIVATE int sqlite3VdbeMemSetStr(
  function SQLITE_NOINLINE (line 67265) | static SQLITE_NOINLINE int vdbeMemFromBtreeResize(
  function SQLITE_PRIVATE (line 67291) | SQLITE_PRIVATE int sqlite3VdbeMemFromBtree(
  function SQLITE_NOINLINE (line 67331) | static SQLITE_NOINLINE const void *valueToText(sqlite3_value* pVal, u8 e...
  function SQLITE_PRIVATE (line 67375) | SQLITE_PRIVATE const void *sqlite3ValueText(sqlite3_value* pVal, u8 enc){
  function SQLITE_PRIVATE (line 67392) | SQLITE_PRIVATE sqlite3_value *sqlite3ValueNew(sqlite3 *db){
  type ValueNewStat4Ctx (line 67405) | struct ValueNewStat4Ctx {
  function sqlite3_value (line 67423) | static sqlite3_value *valueNew(sqlite3 *db, struct ValueNewStat4Ctx *p){
  function valueFromFunction (line 67485) | static int valueFromFunction(
  function valueFromExpr (line 67579) | static int valueFromExpr(
  function SQLITE_PRIVATE (line 67714) | SQLITE_PRIVATE int sqlite3ValueFromExpr(
  function recordFunc (line 67733) | static void recordFunc(
  function SQLITE_PRIVATE (line 67767) | SQLITE_PRIVATE void sqlite3AnalyzeFunctions(void){
  function stat4ValueFromExpr (line 67792) | static int stat4ValueFromExpr(
  function SQLITE_PRIVATE (line 67866) | SQLITE_PRIVATE int sqlite3Stat4ProbeSetValue(
  function SQLITE_PRIVATE (line 67900) | SQLITE_PRIVATE int sqlite3Stat4ValueFromExpr(
  function SQLITE_PRIVATE (line 67917) | SQLITE_PRIVATE int sqlite3Stat4Column(
  function SQLITE_PRIVATE (line 67962) | SQLITE_PRIVATE void sqlite3Stat4ProbeFree(UnpackedRecord *pRec){
  function SQLITE_PRIVATE (line 67980) | SQLITE_PRIVATE void sqlite3ValueSetStr(
  function SQLITE_PRIVATE (line 67993) | SQLITE_PRIVATE void sqlite3ValueFree(sqlite3_value *v){
  function SQLITE_NOINLINE (line 68004) | static SQLITE_NOINLINE int valueBytes(sqlite3_value *pVal, u8 enc){
  function SQLITE_PRIVATE (line 68007) | SQLITE_PRIVATE int sqlite3ValueBytes(sqlite3_value *pVal, u8 enc){
  function SQLITE_PRIVATE (line 68046) | SQLITE_PRIVATE Vdbe *sqlite3VdbeCreate(Parse *pParse){
  function SQLITE_PRIVATE (line 68070) | SQLITE_PRIVATE void sqlite3VdbeError(Vdbe *p, const char *zFormat, ...){
  function SQLITE_PRIVATE (line 68081) | SQLITE_PRIVATE void sqlite3VdbeSetSql(Vdbe *p, const char *z, int n, int...
  function SQLITE_API (line 68095) | SQLITE_API const char *SQLITE_STDCALL sqlite3_sql(sqlite3_stmt *pStmt){
  function SQLITE_PRIVATE (line 68103) | SQLITE_PRIVATE void sqlite3VdbeSwap(Vdbe *pA, Vdbe *pB){
  function growOpArray (line 68131) | static int growOpArray(Vdbe *v, int nOp){
  function test_addop_breakpoint (line 68165) | static void test_addop_breakpoint(void){
  function SQLITE_NOINLINE (line 68187) | static SQLITE_NOINLINE int growOp3(Vdbe *p, int op, int p1, int p2, int ...
  function SQLITE_PRIVATE (line 68193) | SQLITE_PRIVATE int sqlite3VdbeAddOp3(Vdbe *p, int op, int p1, int p2, in...
  function SQLITE_PRIVATE (line 68239) | SQLITE_PRIVATE int sqlite3VdbeAddOp0(Vdbe *p, int op){
  function SQLITE_PRIVATE (line 68242) | SQLITE_PRIVATE int sqlite3VdbeAddOp1(Vdbe *p, int op, int p1){
  function SQLITE_PRIVATE (line 68245) | SQLITE_PRIVATE int sqlite3VdbeAddOp2(Vdbe *p, int op, int p1, int p2){
  function SQLITE_PRIVATE (line 68251) | SQLITE_PRIVATE int sqlite3VdbeGoto(Vdbe *p, int iDest){
  function SQLITE_PRIVATE (line 68258) | SQLITE_PRIVATE int sqlite3VdbeLoadString(Vdbe *p, int iDest, const char ...
  function SQLITE_PRIVATE (line 68270) | SQLITE_PRIVATE void sqlite3VdbeMultiLoad(Vdbe *p, int iDest, const char ...
  function SQLITE_PRIVATE (line 68290) | SQLITE_PRIVATE int sqlite3VdbeAddOp4(
  function SQLITE_PRIVATE (line 68308) | SQLITE_PRIVATE int sqlite3VdbeAddOp4Dup8(
  function SQLITE_PRIVATE (line 68330) | SQLITE_PRIVATE void sqlite3VdbeAddParseSchemaOp(Vdbe *p, int iDb, char *...
  function SQLITE_PRIVATE (line 68339) | SQLITE_PRIVATE int sqlite3VdbeAddOp4Int(
  function SQLITE_PRIVATE (line 68354) | SQLITE_PRIVATE void sqlite3VdbeEndCoroutine(Vdbe *v, int regYield){
  function SQLITE_PRIVATE (line 68381) | SQLITE_PRIVATE int sqlite3VdbeMakeLabel(Vdbe *v){
  function SQLITE_PRIVATE (line 68400) | SQLITE_PRIVATE void sqlite3VdbeResolveLabel(Vdbe *v, int x){
  function SQLITE_PRIVATE (line 68415) | SQLITE_PRIVATE void sqlite3VdbeRunOnlyOnce(Vdbe *p){
  function SQLITE_PRIVATE (line 68422) | SQLITE_PRIVATE void sqlite3VdbeReusable(Vdbe *p){
  type VdbeOpIter (line 68444) | typedef struct VdbeOpIter VdbeOpIter;
  type VdbeOpIter (line 68445) | struct VdbeOpIter {
  function Op (line 68452) | static Op *opIterNext(VdbeOpIter *p){
  function SQLITE_PRIVATE (line 68517) | SQLITE_PRIVATE int sqlite3VdbeAssertMayAbort(Vdbe *v, int mayAbort){
  function resolveP2Values (line 68573) | static void resolveP2Values(Vdbe *p, int *pMaxFuncArgs){
  function SQLITE_PRIVATE (line 68650) | SQLITE_PRIVATE int sqlite3VdbeCurrentAddr(Vdbe *p){
  function SQLITE_PRIVATE (line 68664) | SQLITE_PRIVATE void sqlite3VdbeVerifyNoMallocRequired(Vdbe *p, int N){
  function SQLITE_PRIVATE (line 68680) | SQLITE_PRIVATE VdbeOp *sqlite3VdbeTakeOpArray(Vdbe *p, int *pnOp, int *p...
  function SQLITE_PRIVATE (line 68700) | SQLITE_PRIVATE VdbeOp *sqlite3VdbeAddOpList(
  function SQLITE_PRIVATE (line 68748) | SQLITE_PRIVATE void sqlite3VdbeScanStatus(
  function SQLITE_PRIVATE (line 68776) | SQLITE_PRIVATE void sqlite3VdbeChangeOpcode(Vdbe *p, u32 addr, u8 iNewOp...
  function SQLITE_PRIVATE (line 68779) | SQLITE_PRIVATE void sqlite3VdbeChangeP1(Vdbe *p, u32 addr, int val){
  function SQLITE_PRIVATE (line 68782) | SQLITE_PRIVATE void sqlite3VdbeChangeP2(Vdbe *p, u32 addr, int val){
  function SQLITE_PRIVATE (line 68785) | SQLITE_PRIVATE void sqlite3VdbeChangeP3(Vdbe *p, u32 addr, int val){
  function SQLITE_PRIVATE (line 68788) | SQLITE_PRIVATE void sqlite3VdbeChangeP5(Vdbe *p, u8 p5){
  function SQLITE_PRIVATE (line 68796) | SQLITE_PRIVATE void sqlite3VdbeJumpHere(Vdbe *p, int addr){
  function freeEphemeralFunction (line 68806) | static void freeEphemeralFunction(sqlite3 *db, FuncDef *pDef){
  function freeP4 (line 68817) | static void freeP4(sqlite3 *db, int p4type, void *p4){
  function vdbeFreeOpArray (line 68873) | static void vdbeFreeOpArray(sqlite3 *db, Op *aOp, int nOp){
  function SQLITE_PRIVATE (line 68891) | SQLITE_PRIVATE void sqlite3VdbeLinkSubProgram(Vdbe *pVdbe, SubProgram *p){
  function SQLITE_PRIVATE (line 68899) | SQLITE_PRIVATE int sqlite3VdbeChangeToNoop(Vdbe *p, int addr){
  function SQLITE_PRIVATE (line 68915) | SQLITE_PRIVATE int sqlite3VdbeDeletePriorOpcode(Vdbe *p, u8 op){
  function vdbeChangeP4Full (line 68940) | static void SQLITE_NOINLINE vdbeChangeP4Full(
  function SQLITE_PRIVATE (line 68959) | SQLITE_PRIVATE void sqlite3VdbeChangeP4(Vdbe *p, int addr, const char *z...
  function SQLITE_PRIVATE (line 68997) | SQLITE_PRIVATE void sqlite3VdbeSetP4KeyInfo(Parse *pParse, Index *pIdx){
  function vdbeVComment (line 69012) | static void vdbeVComment(Vdbe *p, const char *zFormat, va_list ap){
  function SQLITE_PRIVATE (line 69021) | SQLITE_PRIVATE void sqlite3VdbeComment(Vdbe *p, const char *zFormat, ...){
  function SQLITE_PRIVATE (line 69029) | SQLITE_PRIVATE void sqlite3VdbeNoopComment(Vdbe *p, const char *zFormat,...
  function SQLITE_PRIVATE (line 69044) | SQLITE_PRIVATE void sqlite3VdbeSetLineNumber(Vdbe *v, int iLine){
  function SQLITE_PRIVATE (line 69062) | SQLITE_PRIVATE VdbeOp *sqlite3VdbeGetOp(Vdbe *p, int addr){
  function translateP (line 69083) | static int translateP(char c, const Op *pOp){
  function displayComment (line 69104) | static int displayComment(
  function displayP4Expr (line 69173) | static void displayP4Expr(StrAccum *p, Expr *pExpr){
  function SQLITE_PRIVATE (line 69367) | SQLITE_PRIVATE void sqlite3VdbeUsesBtree(Vdbe *p, int i){
  function SQLITE_PRIVATE (line 69398) | SQLITE_PRIVATE void sqlite3VdbeEnter(Vdbe *p){
  function SQLITE_NOINLINE (line 69419) | static SQLITE_NOINLINE void vdbeLeave(Vdbe *p){
  function SQLITE_PRIVATE (line 69433) | SQLITE_PRIVATE void sqlite3VdbeLeave(Vdbe *p){
  function SQLITE_PRIVATE (line 69443) | SQLITE_PRIVATE void sqlite3VdbePrintOp(FILE *pOut, int pc, Op *pOp){
  function releaseMemArray (line 69469) | static void releaseMemArray(Mem *p, int N){
  function SQLITE_PRIVATE (line 69515) | SQLITE_PRIVATE void sqlite3VdbeFrameDelete(VdbeFrame *p){
  function SQLITE_PRIVATE (line 69543) | SQLITE_PRIVATE int sqlite3VdbeList(
  function SQLITE_PRIVATE (line 69722) | SQLITE_PRIVATE void sqlite3VdbePrintSql(Vdbe *p){
  function SQLITE_PRIVATE (line 69741) | SQLITE_PRIVATE void sqlite3VdbeIOTraceSql(Vdbe *p){
  type ReusableSpace (line 69771) | struct ReusableSpace {
  type ReusableSpace (line 69792) | struct ReusableSpace
  function SQLITE_PRIVATE (line 69814) | SQLITE_PRIVATE void sqlite3VdbeRewind(Vdbe *p){
  function SQLITE_PRIVATE (line 69867) | SQLITE_PRIVATE void sqlite3VdbeMakeReady(
  function SQLITE_PRIVATE (line 69976) | SQLITE_PRIVATE void sqlite3VdbeFreeCursor(Vdbe *p, VdbeCursor *pCx){
  function closeCursorsInFrame (line 70013) | static void closeCursorsInFrame(Vdbe *p){
  function SQLITE_PRIVATE (line 70031) | SQLITE_PRIVATE int sqlite3VdbeFrameRestore(VdbeFrame *pFrame){
  function closeAllCursors (line 70062) | static void closeAllCursors(Vdbe *p){
  function Cleanup (line 70089) | static void Cleanup(Vdbe *p){
  function SQLITE_PRIVATE (line 70113) | SQLITE_PRIVATE void sqlite3VdbeSetNumCols(Vdbe *p, int nResColumn){
  function SQLITE_PRIVATE (line 70141) | SQLITE_PRIVATE int sqlite3VdbeSetColName(
  function vdbeCommit (line 70169) | static int vdbeCommit(sqlite3 *db, Vdbe *p){
  function checkActiveVdbeCnt (line 70431) | static void checkActiveVdbeCnt(sqlite3 *db){
  function SQLITE_PRIVATE (line 70463) | SQLITE_PRIVATE int sqlite3VdbeCloseStatement(Vdbe *p, int eOp){
  function SQLITE_PRIVATE (line 70529) | SQLITE_PRIVATE int sqlite3VdbeCheckFk(Vdbe *p, int deferred){
  function SQLITE_PRIVATE (line 70556) | SQLITE_PRIVATE int sqlite3VdbeHalt(Vdbe *p){
  function SQLITE_PRIVATE (line 70758) | SQLITE_PRIVATE void sqlite3VdbeResetStepResult(Vdbe *p){
  function SQLITE_PRIVATE (line 70770) | SQLITE_PRIVATE int sqlite3VdbeTransferError(Vdbe *p){
  function vdbeInvokeSqllog (line 70792) | static void vdbeInvokeSqllog(Vdbe *v){
  function SQLITE_PRIVATE (line 70819) | SQLITE_PRIVATE int sqlite3VdbeReset(Vdbe *p){
  function SQLITE_PRIVATE (line 70899) | SQLITE_PRIVATE int sqlite3VdbeFinalize(Vdbe *p){
  function SQLITE_PRIVATE (line 70925) | SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(sqlite3 *db, AuxData **pp, ...
  function SQLITE_PRIVATE (line 70951) | SQLITE_PRIVATE void sqlite3VdbeClearObject(sqlite3 *db, Vdbe *p){
  function SQLITE_PRIVATE (line 70979) | SQLITE_PRIVATE void sqlite3VdbeDelete(Vdbe *p){
  function handleDeferredMoveto (line 71005) | static int SQLITE_NOINLINE handleDeferredMoveto(VdbeCursor *p){
  function handleMovedCursor (line 71031) | static int SQLITE_NOINLINE handleMovedCursor(VdbeCursor *p){
  function SQLITE_PRIVATE (line 71046) | SQLITE_PRIVATE int sqlite3VdbeCursorRestore(VdbeCursor *p){
  function SQLITE_PRIVATE (line 71067) | SQLITE_PRIVATE int sqlite3VdbeCursorMoveto(VdbeCursor **pp, int *piCol){
  function SQLITE_PRIVATE (line 71131) | SQLITE_PRIVATE u32 sqlite3VdbeSerialType(Mem *pMem, int file_format, u32...
  function SQLITE_PRIVATE (line 71203) | SQLITE_PRIVATE u32 sqlite3VdbeSerialTypeLen(u32 serial_type){
  function SQLITE_PRIVATE (line 71212) | SQLITE_PRIVATE u8 sqlite3VdbeOneByteSerialTypeLen(u8 serial_type){
  function u64 (line 71252) | static u64 floatSwap(u64 in){
  function SQLITE_PRIVATE (line 71283) | SQLITE_PRIVATE u32 sqlite3VdbeSerialPut(u8 *buf, Mem *pMem, u32 serial_t...
  function u32 (line 71337) | static u32 SQLITE_NOINLINE serialGet(
  function SQLITE_PRIVATE (line 71373) | SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(
  function SQLITE_PRIVATE (line 71472) | SQLITE_PRIVATE UnpackedRecord *sqlite3VdbeAllocUnpackedRecord(
  function SQLITE_PRIVATE (line 71509) | SQLITE_PRIVATE void sqlite3VdbeRecordUnpack(
  function vdbeRecordCompareDebug (line 71555) | static int vdbeRecordCompareDebug(
  function vdbeAssertFieldCountWithinLimits (line 71660) | static void vdbeAssertFieldCountWithinLimits(
  function vdbeCompareMemString (line 71690) | static int vdbeCompareMemString(
  function SQLITE_NOINLINE (line 71727) | static SQLITE_NOINLINE int sqlite3BlobCompare(const Mem *pB1, const Mem ...
  function sqlite3IntFloatCompare (line 71738) | static int sqlite3IntFloatCompare(i64 i, double r){
  function SQLITE_PRIVATE (line 71771) | SQLITE_PRIVATE int sqlite3MemCompare(const Mem *pMem1, const Mem *pMem2,...
  function i64 (line 71857) | static i64 vdbeRecordDecodeInt(u32 serial_type, const u8 *aKey){
  function SQLITE_PRIVATE (line 71912) | SQLITE_PRIVATE int sqlite3VdbeRecordCompareWithSkip(
  function SQLITE_PRIVATE (line 72091) | SQLITE_PRIVATE int sqlite3VdbeRecordCompare(
  function vdbeRecordCompareInt (line 72108) | static int vdbeRecordCompareInt(
  function vdbeRecordCompareString (line 72201) | static int vdbeRecordCompareString(
  function SQLITE_PRIVATE (line 72262) | SQLITE_PRIVATE RecordCompare sqlite3VdbeFindCompare(UnpackedRecord *p){
  function SQLITE_PRIVATE (line 72308) | SQLITE_PRIVATE int sqlite3VdbeIdxRowid(sqlite3 *db, BtCursor *pCur, i64 ...
  function SQLITE_PRIVATE (line 72386) | SQLITE_PRIVATE int sqlite3VdbeIdxKeyCompare(
  function SQLITE_PRIVATE (line 72422) | SQLITE_PRIVATE void sqlite3VdbeSetChanges(sqlite3 *db, int nChange){
  function SQLITE_PRIVATE (line 72432) | SQLITE_PRIVATE void sqlite3VdbeCountChanges(Vdbe *v){
  function SQLITE_PRIVATE (line 72446) | SQLITE_PRIVATE void sqlite3ExpirePreparedStatements(sqlite3 *db){
  function SQLITE_PRIVATE (line 72456) | SQLITE_PRIVATE sqlite3 *sqlite3VdbeDb(Vdbe *v){
  function SQLITE_PRIVATE (line 72468) | SQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetBoundValue(Vdbe *v, int iVar...
  function SQLITE_PRIVATE (line 72489) | SQLITE_PRIVATE void sqlite3VdbeSetVarmask(Vdbe *v, int iVar){
  function SQLITE_PRIVATE (line 72504) | SQLITE_PRIVATE void sqlite3VtabImportErrmsg(Vdbe *p, sqlite3_vtab *pVtab){
  function SQLITE_STDCALL (line 72544) | SQLITE_STDCALL sqlite3_expired(sqlite3_stmt *pStmt){
  function vdbeSafety (line 72555) | static int vdbeSafety(Vdbe *p){
  function vdbeSafetyNotNull (line 72563) | static int vdbeSafetyNotNull(Vdbe *p){
  function SQLITE_NOINLINE (line 72577) | static SQLITE_NOINLINE void invokeProfileCallback(sqlite3 *db, Vdbe *p){
  function SQLITE_STDCALL (line 72606) | SQLITE_STDCALL sqlite3_finalize(sqlite3_stmt *pStmt){
  function SQLITE_STDCALL (line 72633) | SQLITE_STDCALL sqlite3_reset(sqlite3_stmt *pStmt){
  function SQLITE_STDCALL (line 72654) | SQLITE_STDCALL sqlite3_clear_bindings(sqlite3_stmt *pStmt){
  function SQLITE_API (line 72678) | SQLITE_API const void *SQLITE_STDCALL sqlite3_value_blob(sqlite3_value *...
  function SQLITE_STDCALL (line 72691) | SQLITE_STDCALL sqlite3_value_bytes(sqlite3_value *pVal){
  function SQLITE_STDCALL (line 72694) | SQLITE_STDCALL sqlite3_value_bytes16(sqlite3_value *pVal){
  function SQLITE_STDCALL (line 72697) | SQLITE_STDCALL sqlite3_value_double(sqlite3_value *pVal){
  function SQLITE_STDCALL (line 72700) | SQLITE_STDCALL sqlite3_value_int(sqlite3_value *pVal){
  function SQLITE_STDCALL (line 72703) | SQLITE_STDCALL sqlite3_value_int64(sqlite3_value *pVal){
  function SQLITE_STDCALL (line 72706) | SQLITE_STDCALL sqlite3_value_subtype(sqlite3_value *pVal){
  function SQLITE_API (line 72714) | SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16(sqlite3_value...
  function SQLITE_API (line 72717) | SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16be(sqlite3_val...
  function SQLITE_API (line 72720) | SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16le(sqlite3_val...
  function SQLITE_STDCALL (line 72728) | SQLITE_STDCALL sqlite3_value_type(sqlite3_value* pVal){
  function SQLITE_STDCALL (line 72791) | SQLITE_STDCALL sqlite3_value_free(sqlite3_value *pOld){
  function setResultStrOrError (line 72807) | static void setResultStrOrError(
  function invokeValueDestructor (line 72818) | static int invokeValueDestructor(
  function SQLITE_STDCALL (line 72834) | SQLITE_STDCALL sqlite3_result_blob(
  function SQLITE_STDCALL (line 72844) | SQLITE_STDCALL sqlite3_result_blob64(
  function SQLITE_STDCALL (line 72858) | SQLITE_STDCALL sqlite3_result_double(sqlite3_context *pCtx, double rVal){
  function SQLITE_STDCALL (line 72862) | SQLITE_STDCALL sqlite3_result_error(sqlite3_context *pCtx, const char *z...
  function SQLITE_STDCALL (line 72869) | SQLITE_STDCALL sqlite3_result_error16(sqlite3_context *pCtx, const void ...
  function SQLITE_STDCALL (line 72876) | SQLITE_STDCALL sqlite3_result_int(sqlite3_context *pCtx, int iVal){
  function SQLITE_STDCALL (line 72880) | SQLITE_STDCALL sqlite3_result_int64(sqlite3_context *pCtx, i64 iVal){
  function SQLITE_STDCALL (line 72884) | SQLITE_STDCALL sqlite3_result_null(sqlite3_context *pCtx){
  function SQLITE_STDCALL (line 72888) | SQLITE_STDCALL sqlite3_result_subtype(sqlite3_context *pCtx, unsigned in...
  function SQLITE_STDCALL (line 72894) | SQLITE_STDCALL sqlite3_result_text(
  function SQLITE_STDCALL (line 72903) | SQLITE_STDCALL sqlite3_result_text64(
  function SQLITE_STDCALL (line 72920) | SQLITE_STDCALL sqlite3_result_text16(
  function SQLITE_STDCALL (line 72929) | SQLITE_STDCALL sqlite3_result_text16be(
  function SQLITE_STDCALL (line 72938) | SQLITE_STDCALL sqlite3_result_text16le(
  function SQLITE_STDCALL (line 72948) | SQLITE_STDCALL sqlite3_result_value(sqlite3_context *pCtx, sqlite3_value...
  function SQLITE_STDCALL (line 72952) | SQLITE_STDCALL sqlite3_result_zeroblob(sqlite3_context *pCtx, int n){
  function SQLITE_STDCALL (line 72956) | SQLITE_STDCALL sqlite3_result_zeroblob64(sqlite3_context *pCtx, u64 n){
  function SQLITE_STDCALL (line 72965) | SQLITE_STDCALL sqlite3_result_error_code(sqlite3_context *pCtx, int errC...
  function SQLITE_STDCALL (line 72978) | SQLITE_STDCALL sqlite3_result_error_toobig(sqlite3_context *pCtx){
  function SQLITE_STDCALL (line 72987) | SQLITE_STDCALL sqlite3_result_error_nomem(sqlite3_context *pCtx){
  function doWalCallbacks (line 72999) | static int doWalCallbacks(sqlite3 *db){
  function sqlite3Step (line 73029) | static int sqlite3Step(Vdbe *p){
  function SQLITE_STDCALL (line 73158) | SQLITE_STDCALL sqlite3_step(sqlite3_stmt *pStmt){
  function SQLITE_API (line 73209) | SQLITE_API void *SQLITE_STDCALL sqlite3_user_data(sqlite3_context *p){
  function SQLITE_API (line 73224) | SQLITE_API sqlite3 *SQLITE_STDCALL sqlite3_context_db_handle(sqlite3_con...
  function SQLITE_PRIVATE (line 73236) | SQLITE_PRIVATE sqlite3_int64 sqlite3StmtCurrentTime(sqlite3_context *p){
  function SQLITE_PRIVATE (line 73260) | SQLITE_PRIVATE void sqlite3InvalidFunction(
  function SQLITE_NOINLINE (line 73278) | static SQLITE_NOINLINE void *createAggContext(sqlite3_context *p, int nB...
  function SQLITE_API (line 73300) | SQLITE_API void *SQLITE_STDCALL sqlite3_aggregate_context(sqlite3_contex...
  function SQLITE_API (line 73315) | SQLITE_API void *SQLITE_STDCALL sqlite3_get_auxdata(sqlite3_context *pCt...
  function SQLITE_STDCALL (line 73336) | SQLITE_STDCALL sqlite3_set_auxdata(
  function SQLITE_STDCALL (line 73391) | SQLITE_STDCALL sqlite3_aggregate_count(sqlite3_context *p){
  function SQLITE_STDCALL (line 73400) | SQLITE_STDCALL sqlite3_column_count(sqlite3_stmt *pStmt){
  function SQLITE_STDCALL (line 73409) | SQLITE_STDCALL sqlite3_data_count(sqlite3_stmt *pStmt){
  function Mem (line 73458) | static Mem *columnMem(sqlite3_stmt *pStmt, int i){
  function columnMallocFailure (line 73494) | static void columnMallocFailure(sqlite3_stmt *pStmt)
  function SQLITE_API (line 73512) | SQLITE_API const void *SQLITE_STDCALL sqlite3_column_blob(sqlite3_stmt *...
  function SQLITE_STDCALL (line 73522) | SQLITE_STDCALL sqlite3_column_bytes(sqlite3_stmt *pStmt, int i){
  function SQLITE_STDCALL (line 73527) | SQLITE_STDCALL sqlite3_column_bytes16(sqlite3_stmt *pStmt, int i){
  function SQLITE_STDCALL (line 73532) | SQLITE_STDCALL sqlite3_column_double(sqlite3_stmt *pStmt, int i){
  function SQLITE_STDCALL (line 73537) | SQLITE_STDCALL sqlite3_column_int(sqlite3_stmt *pStmt, int i){
  function SQLITE_STDCALL (line 73542) | SQLITE_STDCALL sqlite3_column_int64(sqlite3_stmt *pStmt, int i){
  function SQLITE_API (line 73562) | SQLITE_API const void *SQLITE_STDCALL sqlite3_column_text16(sqlite3_stmt...
  function SQLITE_STDCALL (line 73568) | SQLITE_STDCALL sqlite3_column_type(sqlite3_stmt *pStmt, int i){
  function SQLITE_API (line 73632) | SQLITE_API const char *SQLITE_STDCALL sqlite3_column_name(sqlite3_stmt *...
  function SQLITE_API (line 73637) | SQLITE_API const void *SQLITE_STDCALL sqlite3_column_name16(sqlite3_stmt...
  function SQLITE_API (line 73657) | SQLITE_API const char *SQLITE_STDCALL sqlite3_column_decltype(sqlite3_st...
  function SQLITE_API (line 73662) | SQLITE_API const void *SQLITE_STDCALL sqlite3_column_decltype16(sqlite3_...
  function SQLITE_API (line 73675) | SQLITE_API const char *SQLITE_STDCALL sqlite3_column_database_name(sqlit...
  function SQLITE_API (line 73680) | SQLITE_API const void *SQLITE_STDCALL sqlite3_column_database_name16(sql...
  function SQLITE_API (line 73691) | SQLITE_API const char *SQLITE_STDCALL sqlite3_column_table_name(sqlite3_...
  function SQLITE_API (line 73696) | SQLITE_API const void *SQLITE_STDCALL sqlite3_column_table_name16(sqlite...
  function SQLITE_API (line 73707) | SQLITE_API const char *SQLITE_STDCALL sqlite3_column_origin_name(sqlite3...
  function SQLITE_API (line 73712) | SQLITE_API const void *SQLITE_STDCALL sqlite3_column_origin_name16(sqlit...
  function vdbeUnbind (line 73735) | static int vdbeUnbind(Vdbe *p, int i){
  function bindText (line 73779) | static int bindText(
  function SQLITE_STDCALL (line 73813) | SQLITE_STDCALL sqlite3_bind_blob(
  function SQLITE_STDCALL (line 73825) | SQLITE_STDCALL sqlite3_bind_blob64(
  function SQLITE_STDCALL (line 73839) | SQLITE_STDCALL sqlite3_bind_double(sqlite3_stmt *pStmt, int i, double rV...
  function SQLITE_STDCALL (line 73849) | SQLITE_STDCALL sqlite3_bind_int(sqlite3_stmt *p, int i, int iValue){
  function SQLITE_STDCALL (line 73852) | SQLITE_STDCALL sqlite3_bind_int64(sqlite3_stmt *pStmt, int i, sqlite_int...
  function SQLITE_STDCALL (line 73862) | SQLITE_STDCALL sqlite3_bind_null(sqlite3_stmt *pStmt, int i){
  function SQLITE_STDCALL (line 73871) | SQLITE_STDCALL sqlite3_bind_text(
  function SQLITE_STDCALL (line 73880) | SQLITE_STDCALL sqlite3_bind_text64(
  function SQLITE_STDCALL (line 73897) | SQLITE_STDCALL sqlite3_bind_text16(
  function SQLITE_STDCALL (line 73907) | SQLITE_STDCALL sqlite3_bind_value(sqlite3_stmt *pStmt, int i, const sqli...
  function SQLITE_STDCALL (line 73938) | SQLITE_STDCALL sqlite3_bind_zeroblob(sqlite3_stmt *pStmt, int i, int n){
  function SQLITE_STDCALL (line 73948) | SQLITE_STDCALL sqlite3_bind_zeroblob64(sqlite3_stmt *pStmt, int i, sqlit...
  function SQLITE_STDCALL (line 73967) | SQLITE_STDCALL sqlite3_bind_parameter_count(sqlite3_stmt *pStmt){
  function SQLITE_API (line 73978) | SQLITE_API const char *SQLITE_STDCALL sqlite3_bind_parameter_name(sqlite...
  function SQLITE_PRIVATE (line 73991) | SQLITE_PRIVATE int sqlite3VdbeParameterIndex(Vdbe *p, const char *zName,...
  function SQLITE_STDCALL (line 74006) | SQLITE_STDCALL sqlite3_bind_parameter_index(sqlite3_stmt *pStmt, const c...
  function SQLITE_PRIVATE (line 74013) | SQLITE_PRIVATE int sqlite3TransferBindings(sqlite3_stmt *pFromStmt, sqli...
  function SQLITE_STDCALL (line 74040) | SQLITE_STDCALL sqlite3_transfer_bindings(sqlite3_stmt *pFromStmt, sqlite...
  function SQLITE_API (line 74062) | SQLITE_API sqlite3 *SQLITE_STDCALL sqlite3_db_handle(sqlite3_stmt *pStmt){
  function SQLITE_STDCALL (line 74070) | SQLITE_STDCALL sqlite3_stmt_readonly(sqlite3_stmt *pStmt){
  function SQLITE_STDCALL (line 74077) | SQLITE_STDCALL sqlite3_stmt_busy(sqlite3_stmt *pStmt){
  function SQLITE_STDCALL (line 74109) | SQLITE_STDCALL sqlite3_stmt_status(sqlite3_stmt *pStmt, int op, int rese...
  function SQLITE_STDCALL (line 74127) | SQLITE_STDCALL sqlite3_stmt_scanstatus(
  function SQLITE_STDCALL (line 74186) | SQLITE_STDCALL sqlite3_stmt_scanstatus_reset(sqlite3_stmt *pStmt){
  function findNextHostParameter (line 74222) | static int findNextHostParameter(const char *zSql, int *pnToken){
  function SQLITE_PRIVATE (line 74265) | SQLITE_PRIVATE char *sqlite3VdbeExpandSql(
  function updateMaxBlobsize (line 74466) | static void updateMaxBlobsize(Mem *p){
  function vdbeTakeBranch (line 74514) | static void vdbeTakeBranch(int iSrcLine, u8 I, u8 M){
  function VdbeCursor (line 74558) | static VdbeCursor *allocateCursor(
  function applyNumericAffinity (line 74627) | static void applyNumericAffinity(Mem *pRec, int bTryForInt){
  function applyAffinity (line 74661) | static void applyAffinity(
  function SQLITE_STDCALL (line 74694) | SQLITE_STDCALL sqlite3_value_numeric_type(sqlite3_value *pVal){
  function SQLITE_PRIVATE (line 74708) | SQLITE_PRIVATE void sqlite3ValueApplyAffinity(
  function u16 (line 74722) | static u16 SQLITE_NOINLINE computeNumericType(Mem *pMem){
  function u16 (line 74741) | static u16 numericType(Mem *pMem){
  function SQLITE_PRIVATE (line 74756) | SQLITE_PRIVATE void sqlite3VdbeMemPrettyPrint(Mem *pMem, char *zBuf){
  function memTracePrint (line 74838) | static void memTracePrint(Mem *p){
  function registerTrace (line 74860) | static void registerTrace(int iReg, Mem *p){
  function sqlite_uint64 (line 74911) | __inline__ sqlite_uint64 sqlite3Hwtime(void){
  function sqlite_uint64 (line 74919) | __declspec(naked) __inline sqlite_uint64 __cdecl sqlite3Hwtime(void){
  function sqlite_uint64 (line 74930) | __inline__ sqlite_uint64 sqlite3Hwtime(void){
  function sqlite_uint64 (line 74938) | __inline__ sqlite_uint64 sqlite3Hwtime(void){
  function sqlite3Hwtime (line 74962) | sqlite3Hwtime(void){ return ((sqlite_uint64)0); }
  function checkSavepointCount (line 74984) | static int checkSavepointCount(sqlite3 *db){
  function SQLITE_NOINLINE (line 74997) | static SQLITE_NOINLINE Mem *out2PrereleaseWithClear(Mem *pOut){
  function Mem (line 75002) | static Mem *out2Prerelease(Vdbe *p, VdbeOp *pOp){
  function SQLITE_PRIVATE (line 75021) | SQLITE_PRIVATE int sqlite3VdbeExec(
  type Incrblob (line 81381) | typedef struct Incrblob Incrblob;
  type Incrblob (line 81382) | struct Incrblob {
  function blobSeekToRow (line 81410) | static int blobSeekToRow(Incrblob *p, sqlite3_int64 iRow, char **pzErr){
  function SQLITE_STDCALL (line 81464) | SQLITE_STDCALL sqlite3_blob_open(
  function SQLITE_STDCALL (line 81703) | SQLITE_STDCALL sqlite3_blob_close(sqlite3_blob *pBlob){
  function blobReadWrite (line 81723) | static int blobReadWrite(
  function SQLITE_STDCALL (line 81772) | SQLITE_STDCALL sqlite3_blob_read(sqlite3_blob *pBlob, void *z, int n, in...
  function SQLITE_STDCALL (line 81779) | SQLITE_STDCALL sqlite3_blob_write(sqlite3_blob *pBlob, const void *z, in...
  function SQLITE_STDCALL (line 81789) | SQLITE_STDCALL sqlite3_blob_bytes(sqlite3_blob *pBlob){
  function SQLITE_STDCALL (line 81804) | SQLITE_STDCALL sqlite3_blob_reopen(sqlite3_blob *pBlob, sqlite3_int64 iR...
  type MergeEngine (line 81997) | typedef struct MergeEngine MergeEngine;
  type PmaReader (line 81998) | typedef struct PmaReader PmaReader;
  type PmaWriter (line 81999) | typedef struct PmaWriter PmaWriter;
  type SorterRecord (line 82000) | typedef struct SorterRecord SorterRecord;
  type SortSubtask (line 82001) | typedef struct SortSubtask SortSubtask;
  type SorterFile (line 82002) | typedef struct SorterFile SorterFile;
  type SorterList (line 82003) | typedef struct SorterList SorterList;
  type IncrMerger (line 82004) | typedef struct IncrMerger IncrMerger;
  type SorterFile (line 82010) | struct SorterFile {
  type SorterList (line 82023) | struct SorterList {
  type MergeEngine (line 82093) | struct MergeEngine {
  type SortSubtask (line 82132) | struct SortSubtask {
  type VdbeSorter (line 82154) | struct VdbeSorter {
  type PmaReader (line 82187) | struct PmaReader {
  type IncrMerger (line 82233) | struct IncrMerger {
  type PmaWriter (line 82251) | struct PmaWriter {
  type SorterRecord (line 82279) | struct SorterRecord {
  function vdbePmaReaderClear (line 82306) | static void vdbePmaReaderClear(PmaReader *pReadr){
  function vdbePmaReadBlob (line 82323) | static int vdbePmaReadBlob(
  function vdbePmaReadVarint (line 82417) | static int vdbePmaReadVarint(PmaReader *p, u64 *pnOut){
  function vdbeSorterMapFile (line 82450) | static int vdbeSorterMapFile(SortSubtask *pTask, SorterFile *pFile, u8 *...
  function vdbePmaReaderSeek (line 82467) | static int vdbePmaReaderSeek(
  function vdbePmaReaderNext (line 82514) | static int vdbePmaReaderNext(PmaReader *pReadr){
  function vdbePmaReaderInit (line 82561) | static int vdbePmaReaderInit(
  function vdbeSorterCompareTail (line 82594) | static int vdbeSorterCompareTail(
  function vdbeSorterCompare (line 82621) | static int vdbeSorterCompare(
  function vdbeSorterCompareText (line 82640) | static int vdbeSorterCompareText(
  function vdbeSorterCompareInt (line 82681) | static int vdbeSorterCompareInt(
  function SQLITE_PRIVATE (line 82764) | SQLITE_PRIVATE int sqlite3VdbeSorterInit(
  function vdbeSorterRecordFree (line 82860) | static void vdbeSorterRecordFree(sqlite3 *db, SorterRecord *pRecord){
  function vdbeSortSubtaskCleanup (line 82873) | static void vdbeSortSubtaskCleanup(sqlite3 *db, SortSubtask *pTask){
  function vdbeSorterWorkDebug (line 82896) | static void vdbeSorterWorkDebug(SortSubtask *pTask, const char *zEvent){
  function vdbeSorterRewindDebug (line 82902) | static void vdbeSorterRewindDebug(const char *zEvent){
  function vdbeSorterPopulateDebug (line 82907) | static void vdbeSorterPopulateDebug(
  function vdbeSorterBlockDebug (line 82916) | static void vdbeSorterBlockDebug(
  function vdbeSorterJoinThread (line 82938) | static int vdbeSorterJoinThread(SortSubtask *pTask){
  function vdbeSorterCreateThread (line 82959) | static int vdbeSorterCreateThread(
  function vdbeSorterJoinAll (line 82972) | static int vdbeSorterJoinAll(VdbeSorter *pSorter, int rcin){
  function MergeEngine (line 83002) | static MergeEngine *vdbeMergeEngineNew(int nReader){
  function vdbeMergeEngineFree (line 83025) | static void vdbeMergeEngineFree(MergeEngine *pMerger){
  function vdbeIncrFree (line 83039) | static void vdbeIncrFree(IncrMerger *pIncr){
  function SQLITE_PRIVATE (line 83056) | SQLITE_PRIVATE void sqlite3VdbeSorterReset(sqlite3 *db, VdbeSorter *pSor...
  function SQLITE_PRIVATE (line 83089) | SQLITE_PRIVATE void sqlite3VdbeSorterClose(sqlite3 *db, VdbeCursor *pCsr){
  function vdbeSorterExtendFile (line 83111) | static void vdbeSorterExtendFile(sqlite3 *db, sqlite3_file *pFd, i64 nBy...
  function vdbeSorterOpenTempFile (line 83130) | static int vdbeSorterOpenTempFile(
  function vdbeSortAllocUnpacked (line 83157) | static int vdbeSortAllocUnpacked(SortSubtask *pTask){
  function vdbeSorterMerge (line 83176) | static void vdbeSorterMerge(
  function SorterCompare (line 83211) | static SorterCompare vdbeSorterGetCompare(VdbeSorter *p){
  function vdbeSorterSort (line 83225) | static int vdbeSorterSort(SortSubtask *pTask, SorterList *pList){
  function vdbePmaWriterInit (line 83280) | static void vdbePmaWriterInit(
  function vdbePmaWriteBlob (line 83302) | static void vdbePmaWriteBlob(PmaWriter *p, u8 *pData, int nData){
  function vdbePmaWriterFinish (line 83335) | static int vdbePmaWriterFinish(PmaWriter *p, i64 *piEof){
  function vdbePmaWriteVarint (line 83354) | static void vdbePmaWriteVarint(PmaWriter *p, u64 iVal){
  function vdbeSorterListToPMA (line 83375) | static int vdbeSorterListToPMA(SortSubtask *pTask, SorterList *pList){
  function vdbeMergeEngineStep (line 83439) | static int vdbeMergeEngineStep(
  function vdbeSorterFlushPMA (line 83524) | static int vdbeSorterFlushPMA(VdbeSorter *pSorter){
  function SQLITE_PRIVATE (line 83591) | SQLITE_PRIVATE int sqlite3VdbeSorterWrite(
  function vdbeIncrPopulate (line 83699) | static int vdbeIncrPopulate(IncrMerger *pIncr){
  function vdbeIncrBgPopulate (line 83751) | static int vdbeIncrBgPopulate(IncrMerger *pIncr){
  function vdbeIncrSwap (line 83775) | static int vdbeIncrSwap(IncrMerger *pIncr){
  function vdbeIncrMergerNew (line 83814) | static int vdbeIncrMergerNew(
  function vdbeIncrMergerSetThreads (line 83838) | static void vdbeIncrMergerSetThreads(IncrMerger *pIncr){
  function vdbeMergeEngineCompare (line 83851) | static void vdbeMergeEngineCompare(
  function vdbeMergeEngineInit (line 83933) | static int vdbeMergeEngineInit(
  function vdbePmaReaderIncrMergeInit (line 84004) | static int vdbePmaReaderIncrMergeInit(PmaReader *pReadr, int eMode){
  function vdbePmaReaderIncrInit (line 84092) | static int vdbePmaReaderIncrInit(PmaReader *pReadr, int eMode){
  function vdbeMergeEngineLevel0 (line 84122) | static int vdbeMergeEngineLevel0(
  function vdbeSorterTreeDepth (line 84161) | static int vdbeSorterTreeDepth(int nPMA){
  function vdbeSorterAddToTree (line 84179) | static int vdbeSorterAddToTree(
  function vdbeSorterMergeTreeBuild (line 84235) | static int vdbeSorterMergeTreeBuild(
  function vdbeSorterSetupMerge (line 84314) | static int vdbeSorterSetupMerge(VdbeSorter *pSorter){
  function SQLITE_PRIVATE (line 84396) | SQLITE_PRIVATE int sqlite3VdbeSorterRewind(const VdbeCursor *pCsr, int *...
  function SQLITE_PRIVATE (line 84444) | SQLITE_PRIVATE int sqlite3VdbeSorterNext(sqlite3 *db, const VdbeCursor *...
  function SQLITE_PRIVATE (line 84508) | SQLITE_PRIVATE int sqlite3VdbeSorterRowkey(const VdbeCursor *pCsr, Mem *...
  function SQLITE_PRIVATE (line 84541) | SQLITE_PRIVATE int sqlite3VdbeSorterCompare(
  type MemJournal (line 84600) | typedef struct MemJournal MemJournal;
  type FilePoint (line 84601) | typedef struct FilePoint FilePoint;
  type FileChunk (line 84602) | typedef struct FileChunk FileChunk;
  type FileChunk (line 84610) | struct FileChunk {
  type FilePoint (line 84630) | struct FilePoint {
  type MemJournal (line 84639) | struct MemJournal {
  function memjrnlRead (line 84658) | static int memjrnlRead(
  function memjrnlFreeChunks (line 84707) | static void memjrnlFreeChunks(MemJournal *p){
  function memjrnlCreateFile (line 84720) | static int memjrnlCreateFile(MemJournal *p){
  function memjrnlWrite (line 84759) | static int memjrnlWrite(
  function memjrnlTruncate (line 84837) | static int memjrnlTruncate(sqlite3_file *pJfd, sqlite_int64 size){
  function memjrnlClose (line 84853) | static int memjrnlClose(sqlite3_file *pJfd){
  function memjrnlSync (line 84865) | static int memjrnlSync(sqlite3_file *pJfd, int flags){
  function memjrnlFileSize (line 84873) | static int memjrnlFileSize(sqlite3_file *pJfd, sqlite_int64 *pSize){
  type sqlite3_io_methods (line 84882) | struct sqlite3_io_methods
  function SQLITE_PRIVATE (line 84916) | SQLITE_PRIVATE int sqlite3JournalOpen(
  function SQLITE_PRIVATE (line 84952) | SQLITE_PRIVATE void sqlite3MemJournalOpen(sqlite3_file *pJfd){
  function SQLITE_PRIVATE (line 84963) | SQLITE_PRIVATE int sqlite3JournalCreate(sqlite3_file *p){
  function SQLITE_PRIVATE (line 84977) | SQLITE_PRIVATE int sqlite3JournalIsInMemory(sqlite3_file *p){
  function SQLITE_PRIVATE (line 84985) | SQLITE_PRIVATE int sqlite3JournalSize(sqlite3_vfs *pVfs){
  function SQLITE_NOINLINE (line 85029) | static SQLITE_NOINLINE int walkExpr(Walker *pWalker, Expr *pExpr){
  function SQLITE_PRIVATE (line 85046) | SQLITE_PRIVATE int sqlite3WalkExpr(Walker *pWalker, Expr *pExpr){
  function SQLITE_PRIVATE (line 85054) | SQLITE_PRIVATE int sqlite3WalkExprList(Walker *pWalker, ExprList *p){
  function SQLITE_PRIVATE (line 85071) | SQLITE_PRIVATE int sqlite3WalkSelectExpr(Walker *pWalker, Select *p){
  function SQLITE_PRIVATE (line 85089) | SQLITE_PRIVATE int sqlite3WalkSelectFrom(Walker *pWalker, Select *p){
  function SQLITE_PRIVATE (line 85126) | SQLITE_PRIVATE int sqlite3WalkSelect(Walker *pWalker, Select *p){
  function incrAggDepth (line 85184) | static int incrAggDepth(Walker *pWalker, Expr *pExpr){
  function incrAggFunctionDepth (line 85188) | static void incrAggFunctionDepth(Expr *pExpr, int N){
  function resolveAlias (line 85217) | static void resolveAlias(
  function nameInUsingClause (line 85266) | static int nameInUsingClause(IdList *pUsing, const char *zCol){
  function SQLITE_PRIVATE (line 85283) | SQLITE_PRIVATE int sqlite3MatchSpanName(
  function lookupName (line 85333) | static int lookupName(
  function SQLITE_PRIVATE (line 85656) | SQLITE_PRIVATE Expr *sqlite3CreateColumnExpr(sqlite3 *db, SrcList *pSrc,...
  function notValid (line 85679) | static void notValid(
  function exprProbability (line 85701) | static int exprProbability(Expr *p){
  function resolveExprStep (line 85721) | static int resolveExprStep(Walker *pWalker, Expr *pExpr){
  function resolveAsName (line 85944) | static int resolveAsName(
  function resolveOrderByTermToExprList (line 85983) | static int resolveOrderByTermToExprList(
  function resolveOutOfRangeError (line 86030) | static void resolveOutOfRangeError(
  function resolveCompoundOrderBy (line 86056) | static int resolveCompoundOrderBy(
  function SQLITE_PRIVATE (line 86154) | SQLITE_PRIVATE int sqlite3ResolveOrderGroupBy(
  function resolveOrderGroupBy (line 86205) | static int resolveOrderGroupBy(
  function resolveSelectStep (line 86263) | static int resolveSelectStep(Walker *pWalker, Select *p){
  function SQLITE_PRIVATE (line 86531) | SQLITE_PRIVATE int sqlite3ResolveExprNames(
  function SQLITE_PRIVATE (line 86576) | SQLITE_PRIVATE int sqlite3ResolveExprListNames(
  function SQLITE_PRIVATE (line 86601) | SQLITE_PRIVATE void sqlite3ResolveSelectNames(
  function SQLITE_PRIVATE (line 86628) | SQLITE_PRIVATE void sqlite3ResolveSelfReference(
  function SQLITE_PRIVATE (line 86686) | SQLITE_PRIVATE char sqlite3ExprAffinity(Expr *pExpr){
  function SQLITE_PRIVATE (line 86722) | SQLITE_PRIVATE Expr *sqlite3ExprAddCollateToken(
  function SQLITE_PRIVATE (line 86738) | SQLITE_PRIVATE Expr *sqlite3ExprAddCollateString(Parse *pParse, Expr *pE...
  function SQLITE_PRIVATE (line 86749) | SQLITE_PRIVATE Expr *sqlite3ExprSkipCollate(Expr *pExpr){
  function SQLITE_PRIVATE (line 86773) | SQLITE_PRIVATE CollSeq *sqlite3ExprCollSeq(Parse *pParse, Expr *pExpr){
  function SQLITE_PRIVATE (line 86837) | SQLITE_PRIVATE char sqlite3CompareAffinity(Expr *pExpr, char aff2){
  function comparisonAffinity (line 86864) | static char comparisonAffinity(Expr *pExpr){
  function SQLITE_PRIVATE (line 86887) | SQLITE_PRIVATE int sqlite3IndexAffinityOk(Expr *pExpr, char idx_affinity){
  function u8 (line 86903) | static u8 binaryCompareP5(Expr *pExpr1, Expr *pExpr2, int jumpIfNull){
  function SQLITE_PRIVATE (line 86921) | SQLITE_PRIVATE CollSeq *sqlite3BinaryCompareCollSeq(
  function codeCompare (line 86944) | static int codeCompare(
  function SQLITE_PRIVATE (line 86971) | SQLITE_PRIVATE int sqlite3ExprCheckHeight(Parse *pParse, int nHeight){
  function heightOfExpr (line 86992) | static void heightOfExpr(Expr *p, int *pnHeight){
  function heightOfExprList (line 86999) | static void heightOfExprList(ExprList *p, int *pnHeight){
  function heightOfSelect (line 87007) | static void heightOfSelect(Select *p, int *pnHeight){
  function exprSetHeight (line 87030) | static void exprSetHeight(Expr *p){
  function SQLITE_PRIVATE (line 87051) | SQLITE_PRIVATE void sqlite3ExprSetHeightAndFlags(Parse *pParse, Expr *p){
  function SQLITE_PRIVATE (line 87061) | SQLITE_PRIVATE int sqlite3SelectExprHeight(Select *p){
  function SQLITE_PRIVATE (line 87071) | SQLITE_PRIVATE void sqlite3ExprSetHeightAndFlags(Parse *pParse, Expr *p){
  function SQLITE_PRIVATE (line 87099) | SQLITE_PRIVATE Expr *sqlite3ExprAlloc(
  function SQLITE_PRIVATE (line 87150) | SQLITE_PRIVATE Expr *sqlite3Expr(
  function SQLITE_PRIVATE (line 87167) | SQLITE_PRIVATE void sqlite3ExprAttachSubtrees(
  function SQLITE_PRIVATE (line 87197) | SQLITE_PRIVATE Expr *sqlite3PExpr(
  function exprAlwaysTrue (line 87232) | static int exprAlwaysTrue(Expr *p){
  function exprAlwaysFalse (line 87238) | static int exprAlwaysFalse(Expr *p){
  function SQLITE_PRIVATE (line 87253) | SQLITE_PRIVATE Expr *sqlite3ExprAnd(sqlite3 *db, Expr *pLeft, Expr *pRig...
  function SQLITE_PRIVATE (line 87273) | SQLITE_PRIVATE Expr *sqlite3ExprFunction(Parse *pParse, ExprList *pList,...
  function SQLITE_PRIVATE (line 87304) | SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse *pParse, Expr *pExpr){
  function SQLITE_PRIVATE (line 87378) | SQLITE_PRIVATE void sqlite3ExprDelete(sqlite3 *db, Expr *p){
  function exprStructSize (line 87404) | static int exprStructSize(Expr *p){
  function dupedExprStructSize (line 87444) | static int dupedExprStructSize(Expr *p, int flags){
  function dupedExprNodeSize (line 87471) | static int dupedExprNodeSize(Expr *p, int flags){
  function dupedExprSize (line 87492) | static int dupedExprSize(Expr *p, int flags){
  function Expr (line 87511) | static Expr *exprDup(sqlite3 *db, Expr *p, int flags, u8 **pzBuffer){
  function With (line 87604) | static With *withDup(sqlite3 *db, With *p){
  function SQLITE_PRIVATE (line 87642) | SQLITE_PRIVATE Expr *sqlite3ExprDup(sqlite3 *db, Expr *p, int flags){
  function SQLITE_PRIVATE (line 87646) | SQLITE_PRIVATE ExprList *sqlite3ExprListDup(sqlite3 *db, ExprList *p, in...
  function SQLITE_PRIVATE (line 87683) | SQLITE_PRIVATE SrcList *sqlite3SrcListDup(sqlite3 *db, SrcList *p, int f...
  function SQLITE_PRIVATE (line 87724) | SQLITE_PRIVATE IdList *sqlite3IdListDup(sqlite3 *db, IdList *p){
  function SQLITE_PRIVATE (line 87748) | SQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3 *db, Select *p, int flags){
  function SQLITE_PRIVATE (line 87777) | SQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3 *db, Select *p, int flags){
  function SQLITE_PRIVATE (line 87792) | SQLITE_PRIVATE ExprList *sqlite3ExprListAppend(
  function SQLITE_PRIVATE (line 87834) | SQLITE_PRIVATE void sqlite3ExprListSetSortOrder(ExprList *p, int iSortOr...
  function SQLITE_PRIVATE (line 87853) | SQLITE_PRIVATE void sqlite3ExprListSetName(
  function SQLITE_PRIVATE (line 87878) | SQLITE_PRIVATE void sqlite3ExprListSetSpan(
  function SQLITE_PRIVATE (line 87899) | SQLITE_PRIVATE void sqlite3ExprListCheckLength(
  function SQLITE_PRIVATE (line 87915) | SQLITE_PRIVATE void sqlite3ExprListDelete(sqlite3 *db, ExprList *pList){
  function SQLITE_PRIVATE (line 87933) | SQLITE_PRIVATE u32 sqlite3ExprListFlags(const ExprList *pList){
  function exprNodeIsConstant (line 87971) | static int exprNodeIsConstant(Walker *pWalker, Expr *pExpr){
  function selectNodeIsConstant (line 88025) | static int selectNodeIsConstant(Walker *pWalker, Select *NotUsed){
  function exprIsConst (line 88030) | static int exprIsConst(Expr *p, int initFlag, int iCur){
  function SQLITE_PRIVATE (line 88049) | SQLITE_PRIVATE int sqlite3ExprIsConstant(Expr *p){
  function SQLITE_PRIVATE (line 88059) | SQLITE_PRIVATE int sqlite3ExprIsConstantNotJoin(Expr *p){
  function SQLITE_PRIVATE (line 88069) | SQLITE_PRIVATE int sqlite3ExprIsTableConstant(Expr *p, int iCur){
  function SQLITE_PRIVATE (line 88082) | SQLITE_PRIVATE int sqlite3ExprIsConstantOrFunction(Expr *p, u8 isInit){
  function SQLITE_PRIVATE (line 88092) | SQLITE_PRIVATE int sqlite3ExprContainsSubquery(Expr *p){
  function SQLITE_PRIVATE (line 88109) | SQLITE_PRIVATE int sqlite3ExprIsInteger(Expr *p, int *pValue){
  function SQLITE_PRIVATE (line 88154) | SQLITE_PRIVATE int sqlite3ExprCanBeNull(const Expr *p){
  function SQLITE_PRIVATE (line 88184) | SQLITE_PRIVATE int sqlite3ExprNeedsNoAffinityChange(const Expr *p, char ...
  function SQLITE_PRIVATE (line 88217) | SQLITE_PRIVATE int sqlite3IsRowid(const char *z){
  function Select (line 88232) | static Select *isCandidateForInOpt(Expr *pX){
  function SQLITE_PRIVATE (line 88272) | SQLITE_PRIVATE int sqlite3CodeOnce(Parse *pParse){
  function sqlite3SetHasNullFlag (line 88283) | static void sqlite3SetHasNullFlag(Vdbe *v, int iCur, int regHasNull){
  function sqlite3InRhsIsConstant (line 88299) | static int sqlite3InRhsIsConstant(Expr *pIn){
  function SQLITE_PRIVATE (line 88382) | SQLITE_PRIVATE int sqlite3FindInIndex(Parse *pParse, Expr *pX, u32 inFla...
  function SQLITE_PRIVATE (line 88532) | SQLITE_PRIVATE int sqlite3CodeSubselect(
  function sqlite3ExprCodeIN (line 88762) | static void sqlite3ExprCodeIN(
  function codeReal (line 88921) | static void codeReal(Vdbe *v, const char *z, int negateFlag, int iMem){
  function codeInteger (line 88939) | static void codeInteger(Parse *pParse, Expr *pExpr, int negFlag, int iMem){
  function cacheEntryClear (line 88975) | static void cacheEntryClear(Parse *pParse, struct yColCache *p){
  function SQLITE_PRIVATE (line 88989) | SQLITE_PRIVATE void sqlite3ExprCacheStore(Parse *pParse, int iTab, int i...
  function SQLITE_PRIVATE (line 89054) | SQLITE_PRIVATE void sqlite3ExprCacheRemove(Parse *pParse, int iReg, int ...
  function SQLITE_PRIVATE (line 89072) | SQLITE_PRIVATE void sqlite3ExprCachePush(Parse *pParse){
  function SQLITE_PRIVATE (line 89086) | SQLITE_PRIVATE void sqlite3ExprCachePop(Parse *pParse){
  function sqlite3ExprCachePinRegister (line 89110) | static void sqlite3ExprCachePinRegister(Parse *pParse, int iReg){
  function SQLITE_PRIVATE (line 89123) | SQLITE_PRIVATE void sqlite3ExprCodeLoadIndexColumn(
  function SQLITE_PRIVATE (line 89145) | SQLITE_PRIVATE void sqlite3ExprCodeGetColumnOfTable(
  function SQLITE_PRIVATE (line 89179) | SQLITE_PRIVATE int sqlite3ExprCodeGetColumn(
  function SQLITE_PRIVATE (line 89207) | SQLITE_PRIVATE void sqlite3ExprCodeGetColumnToReg(
  function SQLITE_PRIVATE (line 89222) | SQLITE_PRIVATE void sqlite3ExprCacheClear(Parse *pParse){
  function SQLITE_PRIVATE (line 89243) | SQLITE_PRIVATE void sqlite3ExprCacheAffinityChange(Parse *pParse, int iS...
  function SQLITE_PRIVATE (line 89251) | SQLITE_PRIVATE void sqlite3ExprCodeMove(Parse *pParse, int iFrom, int iT...
  function usedAsColumnCache (line 89265) | static int usedAsColumnCache(Parse *pParse, int iFrom, int iTo){
  function exprToRegister (line 89279) | static void exprToRegister(Expr *p, int iReg){
  function SQLITE_PRIVATE (line 89297) | SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int...
  function SQLITE_PRIVATE (line 89909) | SQLITE_PRIVATE void sqlite3ExprCodeAtInit(
  function SQLITE_PRIVATE (line 89941) | SQLITE_PRIVATE int sqlite3ExprCodeTemp(Parse *pParse, Expr *pExpr, int *...
  function SQLITE_PRIVATE (line 89979) | SQLITE_PRIVATE void sqlite3ExprCode(Parse *pParse, Expr *pExpr, int targ...
  function SQLITE_PRIVATE (line 89999) | SQLITE_PRIVATE void sqlite3ExprCodeCopy(Parse *pParse, Expr *pExpr, int ...
  function SQLITE_PRIVATE (line 90012) | SQLITE_PRIVATE void sqlite3ExprCodeFactorable(Parse *pParse, Expr *pExpr...
  function SQLITE_PRIVATE (line 90032) | SQLITE_PRIVATE void sqlite3ExprCodeAndCache(Parse *pParse, Expr *pExpr, ...
  function SQLITE_PRIVATE (line 90060) | SQLITE_PRIVATE int sqlite3ExprCodeExprList(
  function exprCodeBetween (line 90113) | static void exprCodeBetween(
  function SQLITE_PRIVATE (line 90170) | SQLITE_PRIVATE void sqlite3ExprIfTrue(Parse *pParse, Expr *pExpr, int de...
  function SQLITE_PRIVATE (line 90291) | SQLITE_PRIVATE void sqlite3ExprIfFalse(Parse *pParse, Expr *pExpr, int d...
  function SQLITE_PRIVATE (line 90439) | SQLITE_PRIVATE void sqlite3ExprIfFalseDup(Parse *pParse, Expr *pExpr, in...
  function SQLITE_PRIVATE (line 90471) | SQLITE_PRIVATE int sqlite3ExprCompare(Expr *pA, Expr *pB, int iTab){
  function SQLITE_PRIVATE (line 90529) | SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList *pA, ExprList *pB, in...
  function SQLITE_PRIVATE (line 90563) | SQLITE_PRIVATE int sqlite3ExprImpliesExpr(Expr *pE1, Expr *pE2, int iTab){
  type SrcCount (line 90588) | struct SrcCount {
  function exprSrcCount (line 90597) | static int exprSrcCount(Walker *pWalker, Expr *pExpr){
  function SQLITE_PRIVATE (line 90626) | SQLITE_PRIVATE int sqlite3FunctionUsesThisSrc(Expr *pExpr, SrcList *pSrc...
  function addAggInfoColumn (line 90644) | static int addAggInfoColumn(sqlite3 *db, AggInfo *pInfo){
  function addAggInfoFunc (line 90660) | static int addAggInfoFunc(sqlite3 *db, AggInfo *pInfo){
  function analyzeAggregate (line 90677) | static int analyzeAggregate(Walker *pWalker, Expr *pExpr){
  function analyzeAggregatesInSelect (line 90802) | static int analyzeAggregatesInSelect(Walker *pWalker, Select *pSelect){
  function SQLITE_PRIVATE (line 90817) | SQLITE_PRIVATE void sqlite3ExprAnalyzeAggregates(NameContext *pNC, Expr ...
  function SQLITE_PRIVATE (line 90833) | SQLITE_PRIVATE void sqlite3ExprAnalyzeAggList(NameContext *pNC, ExprList...
  function SQLITE_PRIVATE (line 90846) | SQLITE_PRIVATE int sqlite3GetTempReg(Parse *pParse){
  function SQLITE_PRIVATE (line 90861) | SQLITE_PRIVATE void sqlite3ReleaseTempReg(Parse *pParse, int iReg){
  function SQLITE_PRIVATE (line 90878) | SQLITE_PRIVATE int sqlite3GetTempRange(Parse *pParse, int nReg){
  function SQLITE_PRIVATE (line 90892) | SQLITE_PRIVATE void sqlite3ReleaseTempRange(Parse *pParse, int iReg, int...
  function SQLITE_PRIVATE (line 90903) | SQLITE_PRIVATE void sqlite3ClearTempRegCache(Parse *pParse){
  function SQLITE_PRIVATE (line 90914) | SQLITE_PRIVATE int sqlite3NoTempsInRange(Parse *pParse, int iFirst, int ...
  function renameTableFunc (line 90969) | static void renameTableFunc(
  function renameParentFunc (line 91034) | static void renameParentFunc(
  function renameTriggerFunc (line 91091) | static void renameTriggerFunc(
  function SQLITE_PRIVATE (line 91163) | SQLITE_PRIVATE void sqlite3AlterFunctions(void){
  function reloadTableSchema (line 91260) | static void reloadTableSchema(Parse *pParse, Table *pTab, const char *zN...
  function isSystemTable (line 91309) | static int isSystemTable(Parse *pParse, const char *zName){
  function SQLITE_PRIVATE (line 91321) | SQLITE_PRIVATE void sqlite3AlterRenameTable(
  function SQLITE_PRIVATE (line 91525) | SQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *pParse, Token *pC...
  function SQLITE_PRIVATE (line 91660) | SQLITE_PRIVATE void sqlite3AlterBeginAddColumn(Parse *pParse, SrcList *p...
  function openStatTable (line 91912) | static void openStatTable(
  type Stat4Accum (line 92005) | typedef struct Stat4Accum Stat4Accum;
  type Stat4Sample (line 92006) | typedef struct Stat4Sample Stat4Sample;
  type Stat4Sample (line 92007) | struct Stat4Sample {
  type Stat4Accum (line 92022) | struct Stat4Accum {
  function sampleClear (line 92041) | static void sampleClear(sqlite3 *db, Stat4Sample *p){
  function sampleSetRowid (line 92053) | static void sampleSetRowid(sqlite3 *db, Stat4Sample *p, int n, const u8 ...
  function sampleSetRowidInt64 (line 92069) | static void sampleSetRowidInt64(sqlite3 *db, Stat4Sample *p, i64 iRowid){
  function sampleCopy (line 92082) | static void sampleCopy(Stat4Accum *p, Stat4Sample *pTo, Stat4Sample *pFr...
  function stat4Destructor (line 92100) | static void stat4Destructor(void *pOld){
  type Stat4Sample (line 92194) | struct Stat4Sample
  function sampleIsBetterPost (line 92239) | static int sampleIsBetterPost(
  function sampleIsBetter (line 92263) | static int sampleIsBetter(
  function sampleInsert (line 92290) | static void sampleInsert(Stat4Accum *p, Stat4Sample *pNew, int nEqZero){
  function samplePushPrevious (line 92380) | static void samplePushPrevious(Stat4Accum *p, int iChng){
  function statPush (line 92446) | static void statPush(
  function statGet (line 92545) | static void statGet(
  function callStatGet (line 92671) | static void callStatGet(Vdbe *v, int regStat4, int iParam, int regOut){
  function analyzeOneTable (line 92689) | static void analyzeOneTable(
  function loadAnalysis (line 93015) | static void loadAnalysis(Parse *pParse, int iDb){
  function analyzeDatabase (line 93025) | static void analyzeDatabase(Parse *pParse, int iDb){
  function analyzeTable (line 93052) | static void analyzeTable(Parse *pParse, Table *pTab, Index *pOnlyIdx){
  function SQLITE_PRIVATE (line 93083) | SQLITE_PRIVATE void sqlite3Analyze(Parse *pParse, Token *pName1, Token *...
  type analysisInfo (line 93147) | typedef struct analysisInfo analysisInfo;
  type analysisInfo (line 93148) | struct analysisInfo {
  function analysisLoader (line 93229) | static int analysisLoader(void *pData, int argc, char **argv, char **Not...
  function SQLITE_PRIVATE (line 93287) | SQLITE_PRIVATE void sqlite3DeleteIndexSamples(sqlite3 *db, Index *pIdx){
  function initAvgEq (line 93312) | static void initAvgEq(Index *pIdx){
  function Index (line 93371) | static Index *findIndexOrPrimaryKey(
  function loadStatTbl (line 93397) | static int loadStatTbl(
  function loadStat4 (line 93521) | static int loadStat4(sqlite3 *db, const char *zDb){
  function SQLITE_PRIVATE (line 93565) | SQLITE_PRIVATE int sqlite3AnalysisLoad(sqlite3 *db, int iDb){
  function resolveAttachExpr (line 93662) | static int resolveAttachExpr(NameContext *pName, Expr *pExpr)
  function attachFunc (line 93686) | static void attachFunc(
  function detachFunc (line 93888) | static void detachFunc(
  function codeAttach (line 93940) | static void codeAttach(
  function SQLITE_PRIVATE (line 94013) | SQLITE_PRIVATE void sqlite3Detach(Parse *pParse, Expr *pDbname){
  function SQLITE_PRIVATE (line 94032) | SQLITE_PRIVATE void sqlite3Attach(Parse *pParse, Expr *p, Expr *pDbname,...
  function SQLITE_PRIVATE (line 94051) | SQLITE_PRIVATE void sqlite3FixInit(
  function SQLITE_PRIVATE (line 94084) | SQLITE_PRIVATE int sqlite3FixSrcList(
  function SQLITE_PRIVATE (line 94114) | SQLITE_PRIVATE int sqlite3FixSelect(
  function SQLITE_PRIVATE (line 94147) | SQLITE_PRIVATE int sqlite3FixExpr(
  function SQLITE_PRIVATE (line 94173) | SQLITE_PRIVATE int sqlite3FixExprList(
  function SQLITE_PRIVATE (line 94190) | SQLITE_PRIVATE int sqlite3FixTriggerStep(
  function SQLITE_STDCALL (line 94281) | SQLITE_STDCALL sqlite3_set_authorizer(
  function sqliteAuthBadReturnCode (line 94301) | static void sqliteAuthBadReturnCode(Parse *pParse){
  function SQLITE_PRIVATE (line 94315) | SQLITE_PRIVATE int sqlite3AuthReadCol(
  function SQLITE_PRIVATE (line 94352) | SQLITE_PRIVATE void sqlite3AuthRead(
  function SQLITE_PRIVATE (line 94409) | SQLITE_PRIVATE int sqlite3AuthCheck(
  function SQLITE_PRIVATE (line 94449) | SQLITE_PRIVATE void sqlite3AuthContextPush(
  function SQLITE_PRIVATE (line 94464) | SQLITE_PRIVATE void sqlite3AuthContextPop(AuthContext *pContext){
  type TableLock (line 94506) | struct TableLock {
  function SQLITE_PRIVATE (line 94523) | SQLITE_PRIVATE void sqlite3TableLock(
  function codeTableLocks (line 94563) | static void codeTableLocks(Parse *pParse){
  function SQLITE_PRIVATE (line 94587) | SQLITE_PRIVATE int sqlite3DbMaskAllZero(yDbMask m){
  function SQLITE_PRIVATE (line 94604) | SQLITE_PRIVATE void sqlite3FinishCoding(Parse *pParse){
  function SQLITE_PRIVATE (line 94732) | SQLITE_PRIVATE void sqlite3NestedParse(Parse *pParse, const char *zForma...
  function SQLITE_PRIVATE (line 94763) | SQLITE_PRIVATE int sqlite3UserAuthTable(const char *zTable){
  function SQLITE_PRIVATE (line 94780) | SQLITE_PRIVATE Table *sqlite3FindTable(sqlite3 *db, const char *zName, c...
  function SQLITE_PRIVATE (line 94813) | SQLITE_PRIVATE Table *sqlite3LocateTable(
  function SQLITE_PRIVATE (line 94861) | SQLITE_PRIVATE Table *sqlite3LocateTableItem(
  function SQLITE_PRIVATE (line 94889) | SQLITE_PRIVATE Index *sqlite3FindIndex(sqlite3 *db, const char *zName, c...
  function freeIndex (line 94909) | static void freeIndex(sqlite3 *db, Index *p){
  function SQLITE_PRIVATE (line 94929) | SQLITE_PRIVATE void sqlite3UnlinkAndDeleteIndex(sqlite3 *db, int iDb, co...
  function SQLITE_PRIVATE (line 94962) | SQLITE_PRIVATE void sqlite3CollapseDatabaseArray(sqlite3 *db){
  function SQLITE_PRIVATE (line 94988) | SQLITE_PRIVATE void sqlite3ResetOneSchema(sqlite3 *db, int iDb){
  function SQLITE_PRIVATE (line 95014) | SQLITE_PRIVATE void sqlite3ResetAllSchemasOfConnection(sqlite3 *db){
  function SQLITE_PRIVATE (line 95032) | SQLITE_PRIVATE void sqlite3CommitInternalChanges(sqlite3 *db){
  function SQLITE_PRIVATE (line 95040) | SQLITE_PRIVATE void sqlite3DeleteColumnNames(sqlite3 *db, Table *pTable){
  function SQLITE_PRIVATE (line 95069) | SQLITE_PRIVATE void sqlite3DeleteTable(sqlite3 *db, Table *pTable){
  function SQLITE_PRIVATE (line 95123) | SQLITE_PRIVATE void sqlite3UnlinkAndDeleteTable(sqlite3 *db, int iDb, co...
  function SQLITE_PRIVATE (line 95151) | SQLITE_PRIVATE char *sqlite3NameFromToken(sqlite3 *db, Token *pName){
  function SQLITE_PRIVATE (line 95166) | SQLITE_PRIVATE void sqlite3OpenMasterTable(Parse *p, int iDb){
  function SQLITE_PRIVATE (line 95181) | SQLITE_PRIVATE int sqlite3FindDbName(sqlite3 *db, const char *zName){
  function SQLITE_PRIVATE (line 95198) | SQLITE_PRIVATE int sqlite3FindDb(sqlite3 *db, Token *pName){
  function SQLITE_PRIVATE (line 95223) | SQLITE_PRIVATE int sqlite3TwoPartName(
  function SQLITE_PRIVATE (line 95259) | SQLITE_PRIVATE int sqlite3CheckObjectName(Parse *pParse, const char *zNa...
  function SQLITE_PRIVATE (line 95272) | SQLITE_PRIVATE Index *sqlite3PrimaryKeyIndex(Table *pTab){
  function SQLITE_PRIVATE (line 95282) | SQLITE_PRIVATE i16 sqlite3ColumnOfIndex(Index *pIdx, i16 iCol){
  function SQLITE_PRIVATE (line 95306) | SQLITE_PRIVATE void sqlite3StartTable(
  function SQLITE_PRIVATE (line 95496) | SQLITE_PRIVATE void sqlite3ColumnPropertiesFromName(Table *pTab, Column ...
  function SQLITE_PRIVATE (line 95514) | SQLITE_PRIVATE void sqlite3AddColumn(Parse *pParse, Token *pName, Token ...
  function SQLITE_PRIVATE (line 95576) | SQLITE_PRIVATE void sqlite3AddNotNull(Parse *pParse, int onError){
  function SQLITE_PRIVATE (line 95608) | SQLITE_PRIVATE char sqlite3AffinityType(const char *zIn, u8 *pszEst){
  function SQLITE_PRIVATE (line 95680) | SQLITE_PRIVATE void sqlite3AddDefaultValue(Parse *pParse, ExprSpan *pSpan){
  function sqlite3StringToId (line 95726) | static void sqlite3StringToId(Expr *p){
  function SQLITE_PRIVATE (line 95752) | SQLITE_PRIVATE void sqlite3AddPrimaryKey(
  function SQLITE_PRIVATE (line 95826) | SQLITE_PRIVATE void sqlite3AddCheckConstraint(
  function SQLITE_PRIVATE (line 95851) | SQLITE_PRIVATE void sqlite3AddCollateType(Parse *pParse, Token *pToken){
  function SQLITE_PRIVATE (line 95903) | SQLITE_PRIVATE CollSeq *sqlite3LocateCollSeq(Parse *pParse, const char *...
  function SQLITE_PRIVATE (line 95934) | SQLITE_PRIVATE void sqlite3ChangeCookie(Parse *pParse, int iDb){
  function identLength (line 95950) | static int identLength(const char *z){
  function identPut (line 95971) | static void identPut(char *z, int *pIdx, char *zSignedIdent){
  function resizeIndexObject (line 96067) | static int resizeIndexObject(sqlite3 *db, Index *pIdx, int N){
  function estimateTableWidth (line 96091) | static void estimateTableWidth(Table *pTab){
  function estimateIndexWidth (line 96105) | static void estimateIndexWidth(Index *pIdx){
  function hasColumn (line 96119) | static int hasColumn(const i16 *aiCol, int nCol, int x){
  function convertToWithoutRowidTable (line 96147) | static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){
  function SQLITE_PRIVATE (line 96287) | SQLITE_PRIVATE void sqlite3EndTable(
  function SQLITE_PRIVATE (line 96529) | SQLITE_PRIVATE void sqlite3CreateView(
  function SQLITE_PRIVATE (line 96601) | SQLITE_PRIVATE int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){
  function sqliteViewResetAll (line 96702) | static void sqliteViewResetAll(sqlite3 *db, int idx){
  function SQLITE_PRIVATE (line 96738) | SQLITE_PRIVATE void sqlite3RootPageMoved(sqlite3 *db, int iDb, int iFrom...
  function destroyRootPage (line 96768) | static void destroyRootPage(Parse *pParse, int iTable, int iDb){
  function destroyTable (line 96797) | static void destroyTable(Parse *pParse, Table *pTab){
  function sqlite3ClearStatTables (line 96855) | static void sqlite3ClearStatTables(
  function SQLITE_PRIVATE (line 96878) | SQLITE_PRIVATE void sqlite3CodeDropTable(Parse *pParse, Table *pTab, int...
  function SQLITE_PRIVATE (line 96949) | SQLITE_PRIVATE void sqlite3DropTable(Parse *pParse, SrcList *pName, int ...
  function SQLITE_PRIVATE (line 97064) | SQLITE_PRIVATE void sqlite3CreateForeignKey(
  function SQLITE_PRIVATE (line 97185) | SQLITE_PRIVATE void sqlite3DeferForeignKey(Parse *pParse, int isDeferred){
  function sqlite3RefillIndex (line 97206) | static void sqlite3RefillIndex(Parse *pParse, Index *pIndex, int memRoot...
  function SQLITE_PRIVATE (line 97293) | SQLITE_PRIVATE Index *sqlite3AllocateIndexObject(
  function SQLITE_PRIVATE (line 97337) | SQLITE_PRIVATE Index *sqlite3CreateIndex(
  function SQLITE_PRIVATE (line 97886) | SQLITE_PRIVATE void sqlite3DefaultRowEst(Index *pIdx){
  function SQLITE_PRIVATE (line 97914) | SQLITE_PRIVATE void sqlite3DropIndex(Parse *pParse, SrcList *pName, int ...
  function SQLITE_PRIVATE (line 97995) | SQLITE_PRIVATE void *sqlite3ArrayAllocate(
  function SQLITE_PRIVATE (line 98026) | SQLITE_PRIVATE IdList *sqlite3IdListAppend(sqlite3 *db, IdList *pList, T...
  function SQLITE_PRIVATE (line 98050) | SQLITE_PRIVATE void sqlite3IdListDelete(sqlite3 *db, IdList *pList){
  function SQLITE_PRIVATE (line 98064) | SQLITE_PRIVATE int sqlite3IdListIndex(IdList *pList, const char *zName){
  function SQLITE_PRIVATE (line 98092) | SQLITE_PRIVATE SrcList *sqlite3SrcListEnlarge(
  function SQLITE_PRIVATE (line 98174) | SQLITE_PRIVATE SrcList *sqlite3SrcListAppend(
  function SQLITE_PRIVATE (line 98211) | SQLITE_PRIVATE void sqlite3SrcListAssignCursors(Parse *pParse, SrcList *...
  function SQLITE_PRIVATE (line 98229) | SQLITE_PRIVATE void sqlite3SrcListDelete(sqlite3 *db, SrcList *pList){
  function SQLITE_PRIVATE (line 98263) | SQLITE_PRIVATE SrcList *sqlite3SrcListAppendFromTerm(
  function SQLITE_PRIVATE (line 98307) | SQLITE_PRIVATE void sqlite3SrcListIndexedBy(Parse *pParse, SrcList *p, T...
  function SQLITE_PRIVATE (line 98329) | SQLITE_PRIVATE void sqlite3SrcListFuncArgs(Parse *pParse, SrcList *p, Ex...
  function SQLITE_PRIVATE (line 98357) | SQLITE_PRIVATE void sqlite3SrcListShiftJoinType(SrcList *p){
  function SQLITE_PRIVATE (line 98370) | SQLITE_PRIVATE void sqlite3BeginTransaction(Parse *pParse, int type){
  function SQLITE_PRIVATE (line 98395) | SQLITE_PRIVATE void sqlite3CommitTransaction(Parse *pParse){
  function SQLITE_PRIVATE (line 98412) | SQLITE_PRIVATE void sqlite3RollbackTransaction(Parse *pParse){
  function SQLITE_PRIVATE (line 98430) | SQLITE_PRIVATE void sqlite3Savepoint(Parse *pParse, int op, Token *pName){
  function SQLITE_PRIVATE (line 98450) | SQLITE_PRIVATE int sqlite3OpenTempDatabase(Parse *pParse){
  function SQLITE_PRIVATE (line 98485) | SQLITE_PRIVATE void sqlite3CodeVerifySchema(Parse *pParse, int iDb){
  function SQLITE_PRIVATE (line 98506) | SQLITE_PRIVATE void sqlite3CodeVerifyNamedSchema(Parse *pParse, const ch...
  function SQLITE_PRIVATE (line 98530) | SQLITE_PRIVATE void sqlite3BeginWriteOperation(Parse *pParse, int setSta...
  function SQLITE_PRIVATE (line 98544) | SQLITE_PRIVATE void sqlite3MultiWrite(Parse *pParse){
  function SQLITE_PRIVATE (line 98565) | SQLITE_PRIVATE void sqlite3MayAbort(Parse *pParse){
  function SQLITE_PRIVATE (line 98575) | SQLITE_PRIVATE void sqlite3HaltConstraint(
  function SQLITE_PRIVATE (line 98595) | SQLITE_PRIVATE void sqlite3UniqueConstraint(
  function SQLITE_PRIVATE (line 98628) | SQLITE_PRIVATE void sqlite3RowidConstraint(
  function collationMatch (line 98652) | static int collationMatch(const char *zColl, Index *pIndex){
  function reindexTable (line 98671) | static void reindexTable(Parse *pParse, Table *pTab, char const *zColl){
  function reindexDatabases (line 98690) | static void reindexDatabases(Parse *pParse, char const *zColl){
  function SQLITE_PRIVATE (line 98722) | SQLITE_PRIVATE void sqlite3Reindex(Parse *pParse, Token *pName1, Token *...
  function SQLITE_PRIVATE (line 98786) | SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoOfIndex(Parse *pParse, Index *pIdx){
  function SQLITE_PRIVATE (line 98818) | SQLITE_PRIVATE With *sqlite3WithAdd(
  function SQLITE_PRIVATE (line 98868) | SQLITE_PRIVATE void sqlite3WithDelete(sqlite3 *db, With *pWith){
  function callCollNeeded (line 98906) | static void callCollNeeded(sqlite3 *db, int enc, const char *zName){
  function synthCollSeq (line 98935) | static int synthCollSeq(sqlite3 *db, CollSeq *pColl){
  function SQLITE_PRIVATE (line 98965) | SQLITE_PRIVATE CollSeq *sqlite3GetCollSeq(
  function SQLITE_PRIVATE (line 99006) | SQLITE_PRIVATE int sqlite3CheckCollSeq(Parse *pParse, CollSeq *pColl){
  function CollSeq (line 99034) | static CollSeq *findCollSeqEntry(
  function SQLITE_PRIVATE (line 99087) | SQLITE_PRIVATE CollSeq *sqlite3FindCollSeq(
  function matchQuality (line 99134) | static int matchQuality(
  function FuncDef (line 99169) | static FuncDef *functionSearch(
  function SQLITE_PRIVATE (line 99185) | SQLITE_PRIVATE void sqlite3InsertBuiltinFuncs(
  function SQLITE_PRIVATE (line 99229) | SQLITE_PRIVATE FuncDef *sqlite3FindFunction(
  function SQLITE_PRIVATE (line 99319) | SQLITE_PRIVATE void sqlite3SchemaClear(void *p){
  function SQLITE_PRIVATE (line 99351) | SQLITE_PRIVATE Schema *sqlite3SchemaGet(sqlite3 *db, Btree *pBt){
  function SQLITE_PRIVATE (line 99402) | SQLITE_PRIVATE Table *sqlite3SrcListLookup(Parse *pParse, SrcList *pSrc){
  function SQLITE_PRIVATE (line 99423) | SQLITE_PRIVATE int sqlite3IsReadOnly(Parse *pParse, Table *pTab, int vie...
  function SQLITE_PRIVATE (line 99460) | SQLITE_PRIVATE void sqlite3MaterializeView(
  function SQLITE_PRIVATE (line 99497) | SQLITE_PRIVATE Expr *sqlite3LimitWhere(
  function SQLITE_PRIVATE (line 99589) | SQLITE_PRIVATE void sqlite3DeleteFrom(
  function SQLITE_PRIVATE (line 100003) | SQLITE_PRIVATE void sqlite3GenerateRowDelete(
  function SQLITE_PRIVATE (line 100142) | SQLITE_PRIVATE void sqlite3GenerateRowIndexDelete(
  function SQLITE_PRIVATE (line 100206) | SQLITE_PRIVATE int sqlite3GenerateIndexKey(
  function SQLITE_PRIVATE (line 100264) | SQLITE_PRIVATE void sqlite3ResolvePartIdxLabel(Parse *pParse, int iLabel){
  function CollSeq (line 100296) | static CollSeq *sqlite3GetFuncCollSeq(sqlite3_context *context){
  function sqlite3SkipAccumulatorLoad (line 100309) | static void sqlite3SkipAccumulatorLoad(sqlite3_context *context){
  function minmaxFunc (line 100316) | static void minmaxFunc(
  function typeofFunc (line 100346) | static void typeofFunc(
  function lengthFunc (line 100367) | static void lengthFunc(
  function absFunc (line 100407) | static void absFunc(sqlite3_context *context, int argc, sqlite3_value **...
  function instrFunc (line 100456) | static void instrFunc(
  function printfFunc (line 100498) | static void printfFunc(
  function substrFunc (line 100534) | static void substrFunc(
  function roundFunc (line 100629) | static void roundFunc(sqlite3_context *context, int argc, sqlite3_value ...
  function upperFunc (line 100691) | static void upperFunc(sqlite3_context *context, int argc, sqlite3_value ...
  function lowerFunc (line 100710) | static void lowerFunc(sqlite3_context *context, int argc, sqlite3_value ...
  function randomFunc (line 100743) | static void randomFunc(
  function randomBlob (line 100769) | static void randomBlob(
  function last_insert_rowid (line 100793) | static void last_insert_rowid(
  function changes (line 100813) | static void changes(
  function total_changes (line 100827) | static void total_changes(
  type compareInfo (line 100842) | struct compareInfo {
  type compareInfo (line 100862) | struct compareInfo
  type compareInfo (line 100865) | struct compareInfo
  type compareInfo (line 100868) | struct compareInfo
  function patternCompare (line 100905) | static int patternCompare(
  function SQLITE_STDCALL (line 101027) | SQLITE_STDCALL sqlite3_strglob(const char *zGlobPattern, const char *zSt...
  function SQLITE_STDCALL (line 101034) | SQLITE_STDCALL sqlite3_strlike(const char *zPattern, const char *zStr, u...
  function likeFunc (line 101060) | static void likeFunc(
  function nullifFunc (line 101125) | static void nullifFunc(
  function versionFunc (line 101141) | static void versionFunc(
  function sourceidFunc (line 101157) | static void sourceidFunc(
  function errlogFunc (line 101173) | static void errlogFunc(
  function compileoptionusedFunc (line 101189) | static void compileoptionusedFunc(
  function compileoptiongetFunc (line 101213) | static void compileoptiongetFunc(
  function quoteFunc (line 101243) | static void quoteFunc(sqlite3_context *context, int argc, sqlite3_value ...
  function unicodeFunc (line 101319) | static void unicodeFunc(
  function charFunc (line 101334) | static void charFunc(
  function hexFunc (line 101375) | static void hexFunc(
  function zeroblobFunc (line 101403) | static void zeroblobFunc(
  function replaceFunc (line 101426) | static void replaceFunc(
  function trimFunc (line 101510) | static void trimFunc(
  function soundexFunc (line 101602) | static void soundexFunc(
  function loadExt (line 101655) | static void loadExt(sqlite3_context *context, int argc, sqlite3_value **...
  type SumCtx (line 101678) | typedef struct SumCtx SumCtx;
  type SumCtx (line 101679) | struct SumCtx {
  function sumStep (line 101697) | static void sumStep(sqlite3_context *context, int argc, sqlite3_value **...
  function sumFinalize (line 101718) | static void sumFinalize(sqlite3_context *context){
  function avgFinalize (line 101731) | static void avgFinalize(sqlite3_context *context){
  function totalFinalize (line 101738) | static void totalFinalize(sqlite3_context *context){
  type CountCtx (line 101749) | typedef struct CountCtx CountCtx;
  type CountCtx (line 101750) | struct CountCtx {
  function countStep (line 101757) | static void countStep(sqlite3_context *context, int argc, sqlite3_value ...
  function countFinalize (line 101773) | static void countFinalize(sqlite3_context *context){
  function minmaxStep (line 101782) | static void minmaxStep(
  function minMaxFinalize (line 101820) | static void minMaxFinalize(
Condensed preview — 83 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (7,804K chars).
[
  {
    "path": ".gitignore",
    "chars": 26,
    "preview": "/build/\n/lib/\n\n*.o\n\n.git/\n"
  },
  {
    "path": "CMakeLists.txt",
    "chars": 835,
    "preview": "cmake_minimum_required(VERSION 2.8)\n\nproject(FinalMonocularSfM)\n\n\n\n# 用IF控制,可以实现Release版本不输出debug信息\n#不知道为什么DEBUG必须写成-DDEB"
  },
  {
    "path": "README.md",
    "chars": 2821,
    "preview": "# MonocularSfM : Monocular Structure from Motion\n\n## Introuction\n\nMonocularSfm是一个三维重建的程序, 可以对有序或者无序的图片进行三维重建.\n\n程序的输入是**图"
  },
  {
    "path": "UnitTest/CMakeLists.txt",
    "chars": 813,
    "preview": "set(MonocularSfM_Feature_LIBS\n\n    feature\n    common\n    database\n    sqlite3\n    -lpthread\n    dl\n    ${OpenCV_LIBS}\n)"
  },
  {
    "path": "UnitTest/InitializerTest.cpp",
    "chars": 3064,
    "preview": "#include \"Database/Database.h\"\n#include \"Reconstruction/Initializer.h\"\n#include \"Reconstruction/Utils.h\"\n#include \"Visua"
  },
  {
    "path": "UnitTest/MapBuilderTest.cpp",
    "chars": 2215,
    "preview": "#include \"Reconstruction/MapBuilder.h\"\n#include <string>\nusing namespace std;\nusing namespace MonocularSfM;\n\nint main()\n"
  },
  {
    "path": "UnitTest/RegisterGraphTest.cpp",
    "chars": 747,
    "preview": "#include \"Reconstruction/RegisterGraph.h\"\n\n#include <iostream>\n#include <cassert>\nusing namespace MonocularSfM;\nint main"
  },
  {
    "path": "UnitTest/TimerTest.cpp",
    "chars": 372,
    "preview": "#include \"Common/Timer.h\"\n#include <unistd.h>\n#include <cassert>\nusing namespace MonocularSfM;\nint main()\n{\n    Timer ti"
  },
  {
    "path": "config/NEU.yaml",
    "chars": 1497,
    "preview": "%YAML:1.0\n\nimages_path : \"/home/anton/Documents/3D/img_all_after/img_all\"\ndatabase_path : \"/home/anton/Documents/3D/img_"
  },
  {
    "path": "config/gerrard-hall.yaml",
    "chars": 1568,
    "preview": "%YAML:1.0\n\nimages_path : \"/home/anton/Documents/workspace/resources/clomap/gerrard-hall/images\"\ndatabase_path : \"/home/a"
  },
  {
    "path": "config/person-hall.yaml",
    "chars": 1569,
    "preview": "%YAML:1.0\n\nimages_path : \"/home/anton/Documents/workspace/resources/clomap/person-hall2/images\"\ndatabase_path : \"/home/a"
  },
  {
    "path": "config/south-building.yaml",
    "chars": 1557,
    "preview": "%YAML:1.0\n\nimages_path : \"/home/anton/Documents/workspace/resources/clomap/south-building/images\"\ndatabase_path : \"/home"
  },
  {
    "path": "ext/CMakeLists.txt",
    "chars": 26,
    "preview": "add_subdirectory(SQLite)\n\n"
  },
  {
    "path": "ext/SQLite/CMakeLists.txt",
    "chars": 119,
    "preview": "add_definitions(-DSQLITE_THREADSAFE=1)\n\n\nadd_library(sqlite3\n    STATIC\n    sqlite3.h\n    sqlite3ext.h\n    sqlite3.c\n)\n"
  },
  {
    "path": "ext/SQLite/shell.c",
    "chars": 159755,
    "preview": "/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here i"
  },
  {
    "path": "ext/SQLite/sqlite3.c",
    "chars": 6638481,
    "preview": "/******************************************************************************\n** This file is an amalgamation of many "
  },
  {
    "path": "ext/SQLite/sqlite3.h",
    "chars": 419210,
    "preview": "/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here i"
  },
  {
    "path": "ext/SQLite/sqlite3ext.h",
    "chars": 29370,
    "preview": "/*\n** 2006 June 7\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a bl"
  },
  {
    "path": "include/Common/Timer.h",
    "chars": 721,
    "preview": "#ifndef __TIMER_H__\n#define __TIMER_H__\n\n#include <chrono>\n\nnamespace MonocularSfM\n{\n\nclass Timer\n{\npublic:\n    Timer();"
  },
  {
    "path": "include/Common/Types.h",
    "chars": 315,
    "preview": "#ifndef __TYPES_H__\n#define __TYPES_H__\n\n\n\nnamespace MonocularSfM\n{\n\n#define INVALID  -1\n\ntypedef int image_t;\ntypedef i"
  },
  {
    "path": "include/Database/Database.h",
    "chars": 4496,
    "preview": "#ifndef __DATABASE_H__\n#define __DATABASE_H__\n\n#include <string>\n#include <vector>\n#include <opencv2/opencv.hpp>\n#includ"
  },
  {
    "path": "include/Exportor/Exportor.h",
    "chars": 388,
    "preview": "#ifndef __EXPORTOR_H__\n#define __EXPORTOR_H__\n\n#include <string>\n#include \"Reconstruction/Map.h\"\n\nnamespace MonocularSfM"
  },
  {
    "path": "include/Exportor/OpenMVSExportor.h",
    "chars": 285,
    "preview": "#ifndef __OPENMVS_EXPORTOR_H__\n#define __OPENMVS_EXPORTOR_H__\n\n#include <string>\n\n\nnamespace MonocularSfM\n{\nclass OpenMV"
  },
  {
    "path": "include/Exportor/OpenMVSInterface.h",
    "chars": 15696,
    "preview": "#ifndef _INTERFACE_MVS_H_\n#define _INTERFACE_MVS_H_\n\n\n// I N C L U D E S ///////////////////////////////////////////////"
  },
  {
    "path": "include/Exportor/PLYExportor.h",
    "chars": 273,
    "preview": "#ifndef __PLY_EXPORTOR_H__\n#define __PLY_EXPORTOR_H__\n\n#include <string>\n\nnamespace MonocularSfM\n{\nclass PLYExportor\n{\np"
  },
  {
    "path": "include/Feature/FeatureExtraction.h",
    "chars": 1746,
    "preview": "#ifndef __FEATURE_EXTRACTION_H__\n#define __FEATURE_EXTRACTION_H__\n\n#include <string>\n\n\nnamespace MonocularSfM\n{\nclass Fe"
  },
  {
    "path": "include/Feature/FeatureMatching.h",
    "chars": 4956,
    "preview": "#ifndef __FEATURE_MATCHING_H__\n#define __FEATURE_MATCHING_H__\n\n#include <string>\n#include <unordered_map>\n\n#include <ope"
  },
  {
    "path": "include/Feature/FeatureUtils.h",
    "chars": 7114,
    "preview": "#ifndef __FEATURE_UTILS_H__\n#define __FEATURE_UTILS_H__\n#include <vector>\n#include <string>\n\n#include <opencv2/opencv.hp"
  },
  {
    "path": "include/Optimizer/BundleData.h",
    "chars": 1226,
    "preview": "#ifndef __BUNDLE_DATA_H__\n#define __BUNDLE_DATA_H__\n\n#include <unordered_map>\n#include <unordered_set>\n\n#include <opencv"
  },
  {
    "path": "include/Optimizer/CeresBundleOptimizer.h",
    "chars": 628,
    "preview": "#ifndef __CERES_BUNDLE_OPTIMIZER_H__\n#define __CERES_BUNDLE_OPTIMIZER_H__\n\n\n#include \"Optimizer/BundleData.h\"\n\n\nvoid ini"
  },
  {
    "path": "include/Reconstruction/Image.h",
    "chars": 1863,
    "preview": "#ifndef __IMAGE_H__\n#define __IMAGE_H__\n#include <string>\n#include <vector>\n#include <opencv2/opencv.hpp>\n\n#include \"Com"
  },
  {
    "path": "include/Reconstruction/Initializer.h",
    "chars": 5632,
    "preview": "#ifndef __INITIALIZER_H__\n#define __INITIALIZER_H__\n\n\n#include <cstddef>\n#include <vector>\n#include <opencv2/opencv.hpp>"
  },
  {
    "path": "include/Reconstruction/Map.h",
    "chars": 7092,
    "preview": "#ifndef __MAP_H__\n#define __MAP_H__\n\n#include <unordered_map>\n#include <unordered_set>\n#include <vector>\n#include <strin"
  },
  {
    "path": "include/Reconstruction/MapBuilder.h",
    "chars": 5779,
    "preview": "#ifndef __MAP_BUILDER_H__\n#define __MAP_BUILDER_H__\n\n#include <string>\n\n\n#include \"Common/Types.h\"\n#include \"Common/Time"
  },
  {
    "path": "include/Reconstruction/Point2D.h",
    "chars": 758,
    "preview": "#ifndef __POINT2D_H__\n#define __POINT2D_H__\n#include <opencv2/opencv.hpp>\n#include \"Common/Types.h\"\nnamespace MonocularS"
  },
  {
    "path": "include/Reconstruction/Point3D.h",
    "chars": 1606,
    "preview": "#ifndef __POINT3D_H__\n#define __POINT3D_H__\n\n#include <opencv2/opencv.hpp>\n#include \"Reconstruction/Track.h\"\n\nnamespace "
  },
  {
    "path": "include/Reconstruction/Projection.h",
    "chars": 2771,
    "preview": "#ifndef __PROJECTION_H__\n#define __PROJECTION_H__\n\n#include <opencv2/opencv.hpp>\n\nnamespace MonocularSfM\n{\n\n\nclass Proje"
  },
  {
    "path": "include/Reconstruction/RegisterGraph.h",
    "chars": 1071,
    "preview": "#ifndef __REGISTER_GRAPH_H__\n#define __REGISTER_GRAPH_H__\n\n#include <vector>\n#include <cassert>\n#include <cstddef>\n#incl"
  },
  {
    "path": "include/Reconstruction/Registrant.h",
    "chars": 1438,
    "preview": "#ifndef __REGISTRANT_H__\n#define __REGISTRANT_H__\n\n#include <cstddef>\n#include <vector>\n#include <opencv2/opencv.hpp>\nna"
  },
  {
    "path": "include/Reconstruction/SceneGraph.h",
    "chars": 4529,
    "preview": "#ifndef __SCENE_GRAPH_H__\n#define __SCENE_GRAPH_H__\n\n\n#include \"Common/Types.h\"\n#include \"Database/Database.h\"\n\n\nnamespa"
  },
  {
    "path": "include/Reconstruction/Track.h",
    "chars": 2061,
    "preview": "#ifndef __TRACK_H__\n#define __TRACK_H__\n\n#include <cstddef>\n#include <cassert>\n#include <vector>\n#include <algorithm>\n\n#"
  },
  {
    "path": "include/Reconstruction/Triangulator.h",
    "chars": 1063,
    "preview": "#ifndef __TRIANGULATOR_H__\n#define __TRIANGULATOR_H__\n\n#include <vector>\n#include <opencv2/opencv.hpp>\n\nnamespace Monocu"
  },
  {
    "path": "include/Reconstruction/Utils.h",
    "chars": 822,
    "preview": "#ifndef __UTILS_H__\n#define __UTILS_H__\n\n#include <vector>\n#include <opencv2/opencv.hpp>\n\nnamespace MonocularSfM\n{\n\n\n\ncl"
  },
  {
    "path": "include/Visualization/Visualization.h",
    "chars": 1478,
    "preview": "#ifndef VISUALIZATION_H\n#define VISUALIZATION_H\n\n\n#include <iostream>\n#include <vector>\n#include <unordered_map>\n#includ"
  },
  {
    "path": "pipeline.py",
    "chars": 365,
    "preview": "import os\nimport sys\n\nbin_path = \"./build/\"\n\n# step1 : extract features\nprint(\"FeatureExtraction\")\nos.system(bin_path + "
  },
  {
    "path": "sfm/CMakeLists.txt",
    "chars": 799,
    "preview": "set(MonocularSfM_Feature_LIBS\n\n    feature\n    common\n    database\n    sqlite3\n    -lpthread\n    dl\n    ${OpenCV_LIBS}\n)"
  },
  {
    "path": "sfm/CheckMatches.cpp",
    "chars": 2140,
    "preview": "#include <iostream>\n#include <string>\n\n#include <opencv2/opencv.hpp>\n\n#include \"Database/Database.h\"\n#include \"Feature/F"
  },
  {
    "path": "sfm/ComputeMatches.cpp",
    "chars": 1441,
    "preview": "#include <iostream>\n#include <opencv2/opencv.hpp>\n\n#include \"Common/Timer.h\"\n#include \"Database/Database.h\"\n#include \"Fe"
  },
  {
    "path": "sfm/FeatureExtraction.cpp",
    "chars": 2179,
    "preview": "#include <iostream>\n#include <opencv2/opencv.hpp>\n\n#include \"Common/Timer.h\"\n#include \"Database/Database.h\"\n#include \"F"
  },
  {
    "path": "sfm/Reconstruction.cpp",
    "chars": 1643,
    "preview": "#include \"Reconstruction/MapBuilder.h\"\n#include \"Reconstruction/Utils.h\"\n#include <string>\nusing namespace std;\nusing na"
  },
  {
    "path": "src/CMakeLists.txt",
    "chars": 234,
    "preview": "\n\nadd_subdirectory(Common)\nadd_subdirectory(Database)\nadd_subdirectory(Feature)\n\n\nadd_subdirectory(Reconstruction)\nadd_s"
  },
  {
    "path": "src/Common/CMakeLists.txt",
    "chars": 130,
    "preview": "\nadd_library(\n    common\n    STATIC\n    ../../include/Common/Types.h\n    ../../include/Common/Timer.h               Time"
  },
  {
    "path": "src/Common/Timer.cpp",
    "chars": 2059,
    "preview": "#include \"Common/Timer.h\"\n#include <iostream>\n#include <iomanip>\n\n\nusing namespace MonocularSfM;\n\n\nTimer::Timer() : star"
  },
  {
    "path": "src/Database/CMakeLists.txt",
    "chars": 106,
    "preview": "\nadd_library(\n    database\n    STATIC\n    ../../include/Database/Database.h               Database.cpp\n)\n\n"
  },
  {
    "path": "src/Database/Database.cpp",
    "chars": 30360,
    "preview": "#include \"Database/Database.h\"\n\nusing namespace MonocularSfM;\n\n\nconst size_t kMaxNumImages = 10000;\n\ninline int SQLite3C"
  },
  {
    "path": "src/Estimator/CMakeLists.txt",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "src/Exportor/CMakeLists.txt",
    "chars": 309,
    "preview": "\nadd_library(\n    exportor\n    STATIC\n    ../../include/Exportor/Exportor.h                    Exportor.cpp\n\n    ../../i"
  },
  {
    "path": "src/Exportor/Exportor.cpp",
    "chars": 68,
    "preview": "//#include \"Exportor/Exportor.h\"\n\n//using namespace MonocularSfM;\n\n\n"
  },
  {
    "path": "src/Exportor/OpenMVSExportor.cpp",
    "chars": 118,
    "preview": "//#include \"Exportor/OpenMVSExportor.h\"\n//#include \"Exportor/OpenMVSInterface.h\"\n\n//using namespace MonocularSfM;\n\n\n\n\n"
  },
  {
    "path": "src/Exportor/PLYExportor.cpp",
    "chars": 73,
    "preview": "//#include \"Exportor/PLYExportor.h\"\n\n//using namespace MonocularSfM;\n\n\n\n\n"
  },
  {
    "path": "src/Feature/CMakeLists.txt",
    "chars": 265,
    "preview": "\nadd_library(\n    feature\n    STATIC\n    ../../include/Feature/FeatureUtils.h               FeatureUtils.cpp\n    ../../i"
  },
  {
    "path": "src/Feature/FeatureExtraction.cpp",
    "chars": 8399,
    "preview": "#include <iostream>\n#include <opencv2/opencv.hpp>\n\n\n#include \"Common/Timer.h\"\n#include \"Database/Database.h\"\n#include \"F"
  },
  {
    "path": "src/Feature/FeatureMatching.cpp",
    "chars": 6011,
    "preview": "#include \"Common/Timer.h\"\n#include \"Database/Database.h\"\n#include \"Feature/FeatureUtils.h\"\n#include \"Feature/FeatureMatc"
  },
  {
    "path": "src/Feature/FeatureUtils.cpp",
    "chars": 10426,
    "preview": "#include <unordered_map>\n\n#include <opencv2/xfeatures2d.hpp>\n\n#include \"Feature/FeatureUtils.h\"\n\n\nusing namespace Monocu"
  },
  {
    "path": "src/Optimizer/BundleData.cpp",
    "chars": 971,
    "preview": "#include \"Optimizer/BundleData.h\"\n\n#include \"Reconstruction/Projection.h\"\n\nusing namespace MonocularSfM;\n\n\n\ndouble Bundl"
  },
  {
    "path": "src/Optimizer/CMakeLists.txt",
    "chars": 202,
    "preview": "\nadd_library(\n    optimizer\n    STATIC\n    ../../include/Optimizer/BundleData.h               BundleData.cpp\n    ../../i"
  },
  {
    "path": "src/Optimizer/CeresBundleOptimizer.cpp",
    "chars": 9916,
    "preview": "#include \"Optimizer/CeresBundleOptimizer.h\"\n\n\n#include <ceres/ceres.h>\n#include <ceres/rotation.h>\n#include <ceres/loss_"
  },
  {
    "path": "src/Reconstruction/CMakeLists.txt",
    "chars": 1008,
    "preview": "\nadd_library(\n    reconstruction\n    STATIC\n\n    ../../include/Reconstruction/Utils.h                    Utils.cpp\n    ."
  },
  {
    "path": "src/Reconstruction/Image.cpp",
    "chars": 2326,
    "preview": "#include \"Reconstruction/Image.h\"\nusing namespace MonocularSfM;\n\nImage::Image()\n{\n    num_points3D_ = 0;\n}\nImage::Image("
  },
  {
    "path": "src/Reconstruction/Initializer.cpp",
    "chars": 14940,
    "preview": "\n#include <algorithm>\n\n#include \"Reconstruction/Projection.h\"\n#include \"Reconstruction/Initializer.h\"\n#include \"Reconstr"
  },
  {
    "path": "src/Reconstruction/Map.cpp",
    "chars": 60490,
    "preview": "#include \"Reconstruction/Map.h\"\n#include \"Reconstruction/Projection.h\"\n\n#include \"Exportor/OpenMVSInterface.h\"\n\n#include"
  },
  {
    "path": "src/Reconstruction/MapBuilder.cpp",
    "chars": 19199,
    "preview": "#include \"Reconstruction/MapBuilder.h\"\n\n\nusing namespace MonocularSfM;\n\n\nvoid SetTimer(Timer& timer)\n{\n    if(!timer.IsS"
  },
  {
    "path": "src/Reconstruction/Point2D.cpp",
    "chars": 999,
    "preview": "#include \"Reconstruction/Point2D.h\"\n\nusing namespace MonocularSfM;\n\nPoint2D::Point2D() : xy_(0.0, 0.0), point3D_id_(INVA"
  },
  {
    "path": "src/Reconstruction/Point3D.cpp",
    "chars": 1685,
    "preview": "#include \"Reconstruction/Point3D.h\"\nusing namespace MonocularSfM;\n\nPoint3D::Point3D() : xyz_(0.0, 0.0, 0.0), color_(0, 0"
  },
  {
    "path": "src/Reconstruction/Projection.cpp",
    "chars": 6759,
    "preview": "#include \"Reconstruction/Projection.h\"\n\n\nusing namespace MonocularSfM;\n\nbool Projection::HasPositiveDepth(const cv::Vec3"
  },
  {
    "path": "src/Reconstruction/RegisterGraph.cpp",
    "chars": 3343,
    "preview": "#include \"Reconstruction/RegisterGraph.h\"\nusing namespace MonocularSfM;\n\nRegisterGraph::RegisterGraph(const size_t& tota"
  },
  {
    "path": "src/Reconstruction/Registrant.cpp",
    "chars": 5229,
    "preview": "#include \"Reconstruction/Registrant.h\"\n#include \"Reconstruction/Utils.h\"\n#include \"Reconstruction/Projection.h\"\n\nusing n"
  },
  {
    "path": "src/Reconstruction/SceneGraph.cpp",
    "chars": 9274,
    "preview": "#include <iostream>\n#include <unordered_set>\n\n#include \"Reconstruction/SceneGraph.h\"\n\nusing namespace MonocularSfM;\n\n\n\n\n"
  },
  {
    "path": "src/Reconstruction/Track.cpp",
    "chars": 2474,
    "preview": "#include \"Reconstruction/Track.h\"\n\n\nusing namespace MonocularSfM;\n\n\n\n\n\n\n////////////////////////////////////////////////"
  },
  {
    "path": "src/Reconstruction/Triangulator.cpp",
    "chars": 3150,
    "preview": "#include \"Reconstruction/Triangulator.h\"\n#include \"Reconstruction/Projection.h\"\n\nusing namespace MonocularSfM;\n\n\n\n\n\nTria"
  },
  {
    "path": "src/Reconstruction/Utils.cpp",
    "chars": 2275,
    "preview": "#include \"Reconstruction/Utils.h\"\n\nusing namespace MonocularSfM;\n\n\n\nstd::vector<cv::Point2f> Utils::Vector2dToPoint2f(co"
  },
  {
    "path": "src/Visualization/CMakeLists.txt",
    "chars": 125,
    "preview": "add_library(\n    visualization\n    STATIC\n    ../../include/Visualization/Visualization.h               Visualization.cp"
  },
  {
    "path": "src/Visualization/Visualization.cpp",
    "chars": 3600,
    "preview": "#include \"Common/Types.h\"\n#include \"Visualization/Visualization.h\"\n\n#include <opencv2/viz/viz3d.hpp>\n#include <opencv2/v"
  }
]

About this extraction

This page contains the full source code of the nebula-beta/MonocularSfM GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 83 files (7.2 MB), approximately 1.9M tokens, and a symbol index with 4383 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!