954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
....
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
....
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
....
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
....
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
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
....
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
....
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
....
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
....
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
....
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
....
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
....
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
....
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
....
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
....
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
....
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
|
-- only to the connecting parsav instance, stored in memory, and dropped
-- as soon as the connection session ends.
local tempviews = sqlsquash(lib.util.ingest 'backend/schema/pgsql-views.sql')
local prep = { quote
var res = lib.pq.PQexec([con], tempviews)
if lib.pq.PQresultStatus(res) == lib.pq.PGRES_COMMAND_OK then
lib.dbg('uploading pgsql session views')
else
lib.bail('backend pgsql - failed to upload session views: \n', lib.pq.PQresultErrorMessage(res))
end
end }
for k,q in pairs(queries) do
local qt = sqlsquash(q.sql)
................................................................................
[#args], params, params_sz, params_ft, 1)
if res == nil then
lib.bail(['grievous error occurred executing '..k..' against database'])
elseif lib.pq.PQresultStatus(res) ~= okconst then
lib.bail(['PGSQL database procedure '..k..' failed\n'],
lib.pq.PQresultErrorMessage(res))
end
var ct = lib.pq.PQntuples(res)
if ct == 0 then
lib.pq.PQclear(res)
return pqr {0, nil}
else
return pqr {ct, res}
end
end
q.exec.name = 'pgsql.' .. k .. '.exec'
end
local terra row_to_artifact(res: &pqr, i: intptr): lib.mem.ptr(lib.store.artifact)
var id = res:int(uint64,i,0)
................................................................................
local getpow = terra(
src: &lib.store.source,
uid: uint64
): lib.store.powerset
var powers = lib.store.rights_default().powers
var map = array([privmap])
var r = queries.actor_powers_fetch.exec(src, uid)
for i=0, r.sz do
for j=0, [map.type.N] do
var pn = r:_string(i,0)
if map[j].name:cmp(pn) then
if r:bool(i,1)
then powers = powers + map[j].val
................................................................................
return powers
end
local txdo = terra(src: &lib.store.source)
var res = lib.pq.PQexec([&lib.pq.PGconn](src.handle), 'begin')
if lib.pq.PQresultStatus(res) == lib.pq.PGRES_COMMAND_OK then
lib.dbg('beginning pgsql transaction')
return true
else
lib.warn('backend pgsql - failed to begin transaction: \n', lib.pq.PQresultErrorMessage(res))
return false
end
end
local txdone = terra(src: &lib.store.source)
var res = lib.pq.PQexec([&lib.pq.PGconn](src.handle), 'end')
if lib.pq.PQresultStatus(res) == lib.pq.PGRES_COMMAND_OK then
lib.dbg('completing pgsql transaction')
return true
else
lib.warn('backend pgsql - failed to complete transaction: \n', lib.pq.PQresultErrorMessage(res))
return false
end
end
local b = `lib.store.backend {
id = "pgsql";
open = [terra(src: &lib.store.source): &opaque
lib.report('connecting to postgres database: ', src.string.ptr)
var [con] = lib.pq.PQconnectdb(src.string.ptr)
................................................................................
key: binblob
): {}
queries.server_setup_self.exec(src,domain,key,lib.osclock.time(nil))
end];
dbsetup = [terra(src: &lib.store.source): bool
var res = lib.pq.PQexec([&lib.pq.PGconn](src.handle), schema)
if lib.pq.PQresultStatus(res) == lib.pq.PGRES_COMMAND_OK then
lib.report('successfully instantiated schema in database')
return true
else
lib.warn('backend pgsql - failed to initialize database: \n', lib.pq.PQresultErrorMessage(res))
return false
end
end];
obliterate_everything = [terra(src: &lib.store.source): bool
var res = lib.pq.PQexec([&lib.pq.PGconn](src.handle), obliterator)
if lib.pq.PQresultStatus(res) == lib.pq.PGRES_COMMAND_OK then
lib.report('successfully wiped out everything parsav-related in database')
return true
else
lib.warn('backend pgsql - failed to obliterate database: \n', lib.pq.PQresultErrorMessage(res))
return false
end
end];
conf_get = [terra(src: &lib.store.source, key: pstring)
var r = queries.conf_get.exec(src, key)
if r.sz == 0 then return [lib.mem.ptr(int8)] { ptr = nil, ct = 0 } else
defer r:free()
return r:String(0,0)
end
end];
conf_set = [terra(src: &lib.store.source, key: pstring, val: pstring)
queries.conf_set.exec(src, key, val):free() end];
conf_reset = [terra(src: &lib.store.source, key: rawstring)
queries.conf_reset.exec(src, key):free() end];
actor_fetch_uid = [terra(src: &lib.store.source, uid: uint64)
var r = queries.actor_fetch_uid.exec(src, uid)
if r.sz == 0 then
return [lib.mem.ptr(lib.store.actor)] { ct = 0, ptr = nil }
else defer r:free()
var a = row_to_actor(&r, 0)
................................................................................
::fail::return 0, 0, pstring.null()
end];
actor_stats = [terra(src: &lib.store.source, uid: uint64)
var r = queries.actor_stats.exec(src, uid)
if r.sz == 0 then lib.bail('error fetching actor stats!') end
var s: lib.store.actor_stats
s.posts = r:int(uint64, 0, 0)
s.follows = r:int(uint64, 0, 1)
s.followers = r:int(uint64, 0, 2)
s.mutuals = r:int(uint64, 0, 3)
return s
end];
................................................................................
post_fetch = [terra(
src: &lib.store.source,
post: uint64
): lib.mem.ptr(lib.store.post)
var r = queries.post_fetch.exec(src, post)
if r.sz == 0 then return [lib.mem.ptr(lib.store.post)].null() end
var p = row_to_post(&r, 0)
p.ptr.source = src
return p
end];
post_act_cancel = [terra(
src: &lib.store.source,
................................................................................
r = queries.timeline_instance_fetch.exec(src,A,B,C,D)
var ret: lib.mem.ptr(lib.mem.ptr(lib.store.post)) ret:init(r.sz)
for i=0,r.sz do
ret.ptr[i] = row_to_post(&r, i) -- MUST FREE ALL
ret.ptr[i].ptr.source = src
end
return ret
end];
timeline_circle_fetch = [terra(
src: &lib.store.source,
cid: uint64,
................................................................................
r = queries.timeline_circle_fetch.exec(src,cid,A,B,C,D)
var ret: lib.mem.ptr(lib.mem.ptr(lib.store.post)) ret:init(r.sz)
for i=0,r.sz do
ret.ptr[i] = row_to_post(&r, i) -- MUST FREE ALL
ret.ptr[i].ptr.source = src
end
return ret
end];
timeline_actor_fetch_uid = [terra(
src: &lib.store.source,
uid: uint64,
................................................................................
r = queries.timeline_actor_fetch.exec(src,uid,A,B,C,D)
var ret: lib.mem.ptr(lib.mem.ptr(lib.store.post)) ret:init(r.sz)
for i=0,r.sz do
ret.ptr[i] = row_to_post(&r, i) -- MUST FREE ALL
ret.ptr[i].ptr.source = src
end
return ret
end];
post_enum_author_uid = [terra(
src: &lib.store.source,
uid: uint64,
................................................................................
r = queries.post_enum_author_uid.exec(src,A,B,C,D,uid)
var ret: lib.mem.ptr(lib.mem.ptr(lib.store.post)) ret:init(r.sz)
for i=0,r.sz do
ret.ptr[i] = row_to_post(&r, i) -- MUST FREE ALL
ret.ptr[i].ptr.source = src
end
return ret
end];
actor_powers_fetch = getpow;
actor_save = [terra(
src: &lib.store.source,
................................................................................
ac.id = r:int(uint64,0,0)
-- check against default rights, insert records for wherever powers differ
lib.dbg('created new actor, establishing powers')
privupdate(src,ac)
lib.dbg('powers established')
return ac.id
end];
actor_rel_create = [terra(
src: &lib.store.source,
kind: uint16,
relator: uint64,
................................................................................
auth_fetch_aid = [terra(
src: &lib.store.source,
aid: uint64
): lib.mem.ptr(lib.store.auth)
var r = queries.auth_fetch_aid.exec(src,aid)
if r.sz == 0 then return [lib.mem.ptr(lib.store.auth)].null() end
var kind = r:_string(0, 2)
var comment = r:_string(0, 3)
var a = [ lib.str.encapsulate(lib.store.auth, {
kind = {`kind.ptr, `kind.ct+1};
comment = {`comment.ptr, `comment.ct+1};
}) ]
a.ptr.aid = r:int(uint64, 0, 0)
................................................................................
auth_enum_uid = [terra(
src: &lib.store.source,
uid: uint64
): lib.mem.lstptr(lib.store.auth)
var r = queries.auth_enum_uid.exec(src,uid)
if r.sz == 0 then return [lib.mem.lstptr(lib.store.auth)].null() end
var ret = lib.mem.heapa([lib.mem.ptr(lib.store.auth)], r.sz)
for i=0, r.sz do
var kind = r:_string(i, 1)
var comment = r:_string(i, 2)
var a = [ lib.str.encapsulate(lib.store.auth, {
kind = {`kind.ptr, `kind.ct+1};
comment = {`comment.ptr, `comment.ct+1};
................................................................................
artifact_enum_uid = [terra(
src: &lib.store.source,
uid: uint64,
folder: pstring
)
var res = queries.artifact_enum_uid.exec(src,uid,folder)
if res.sz > 0 then
var m = lib.mem.heapa([lib.mem.ptr(lib.store.artifact)], res.sz)
for i=0,res.sz do
m.ptr[i] = row_to_artifact(&res, i)
m(i).ptr.owner = uid
end
return m
else return [lib.mem.lstptr(lib.store.artifact)].null() end
................................................................................
actor_conf_str_enum = nil;
actor_conf_str_get = [terra(
src: &lib.store.source,
pool: &lib.mem.pool,
uid: uint64,
key: pstring
): pstring
var r = queries.actor_conf_str_get.exec(src, uid, key)
if r.sz > 0 then
return r:_string(0,0):pdup(pool)
else return pstring.null() end
end];
actor_conf_str_set = [terra(src: &lib.store.source, uid: uint64, key: pstring, value: pstring): {}
queries.actor_conf_str_set.exec(src,uid,key,value) end];
actor_conf_str_reset = [terra(src: &lib.store.source, uid: uint64, key: pstring): {}
queries.actor_conf_str_reset.exec(src,uid,key) end];
actor_conf_int_enum = nil;
actor_conf_int_get = [terra(src: &lib.store.source, uid: uint64, key: pstring)
var r = queries.actor_conf_int_get.exec(src, uid, key)
if r.sz > 0 then
var ret = r:int(uint64,0,0)
r:free()
|
|
>
<
>
>
>
>
|
|
|
|
|
|
>
>
>
>
|
|
>
>
>
|
|
>
>
>
<
|
>
>
>
<
>
>
|
|
|
|
>
>
>
>
>
>
>
>
>
|
|
|
|
|
|
|
|
|
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
....
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
....
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
....
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
....
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
....
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
....
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
....
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
....
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
....
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
....
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
....
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
....
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
....
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
....
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
....
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
|
-- only to the connecting parsav instance, stored in memory, and dropped
-- as soon as the connection session ends.
local tempviews = sqlsquash(lib.util.ingest 'backend/schema/pgsql-views.sql')
local prep = { quote
var res = lib.pq.PQexec([con], tempviews)
if lib.pq.PQresultStatus(res) == lib.pq.PGRES_COMMAND_OK then
lib.dbg('uploaded pgsql session views')
lib.pq.PQclear(res)
else
lib.bail('backend pgsql - failed to upload session views: \n', lib.pq.PQresultErrorMessage(res))
end
end }
for k,q in pairs(queries) do
local qt = sqlsquash(q.sql)
................................................................................
[#args], params, params_sz, params_ft, 1)
if res == nil then
lib.bail(['grievous error occurred executing '..k..' against database'])
elseif lib.pq.PQresultStatus(res) ~= okconst then
lib.bail(['PGSQL database procedure '..k..' failed\n'],
lib.pq.PQresultErrorMessage(res))
end
escape
if q.cmd then
emit quote lib.pq.PQclear(res) end
else emit quote
var ct = lib.pq.PQntuples(res)
if ct == 0 then
lib.pq.PQclear(res)
return pqr {0, nil}
else
return pqr {ct, res}
end
end end
end
end
q.exec.name = 'pgsql.' .. k .. '.exec'
end
local terra row_to_artifact(res: &pqr, i: intptr): lib.mem.ptr(lib.store.artifact)
var id = res:int(uint64,i,0)
................................................................................
local getpow = terra(
src: &lib.store.source,
uid: uint64
): lib.store.powerset
var powers = lib.store.rights_default().powers
var map = array([privmap])
var r = queries.actor_powers_fetch.exec(src, uid)
defer r:free()
for i=0, r.sz do
for j=0, [map.type.N] do
var pn = r:_string(i,0)
if map[j].name:cmp(pn) then
if r:bool(i,1)
then powers = powers + map[j].val
................................................................................
return powers
end
local txdo = terra(src: &lib.store.source)
var res = lib.pq.PQexec([&lib.pq.PGconn](src.handle), 'begin')
var r: bool
if lib.pq.PQresultStatus(res) == lib.pq.PGRES_COMMAND_OK then
lib.dbg('beginning pgsql transaction')
r = true
else
lib.warn('backend pgsql - failed to begin transaction: \n', lib.pq.PQresultErrorMessage(res))
r = false
end
lib.pq.PQclear(res)
return r
end
local txdone = terra(src: &lib.store.source)
var res = lib.pq.PQexec([&lib.pq.PGconn](src.handle), 'end')
var r: bool
if lib.pq.PQresultStatus(res) == lib.pq.PGRES_COMMAND_OK then
lib.dbg('completing pgsql transaction')
r = true
else
lib.warn('backend pgsql - failed to complete transaction: \n', lib.pq.PQresultErrorMessage(res))
r = false
end
lib.pq.PQclear(res)
return r
end
local b = `lib.store.backend {
id = "pgsql";
open = [terra(src: &lib.store.source): &opaque
lib.report('connecting to postgres database: ', src.string.ptr)
var [con] = lib.pq.PQconnectdb(src.string.ptr)
................................................................................
key: binblob
): {}
queries.server_setup_self.exec(src,domain,key,lib.osclock.time(nil))
end];
dbsetup = [terra(src: &lib.store.source): bool
var res = lib.pq.PQexec([&lib.pq.PGconn](src.handle), schema)
var r = true
if lib.pq.PQresultStatus(res) == lib.pq.PGRES_COMMAND_OK then
lib.report('successfully instantiated schema in database')
else
lib.warn('backend pgsql - failed to initialize database: \n', lib.pq.PQresultErrorMessage(res))
r = false
end
lib.pq.PQclear(res)
return r
end];
obliterate_everything = [terra(src: &lib.store.source): bool
var res = lib.pq.PQexec([&lib.pq.PGconn](src.handle), obliterator)
var r = true
if lib.pq.PQresultStatus(res) == lib.pq.PGRES_COMMAND_OK then
lib.report('successfully wiped out everything parsav-related in database')
else
lib.warn('backend pgsql - failed to obliterate database: \n', lib.pq.PQresultErrorMessage(res))
return false
end
lib.pq.PQclear(res)
return r
end];
conf_get = [terra(src: &lib.store.source, pool: &lib.mem.pool, key: pstring)
var r = queries.conf_get.exec(src, key)
if r.sz == 0 then return [lib.mem.ptr(int8)] { ptr = nil, ct = 0 } else
defer r:free()
return r:_string(0,0):pdup(pool)
end
end];
conf_set = [terra(src: &lib.store.source, key: pstring, val: pstring)
queries.conf_set.exec(src, key, val) end];
conf_reset = [terra(src: &lib.store.source, key: rawstring)
queries.conf_reset.exec(src, key) end];
actor_fetch_uid = [terra(src: &lib.store.source, uid: uint64)
var r = queries.actor_fetch_uid.exec(src, uid)
if r.sz == 0 then
return [lib.mem.ptr(lib.store.actor)] { ct = 0, ptr = nil }
else defer r:free()
var a = row_to_actor(&r, 0)
................................................................................
::fail::return 0, 0, pstring.null()
end];
actor_stats = [terra(src: &lib.store.source, uid: uint64)
var r = queries.actor_stats.exec(src, uid)
if r.sz == 0 then lib.bail('error fetching actor stats!') end
defer r:free()
var s: lib.store.actor_stats
s.posts = r:int(uint64, 0, 0)
s.follows = r:int(uint64, 0, 1)
s.followers = r:int(uint64, 0, 2)
s.mutuals = r:int(uint64, 0, 3)
return s
end];
................................................................................
post_fetch = [terra(
src: &lib.store.source,
post: uint64
): lib.mem.ptr(lib.store.post)
var r = queries.post_fetch.exec(src, post)
if r.sz == 0 then return [lib.mem.ptr(lib.store.post)].null() end
defer r:free()
var p = row_to_post(&r, 0)
p.ptr.source = src
return p
end];
post_act_cancel = [terra(
src: &lib.store.source,
................................................................................
r = queries.timeline_instance_fetch.exec(src,A,B,C,D)
var ret: lib.mem.ptr(lib.mem.ptr(lib.store.post)) ret:init(r.sz)
for i=0,r.sz do
ret.ptr[i] = row_to_post(&r, i) -- MUST FREE ALL
ret.ptr[i].ptr.source = src
end
r:free()
return ret
end];
timeline_circle_fetch = [terra(
src: &lib.store.source,
cid: uint64,
................................................................................
r = queries.timeline_circle_fetch.exec(src,cid,A,B,C,D)
var ret: lib.mem.ptr(lib.mem.ptr(lib.store.post)) ret:init(r.sz)
for i=0,r.sz do
ret.ptr[i] = row_to_post(&r, i) -- MUST FREE ALL
ret.ptr[i].ptr.source = src
end
r:free()
return ret
end];
timeline_actor_fetch_uid = [terra(
src: &lib.store.source,
uid: uint64,
................................................................................
r = queries.timeline_actor_fetch.exec(src,uid,A,B,C,D)
var ret: lib.mem.ptr(lib.mem.ptr(lib.store.post)) ret:init(r.sz)
for i=0,r.sz do
ret.ptr[i] = row_to_post(&r, i) -- MUST FREE ALL
ret.ptr[i].ptr.source = src
end
r:free()
return ret
end];
post_enum_author_uid = [terra(
src: &lib.store.source,
uid: uint64,
................................................................................
r = queries.post_enum_author_uid.exec(src,A,B,C,D,uid)
var ret: lib.mem.ptr(lib.mem.ptr(lib.store.post)) ret:init(r.sz)
for i=0,r.sz do
ret.ptr[i] = row_to_post(&r, i) -- MUST FREE ALL
ret.ptr[i].ptr.source = src
end
r:free()
return ret
end];
actor_powers_fetch = getpow;
actor_save = [terra(
src: &lib.store.source,
................................................................................
ac.id = r:int(uint64,0,0)
-- check against default rights, insert records for wherever powers differ
lib.dbg('created new actor, establishing powers')
privupdate(src,ac)
lib.dbg('powers established')
r:free()
return ac.id
end];
actor_rel_create = [terra(
src: &lib.store.source,
kind: uint16,
relator: uint64,
................................................................................
auth_fetch_aid = [terra(
src: &lib.store.source,
aid: uint64
): lib.mem.ptr(lib.store.auth)
var r = queries.auth_fetch_aid.exec(src,aid)
if r.sz == 0 then return [lib.mem.ptr(lib.store.auth)].null() end
defer r:free()
var kind = r:_string(0, 2)
var comment = r:_string(0, 3)
var a = [ lib.str.encapsulate(lib.store.auth, {
kind = {`kind.ptr, `kind.ct+1};
comment = {`comment.ptr, `comment.ct+1};
}) ]
a.ptr.aid = r:int(uint64, 0, 0)
................................................................................
auth_enum_uid = [terra(
src: &lib.store.source,
uid: uint64
): lib.mem.lstptr(lib.store.auth)
var r = queries.auth_enum_uid.exec(src,uid)
if r.sz == 0 then return [lib.mem.lstptr(lib.store.auth)].null() end
defer r:free()
var ret = lib.mem.heapa([lib.mem.ptr(lib.store.auth)], r.sz)
for i=0, r.sz do
var kind = r:_string(i, 1)
var comment = r:_string(i, 2)
var a = [ lib.str.encapsulate(lib.store.auth, {
kind = {`kind.ptr, `kind.ct+1};
comment = {`comment.ptr, `comment.ct+1};
................................................................................
artifact_enum_uid = [terra(
src: &lib.store.source,
uid: uint64,
folder: pstring
)
var res = queries.artifact_enum_uid.exec(src,uid,folder)
if res.sz > 0 then defer res:free()
var m = lib.mem.heapa([lib.mem.ptr(lib.store.artifact)], res.sz)
for i=0,res.sz do
m.ptr[i] = row_to_artifact(&res, i)
m(i).ptr.owner = uid
end
return m
else return [lib.mem.lstptr(lib.store.artifact)].null() end
................................................................................
actor_conf_str_enum = nil;
actor_conf_str_get = [terra(
src: &lib.store.source,
pool: &lib.mem.pool,
uid: uint64,
key: pstring
): pstring
var r = queries.actor_conf_str_get.exec(src, uid, key)
if r.sz > 0 then defer r:free()
return r:_string(0,0):pdup(pool)
else return pstring.null() end
end];
actor_conf_str_set = [terra(src: &lib.store.source, uid: uint64, key: pstring, value: pstring): {}
queries.actor_conf_str_set.exec(src,uid,key,value) end];
actor_conf_str_reset = [terra(src: &lib.store.source, uid: uint64, key: pstring): {}
queries.actor_conf_str_reset.exec(src,uid,key) end];
actor_conf_int_enum = nil;
actor_conf_int_get = [terra(src: &lib.store.source, uid: uint64, key: pstring)
var r = queries.actor_conf_int_get.exec(src, uid, key)
if r.sz > 0 then
var ret = r:int(uint64,0,0)
r:free()
|