/ Check-in [782c3351]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:replaced relative lock proxy paths with absolute
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | apple-osx
Files: files | file ages | folders
SHA1: 782c33512ab2b677b0734c591fcecddc5a655203
User & Date: adam 2010-09-10 20:19:07
Context
2010-09-10
23:16
fixed memory leak in proxy lock file error handling check-in: e01c5f3e user: adam tags: apple-osx
20:19
replaced relative lock proxy paths with absolute check-in: 782c3351 user: adam tags: apple-osx
00:59
replaced relative lock proxy paths with absolute check-in: 6a88cd46 user: adam tags: apple-osx
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to test/pragma.test.

1303
1304
1305
1306
1307
1308
1309

1310
1311
1312
1313
1314
1315
1316
1317
1318

1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351


1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363

1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
....
1402
1403
1404
1405
1406
1407
1408


1409
1410
1411
1412
1413
1414
1415
1416

1417
1418
1419
1420
1421
1422
1423
1424
1425
....
1432
1433
1434
1435
1436
1437
1438

1439
1440
1441
1442

1443
1444
1445
1446
1447
1448
1449
1450
1451
....
1472
1473
1474
1475
1476
1477
1478

1479
1480
1481
1482

1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495

1496
1497
1498
1499
1500
1501
1502
1503
1504
....
1510
1511
1512
1513
1514
1515
1516

1517
1518
1519
1520
1521
1522
1523
1524
1525
  # Test the lock_proxy_file pragmas.
  #
  db close
  set env(SQLITE_FORCE_PROXY_LOCKING) "0"

  sqlite3 db test.db
  # set lock proxy name and then query it via pragma interface

  do_test pragma-16.1 {
    execsql {
      PRAGMA lock_proxy_file="mylittleproxy";
      select * from sqlite_master;
    }
    execsql {
      PRAGMA lock_proxy_file;
    } 
  } {mylittleproxy}


  # 2 database connections can share a lock proxy file
  do_test pragma-16.2 {
    sqlite3 db2 test.db
    execsql {
      PRAGMA lock_proxy_file="mylittleproxy";
    } db2
  } {}

  db2 close
  # 2nd database connection should auto-name an existing lock proxy file
  do_test pragma-16.2.1 {
    sqlite3 db2 test.db
    execsql {
      PRAGMA lock_proxy_file=":auto:";
      select * from sqlite_master;
    } db2
    execsql {
      PRAGMA lock_proxy_file;
    } db2
  } {mylittleproxy}

  db2 close
  # 2nd database connection cannot override the lock proxy file
  do_test pragma-16.3 {
    sqlite3 db2 test.db
    execsql {
      PRAGMA lock_proxy_file="myotherproxy";
    } db2
    catchsql {
      select * from sqlite_master;
    } db2
  } {1 {database is locked}}



  # lock proxy file can be renamed if no other connections are active
  do_test pragma-16.4 {
    db2 close
    db close
    sqlite3 db2 test.db
    execsql {
      PRAGMA lock_proxy_file="myoriginalproxy";
      PRAGMA lock_proxy_file="myotherproxy";
      PRAGMA lock_proxy_file;
    } db2
  } {myotherproxy}


  db2 close
  set env(SQLITE_FORCE_PROXY_LOCKING) "1"
  # auto-naming should reuse the last proxy name when available
  do_test pragma-16.5 {
    sqlite3 db2 test.db
    execsql {
      PRAGMA lock_proxy_file=":auto:";
      PRAGMA lock_proxy_file;
    } db2
  } {myotherproxy}
  
  # auto-naming a new proxy should use a predictable & unique name
  do_test pragma-16.6 {
    db2 close
    sqlite3 db2 test2.db
    set lockpath [execsql {
      PRAGMA lock_proxy_file=":auto:";
................................................................................
    sqlite3 db test2.db
    catchsql {
      select * from sqlite_master;
    } 
  } {1 {database is locked}}

  db2 close


  # check that db is unlocked after first host connection closes 
  do_test pragma-16.8.1 {
    execsql {
      PRAGMA lock_proxy_file="yetanotherproxy";
      select * from sqlite_master;
    }
    execsql {
      PRAGMA lock_proxy_file;

    } 
  } {yetanotherproxy}
  do_test pragma-16.8.2 {
    execsql {
      create table if not exists mine(x);
      insert into mine values (1);
    } 
  } {}

................................................................................
      PRAGMA lock_proxy_file=":auto:";
      PRAGMA lock_proxy_file;
    } db]
    string match "*proxytest.db:auto:" $lockpath2
  } {1}

  # ensure creating directories for a lock proxy file works

  db close
  file delete -force proxytest
  do_test pragma-16.10.1 {
    sqlite3 db proxytest.db

    set lockpath2 [execsql {
      PRAGMA lock_proxy_file="./proxytest/sub/dir/lock";
      PRAGMA lock_proxy_file;
    } db]
    string match "*proxytest/sub/dir/lock" $lockpath2
  } {1}

  # ensure that after deleting the path, setting ":auto:" works correctly
  db close
................................................................................
      create table if not exists zz(y);
      PRAGMA lock_proxy_file;
    } db]
    string match "*proxytest.db:auto:" $lockpath2
  } {1}

  # make sure we can deal with ugly file paths correctly

  db close
  file delete -force proxytest
  do_test pragma-16.10.4 {
    sqlite3 db proxytest.db

    set lockpath2 [execsql {
      PRAGMA lock_proxy_file="./././////./proxytest/../proxytest/sub/dir/lock";
      create table if not exists aa(bb);
      PRAGMA lock_proxy_file;
    } db]
    string match "*proxytest/sub/dir/lock" $lockpath2
  } {1}

  # ensure that if the path can not be created (perm), setting :auto: deals
  db close
  file delete -force proxytest
  do_test pragma-16.10.5 {
    sqlite3 db proxytest.db

    execsql {
      PRAGMA lock_proxy_file="./proxytest/sub/dir/lock";
      create table if not exists bb(bb);
    }
    db close
    file delete -force proxytest
    file mkdir proxytest
    file attributes proxytest -permission 0000
    sqlite3 db proxytest.db
................................................................................
    string match "*proxytest.db:auto:" $lockpath2
  } {1}

  # ensure that if the path can not be created, locking fails
  db close
  do_test pragma-16.10.6 {
    sqlite3 db proxytest.db

    catchsql {
      PRAGMA lock_proxy_file="./proxytest/sub/dir/lock";
      create table if not exists faily(y);
      PRAGMA lock_proxy_file;
    } db
  } {1 {database is locked}}
  db close

  file attributes proxytest -permission 0777







>

<
|
|
<
<
|
<
<
>




<
|
<










|
|
|
|
|
|



<
|
<




>
>






<
|
|
|
<
<
>










|







 







>
>


<
|
|
<
<
|
>
|
<







 







>




>

<







 







>




>

<











>

<







 







>

<







1303
1304
1305
1306
1307
1308
1309
1310
1311

1312
1313


1314


1315
1316
1317
1318
1319

1320

1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339

1340

1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352

1353
1354
1355


1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
....
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405

1406
1407


1408
1409
1410

1411
1412
1413
1414
1415
1416
1417
....
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437

1438
1439
1440
1441
1442
1443
1444
....
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478

1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491

1492
1493
1494
1495
1496
1497
1498
....
1504
1505
1506
1507
1508
1509
1510
1511
1512

1513
1514
1515
1516
1517
1518
1519
  # Test the lock_proxy_file pragmas.
  #
  db close
  set env(SQLITE_FORCE_PROXY_LOCKING) "0"

  sqlite3 db test.db
  # set lock proxy name and then query it via pragma interface
  set lpp [pwd]/proxyfile_1
  do_test pragma-16.1 {

    execsql "PRAGMA lock_proxy_file='$lpp'"
    execsql "select * from sqlite_master"


    execsql "PRAGMA lock_proxy_file"


  } $lpp

  # 2 database connections can share a lock proxy file
  do_test pragma-16.2 {
    sqlite3 db2 test.db

    execsql "PRAGMA lock_proxy_file='$lpp'" db2

  } {}

  db2 close
  # 2nd database connection should auto-name an existing lock proxy file
  do_test pragma-16.2.1 {
    sqlite3 db2 test.db
    execsql {
      PRAGMA lock_proxy_file=":auto:";
      select * from sqlite_master;
    } db2
    execsql "PRAGMA lock_proxy_file" db2
  } $lpp

  db2 close
  set lpp2 [pwd]/proxyfile_2

  # 2nd database connection cannot override the lock proxy file
  do_test pragma-16.3 {
    sqlite3 db2 test.db

    execsql "PRAGMA lock_proxy_file='$lpp2'" db2

    catchsql {
      select * from sqlite_master;
    } db2
  } {1 {database is locked}}

  set lpp3 [pwd]/unused_proxyfile

  # lock proxy file can be renamed if no other connections are active
  do_test pragma-16.4 {
    db2 close
    db close
    sqlite3 db2 test.db

    execsql "PRAGMA lock_proxy_file='$lpp3'" db2
    execsql "PRAGMA lock_proxy_file='$lpp2'" db2
    execsql "PRAGMA lock_proxy_file" db2


  } $lpp2

  db2 close
  set env(SQLITE_FORCE_PROXY_LOCKING) "1"
  # auto-naming should reuse the last proxy name when available
  do_test pragma-16.5 {
    sqlite3 db2 test.db
    execsql {
      PRAGMA lock_proxy_file=":auto:";
      PRAGMA lock_proxy_file;
    } db2
  } $lpp2
  
  # auto-naming a new proxy should use a predictable & unique name
  do_test pragma-16.6 {
    db2 close
    sqlite3 db2 test2.db
    set lockpath [execsql {
      PRAGMA lock_proxy_file=":auto:";
................................................................................
    sqlite3 db test2.db
    catchsql {
      select * from sqlite_master;
    } 
  } {1 {database is locked}}

  db2 close
  set lpp4 [pwd]/proxyfile_4

  # check that db is unlocked after first host connection closes 
  do_test pragma-16.8.1 {

    execsql "PRAGMA lock_proxy_file='$lpp4'" 
    execsql "select * from sqlite_master"


    execsql "PRAGMA lock_proxy_file"
  } $lpp4
  

  do_test pragma-16.8.2 {
    execsql {
      create table if not exists mine(x);
      insert into mine values (1);
    } 
  } {}

................................................................................
      PRAGMA lock_proxy_file=":auto:";
      PRAGMA lock_proxy_file;
    } db]
    string match "*proxytest.db:auto:" $lockpath2
  } {1}

  # ensure creating directories for a lock proxy file works
  set lpp5 [pwd]/proxytest/sub/dir/lock
  db close
  file delete -force proxytest
  do_test pragma-16.10.1 {
    sqlite3 db proxytest.db
    execsql "PRAGMA lock_proxy_file='$lpp5'" 
    set lockpath2 [execsql {

      PRAGMA lock_proxy_file;
    } db]
    string match "*proxytest/sub/dir/lock" $lockpath2
  } {1}

  # ensure that after deleting the path, setting ":auto:" works correctly
  db close
................................................................................
      create table if not exists zz(y);
      PRAGMA lock_proxy_file;
    } db]
    string match "*proxytest.db:auto:" $lockpath2
  } {1}

  # make sure we can deal with ugly file paths correctly
  set lpp6 [pwd]/./././////./proxytest/../proxytest/sub/dir/lock
  db close
  file delete -force proxytest
  do_test pragma-16.10.4 {
    sqlite3 db proxytest.db
    execsql "PRAGMA lock_proxy_file='$lpp6'" 
    set lockpath2 [execsql {

      create table if not exists aa(bb);
      PRAGMA lock_proxy_file;
    } db]
    string match "*proxytest/sub/dir/lock" $lockpath2
  } {1}

  # ensure that if the path can not be created (perm), setting :auto: deals
  db close
  file delete -force proxytest
  do_test pragma-16.10.5 {
    sqlite3 db proxytest.db
    execsql "PRAGMA lock_proxy_file='$lpp5'" 
    execsql {

      create table if not exists bb(bb);
    }
    db close
    file delete -force proxytest
    file mkdir proxytest
    file attributes proxytest -permission 0000
    sqlite3 db proxytest.db
................................................................................
    string match "*proxytest.db:auto:" $lockpath2
  } {1}

  # ensure that if the path can not be created, locking fails
  db close
  do_test pragma-16.10.6 {
    sqlite3 db proxytest.db
    execsql "PRAGMA lock_proxy_file='$lpp5'" 
    catchsql {

      create table if not exists faily(y);
      PRAGMA lock_proxy_file;
    } db
  } {1 {database is locked}}
  db close

  file attributes proxytest -permission 0777