/usr/lib/pike7.8/modules/Sql.pmod/sqlite.pike is in pike7.8-sqlite 7.8.866-8.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | #pike __REAL_VERSION__
// Cannot dump this since the #if constant(...) check below may depend
// on the presence of system libs at runtime.
constant dont_dump_program = 1;
#if constant(SQLite.SQLite)
inherit SQLite.SQLite;
void create(string a, void|string b, void|mixed c, void|mixed d,
void|mapping options) {
if(b) a += "/"+b;
::create(a);
}
array list_fields(string n, string|void wild)
{
string qry = "";
qry = "PRAGMA table_info(" + n + ")";
array r = query(qry);
// now, we weed out the ones that don't match wild, if provided
if(wild)
{
r = filter(r, lambda(mapping row)
{ return (search(row->name, wild) !=-1); }
);
}
array fields = ({});
foreach(r;; mapping f)
{
mapping fld = ([]);
fld->name = f->name;
fld->table = n;
string t, l;
if(!sscanf(f->type, "%s(%s)", t, l))
t = f->type;
fld->length = (int)l;
switch(t)
{
case "char":
t = "string";
break;
case "int":
t = "integer";
break;
}
fld->type = t;
fld->flags = (<>);
if((int)f->notnull)
fld->flags->not_null = 1;
if((int)f->pk)
{
// primary key implies not null.
fld->flags->not_null = 1;
fld->flags->primary_key = 1;
}
fld->default = f->dflt_value;
fields += ({fld});
}
return fields;
}
array list_tables(string|void n)
{
string qry = "";
if(n)
qry = "SELECT name FROM SQLITE_MASTER WHERE name like '" + n + "%' and TYPE='table'";
else
qry = "SELECT name FROM SQLITE_MASTER where TYPE='table'";
array r = query(qry);
array out = ({});
foreach(r;;mapping row)
{
if(row->name)
out += ({row->name});
else
out += ({row["sqlite_master.name"] });
}
return out;
}
#else
constant this_program_does_not_exist=1;
#endif
|