|
|
| version 1.37, 2007/02/03 18:08:38 | version 1.40, 2008/07/18 08:24:35 |
|---|---|
| Line 44 static void _length(Request& r, MethodPa | Line 44 static void _length(Request& r, MethodPa |
| static void _pos(Request& r, MethodParams& params) { | static void _pos(Request& r, MethodParams& params) { |
| // just checking for consistency | // just checking for consistency |
| params.as_no_junction(0, "substr must not be code"); | params.as_no_junction(0, "substr must not be code"); |
| if(params.count()>1){ | |
| ssize_t offset=params.as_int(1, "n must be int", r); | |
| if(offset<0) | |
| throw Exception(PARSER_RUNTIME, | |
| 0, | |
| "n(%d) must be >=0", offset); | |
| } | |
| // never found | // never found |
| r.write_no_lang(*new VInt(-1)); | r.write_no_lang(*new VInt(-1)); |
| } | } |
| Line 74 public: | Line 81 public: |
| bool add_column(SQL_Error& /*error*/, const char* /*str*/, size_t /*length*/) { /* ignore */ return false; } | bool add_column(SQL_Error& /*error*/, const char* /*str*/, size_t /*length*/) { /* ignore */ return false; } |
| bool before_rows(SQL_Error& error) { | bool before_rows(SQL_Error& error) { |
| // there are some result rows, which is wrong | // there are some result rows, which is wrong |
| error=SQL_Error("parser.runtime", | error=SQL_Error(PARSER_RUNTIME, |
| /*statement_string,*/ | /*statement_string,*/ |
| "must return nothing"); | "must return nothing"); |
| return true; | return true; |
| Line 102 static void _sql(Request& r, MethodParam | Line 109 static void _sql(Request& r, MethodParam |
| bind=vbind->get_hash(); | bind=vbind->get_hash(); |
| } | } |
| if(valid_options!=options->count()) | if(valid_options!=options->count()) |
| throw Exception("parser.runtime", | throw Exception(PARSER_RUNTIME, |
| 0, | 0, |
| "called with invalid option"); | "called with invalid option"); |
| } else | } else |
| throw Exception("parser.runtime", | throw Exception(PARSER_RUNTIME, |
| 0, | 0, |
| "options must be hash"); | "options must be hash"); |
| } | } |
| Line 124 static void _sql(Request& r, MethodParam | Line 131 static void _sql(Request& r, MethodParam |
| r.connection()->query( | r.connection()->query( |
| statement_cstr, | statement_cstr, |
| placeholders_count, placeholders, | placeholders_count, placeholders, |
| 0, 0, | 0, SQL_NO_LIMIT, |
| handlers, | handlers, |
| statement_string); | statement_string); |
| Line 135 static void _sql(Request& r, MethodParam | Line 142 static void _sql(Request& r, MethodParam |
| static void _left_right(Request& r, MethodParams& params) { | static void _left_right(Request& r, MethodParams& params) { |
| ssize_t sn=params.as_int(0, "n must be int", r); | ssize_t sn=params.as_int(0, "n must be int", r); |
| if(sn<0) | if(sn<0) |
| throw Exception("parser.runtime", | throw Exception(PARSER_RUNTIME, |
| 0, | 0, |
| "n(%d) must be >=0", sn); | "n(%d) must be >=0", sn); |
| Line 145 static void _left_right(Request& r, Meth | Line 152 static void _left_right(Request& r, Meth |
| static void _mid(Request& r, MethodParams& params) { | static void _mid(Request& r, MethodParams& params) { |
| ssize_t sbegin=params.as_int(0, "p must be int", r); | ssize_t sbegin=params.as_int(0, "p must be int", r); |
| if(sbegin<0) | if(sbegin<0) |
| throw Exception("parser.runtime", | throw Exception(PARSER_RUNTIME, |
| 0, | 0, |
| "p(%d) must be >=0", sbegin); | "p(%d) must be >=0", sbegin); |
| if(params.count()>1) { | if(params.count()>1) { |
| ssize_t sn=params.as_int(1, "n must be int", r); | ssize_t sn=params.as_int(1, "n must be int", r); |
| if(sn<0) | if(sn<0) |
| throw Exception("parser.runtime", | throw Exception(PARSER_RUNTIME, |
| 0, | 0, |
| "n(%d) must be >=0", sn); | "n(%d) must be >=0", sn); |
| } | } |
| Line 167 MVoid::MVoid(): Methoded("void") { | Line 174 MVoid::MVoid(): Methoded("void") { |
| add_native_method("length", Method::CT_DYNAMIC, _length, 0, 0); | add_native_method("length", Method::CT_DYNAMIC, _length, 0, 0); |
| // ^void.pos[substr] | // ^void.pos[substr] |
| add_native_method("pos", Method::CT_DYNAMIC, _pos, 1, 1); | add_native_method("pos", Method::CT_DYNAMIC, _pos, 1, 2); |
| // ^void.int[] | // ^void.int[] |
| // ^void.int(default) | // ^void.int(default) |