@@ -1866,13 +1866,101 @@ pysqlite_connection_exit_impl(pysqlite_Connection *self, PyObject *exc_type,
18661866 Py_RETURN_FALSE ;
18671867}
18681868
1869+ static
1870+ PyObject * get_limit (pysqlite_Connection * self , void * limit )
1871+ {
1872+ if (!pysqlite_check_thread (self ) || !pysqlite_check_connection (self )) {
1873+ return NULL ;
1874+ }
1875+
1876+ int value = sqlite3_limit (self -> db , (int )limit , -1 );
1877+ return PyLong_FromLong (value );
1878+ }
1879+
1880+ static int
1881+ set_limit (pysqlite_Connection * self , PyObject * value , void * limit )
1882+ {
1883+ if (!pysqlite_check_thread (self ) || !pysqlite_check_connection (self )) {
1884+ return -1 ;
1885+ }
1886+ if (value == NULL ) {
1887+ PyErr_SetString (self -> ProgrammingError ,
1888+ "Cannot delete limit attributes" );
1889+ return -1 ;
1890+ }
1891+ int setval = _PyLong_AsInt (value );
1892+ if (setval == -1 && PyErr_Occurred ()) {
1893+ return -1 ;
1894+ }
1895+ (void )sqlite3_limit (self -> db , (int )limit , setval );
1896+ return 0 ;
1897+ }
1898+
18691899static const char connection_doc [] =
18701900PyDoc_STR ("SQLite database connection object." );
18711901
1902+ #define DEF_LIMIT_GETSET (limit , doc ) \
1903+ {#limit, (getter)get_limit, (setter)set_limit, doc, (void *)limit},
1904+
18721905static PyGetSetDef connection_getset [] = {
18731906 {"isolation_level" , (getter )pysqlite_connection_get_isolation_level , (setter )pysqlite_connection_set_isolation_level },
18741907 {"total_changes" , (getter )pysqlite_connection_get_total_changes , (setter )0 },
18751908 {"in_transaction" , (getter )pysqlite_connection_get_in_transaction , (setter )0 },
1909+ DEF_LIMIT_GETSET (
1910+ SQLITE_LIMIT_LENGTH ,
1911+ "The maximum size of any string or BLOB or table row, in bytes."
1912+ )
1913+ DEF_LIMIT_GETSET (
1914+ SQLITE_LIMIT_SQL_LENGTH ,
1915+ "The maximum length of an SQL statement, in bytes."
1916+ )
1917+ DEF_LIMIT_GETSET (
1918+ SQLITE_LIMIT_COLUMN ,
1919+ "The maximum number of columns in a table definition or in the result "
1920+ "set of a SELECT or the maximum number of columns in an index or in an "
1921+ "ORDER BY or GROUP BY clause."
1922+ )
1923+ DEF_LIMIT_GETSET (
1924+ SQLITE_LIMIT_EXPR_DEPTH ,
1925+ "The maximum depth of the parse tree on any expression."
1926+ )
1927+ DEF_LIMIT_GETSET (
1928+ SQLITE_LIMIT_COMPOUND_SELECT ,
1929+ "The maximum number of terms in a compound SELECT statement."
1930+ )
1931+ DEF_LIMIT_GETSET (
1932+ SQLITE_LIMIT_VDBE_OP ,
1933+ "The maximum number of instructions in a virtual machine program used "
1934+ "to implement an SQL statement."
1935+ )
1936+ DEF_LIMIT_GETSET (
1937+ SQLITE_LIMIT_FUNCTION_ARG ,
1938+ "The maximum number of arguments on a function."
1939+ )
1940+ DEF_LIMIT_GETSET (
1941+ SQLITE_LIMIT_ATTACHED ,
1942+ "The maximum number of attached databases."
1943+ )
1944+ DEF_LIMIT_GETSET (
1945+ SQLITE_LIMIT_LIKE_PATTERN_LENGTH ,
1946+ "The maximum length of the pattern argument to the LIKE or GLOB "
1947+ "operators."
1948+ )
1949+ DEF_LIMIT_GETSET (
1950+ SQLITE_LIMIT_VARIABLE_NUMBER ,
1951+ "The maximum index number of any parameter in an SQL statement."
1952+ )
1953+ DEF_LIMIT_GETSET (
1954+ SQLITE_LIMIT_TRIGGER_DEPTH ,
1955+ "The maximum depth of recursion for triggers."
1956+ )
1957+ #if SQLITE_VERSION_NUMBER >= 3008003
1958+ DEF_LIMIT_GETSET (
1959+ SQLITE_LIMIT_WORKER_THREADS ,
1960+ "The maximum number of auxiliary worker threads that a single "
1961+ "prepared statement may start."
1962+ )
1963+ #endif
18761964 {NULL }
18771965};
18781966
0 commit comments