mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-29 08:01:23 +03:00
Bring JNI-side sqlite3_last_insert_rowid() and sqlite3_table_column_metadata() in line with the core's NULL handling.
FossilOrigin-Name: c2afc1c2a2fc9bdf3d7b7701004e0fa40965cf8c6b7cf44b46f2ca37cfa1d2aa
This commit is contained in:
@ -3583,12 +3583,7 @@ S3JniApi(sqlite3_keyword_name(),jstring,1keyword_1name)(
|
||||
S3JniApi(sqlite3_last_insert_rowid(),jlong,1last_1insert_1rowid)(
|
||||
JniArgsEnvClass, jobject jpDb
|
||||
){
|
||||
jlong rc = 0;
|
||||
sqlite3 * const pDb = PtrGet_sqlite3(jpDb);
|
||||
if( pDb ){
|
||||
rc = (jlong)sqlite3_last_insert_rowid(pDb);
|
||||
}
|
||||
return rc;
|
||||
return (jlong)sqlite3_last_insert_rowid(PtrGet_sqlite3(jpDb));
|
||||
}
|
||||
|
||||
S3JniApi(sqlite3_limit(),jint,1limit)(
|
||||
@ -4564,11 +4559,12 @@ S3JniApi(sqlite3_table_column_metadata(),int,1table_1column_1metadata)(
|
||||
int pNotNull = 0, pPrimaryKey = 0, pAutoinc = 0;
|
||||
int rc;
|
||||
|
||||
if( !db || !jDbName || !jTableName || !jColumnName ) return SQLITE_MISUSE;
|
||||
if( !db || !jDbName || !jTableName ) return SQLITE_MISUSE;
|
||||
zDbName = s3jni_jstring_to_utf8(jDbName,0);
|
||||
zTableName = zDbName ? s3jni_jstring_to_utf8(jTableName,0) : 0;
|
||||
zColumnName = zTableName ? s3jni_jstring_to_utf8(jColumnName,0) : 0;
|
||||
rc = zColumnName
|
||||
zColumnName = (zTableName && jColumnName)
|
||||
? s3jni_jstring_to_utf8(jColumnName,0) : 0;
|
||||
rc = zTableName
|
||||
? sqlite3_table_column_metadata(db, zDbName, zTableName,
|
||||
zColumnName, &pzDataType, &pzCollSeq,
|
||||
&pNotNull, &pPrimaryKey, &pAutoinc)
|
||||
|
@ -259,6 +259,7 @@ public class Tester1 implements Runnable {
|
||||
affirm( 0==sqlite3_db_readonly(db,null) );
|
||||
affirm( 0>sqlite3_db_readonly(db,"nope") );
|
||||
affirm( 0>sqlite3_db_readonly(null,null) );
|
||||
affirm( 0==sqlite3_last_insert_rowid(null) );
|
||||
|
||||
// These interrupt checks are only to make sure that the JNI binding
|
||||
// has the proper exported symbol names. They don't actually test
|
||||
@ -1464,7 +1465,7 @@ public class Tester1 implements Runnable {
|
||||
affirm( "noCase".equals(zCollSeq.value) );
|
||||
affirm( "duck".equals(zDataType.value) );
|
||||
|
||||
final TableColumnMetadata m =
|
||||
TableColumnMetadata m =
|
||||
sqlite3_table_column_metadata(db, "main", "t", "a");
|
||||
affirm( null != m );
|
||||
affirm( bPrimaryKey.value == m.isPrimaryKey() );
|
||||
@ -1474,6 +1475,16 @@ public class Tester1 implements Runnable {
|
||||
affirm( zDataType.value.equals(m.getDataType()) );
|
||||
|
||||
affirm( null == sqlite3_table_column_metadata(db, "nope", "t", "a") );
|
||||
affirm( null == sqlite3_table_column_metadata(db, "main", "nope", "a") );
|
||||
|
||||
m = sqlite3_table_column_metadata(db, "main", "t", null)
|
||||
/* Check only for existence of table */;
|
||||
affirm( null != m );
|
||||
affirm( m.isPrimaryKey() );
|
||||
affirm( !m.isAutoincrement() );
|
||||
affirm( !m.isNotNull() );
|
||||
affirm( "BINARY".equalsIgnoreCase(m.getCollation()) );
|
||||
affirm( "INTEGER".equalsIgnoreCase(m.getDataType()) );
|
||||
|
||||
sqlite3_close_v2(db);
|
||||
}
|
||||
|
Reference in New Issue
Block a user