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
  
106
  
107
  
108
  
109
  
110
  
111
  
112
  
113
  
114
  
115
  
/* 
 * Sybase driver for the Pike programming language. 
 * By Francesco Chemolli <kinkie@roxen.com> 10/12/1999 
 * 
 */ 
 
#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(sybase.sybase) 
 
inherit sybase.sybase:mo; 
#define THROW(X) throw(({X+"\n",backtrace()})) 
 
 
/* 
 * Deprecated. Use connect(host,db,user,pass) instead. 
 */ 
void select_db(string db) 
{ 
  mo::big_query("use "+db); 
} 
 
/* 
 * Deprecated. Use an SQL command instead. 
 */ 
void create_db (string dbname) { 
  mo::big_query("create database "+dbname); 
} 
 
/* 
 * Deprecated. Use an SQL command instead. 
 */ 
void drop_db (string dbname) { 
  mo::big_query("drop database "+dbname); 
} 
 
void shutdown() { 
  catch { //there _will_ be an error. It's just that we don't care about it. 
    mo::big_query("shutdown"); 
  }; 
} 
 
string server_info () { 
  return "sybase/10.X or 11.X"; 
} 
 
/* 
 * Unimplemented. Anyone knows Transact-SQL well enough? 
 * maybe we could use the connection properties otherwise (CS_HOSTNAME) 
 */ 
string host_info() { 
  return "unknown"; 
} 
 
/* 
 * Unimplemented. Anyone knows Transact-SQL well enough? 
 */ 
array(string) list_dbs(string|void wild) { 
  THROW("Unsupported"); 
} 
 
/* 
 * Unimplemented. PLEASE tell me somebody knows how to do this. 
 * There MUST be some system stored procedure... 
 */ 
array(string) list_tables(string|void wild) { 
  THROW("Unsupported"); 
} 
 
/* 
 * Unimplemented. 
 */ 
array(string) list_fields(string|void wild) { 
  THROW("Unsupported"); 
} 
 
int num_rows() { 
  THROW("Unsupported by the DB server"); 
} 
 
void seek(int skipthismany) { 
  if (skipthismany<0) 
    THROW("Negative skips are not supported"); 
  if (!skipthismany) 
    return; 
  while (skipthismany && fetch_row()){ 
    skipthismany--; 
  } 
} 
 
void create(void|string host, void|string db, void|string user, 
            void|string _pass, void|mapping options) { 
  string pass = _pass; 
  _pass = "CENSORED"; 
  mo::create(host||"",db||"",user||"",pass||"",options); 
  if (db && stringp(db) && sizeof(db)) { 
    mo::big_query("use "+db); 
  } 
} 
 
int|object big_query(string q, mapping(string|int:mixed)|void bindings) { 
  if (!bindings) 
    return ::big_query(q); 
  return ::big_query(.sql_util.emulate_bindings(q,bindings,this)); 
} 
 
#else 
constant this_program_does_not_exist=1; 
#endif