--- parser3/src/classes/table.C 2002/08/07 10:25:56 1.158 +++ parser3/src/classes/table.C 2002/08/15 10:38:18 1.160 @@ -5,7 +5,7 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char* IDENT_TABLE_C="$Date: 2002/08/07 10:25:56 $"; +static const char* IDENT_TABLE_C="$Date: 2002/08/15 10:38:18 $"; #include "classes.h" #include "pa_common.h" @@ -178,7 +178,7 @@ static void _save(Request& r, const Stri Value& vfile_name=params->as_no_junction(params->size()-1, "file name must not be code"); - Table& table=static_cast(r.self)->table(); + Table& table=static_cast(r.self)->table(&method_name); bool do_append=false; String sdata(pool); @@ -236,19 +236,19 @@ static void _save(Request& r, const Stri static void _count(Request& r, const String& method_name, MethodParams *) { Pool& pool=r.pool(); - int result=static_cast(r.self)->table().size(); + int result=static_cast(r.self)->table(&method_name).size(); r.write_no_lang(*new(pool) VInt(pool, result)); } static void _line(Request& r, const String& method_name, MethodParams *) { Pool& pool=r.pool(); - int result=1+static_cast(r.self)->table().current(); + int result=1+static_cast(r.self)->table(&method_name).current(); r.write_no_lang(*new(pool) VInt(pool, result)); } static void _offset(Request& r, const String& method_name, MethodParams *params) { Pool& pool=r.pool(); - Table& table=static_cast(r.self)->table(); + Table& table=static_cast(r.self)->table(&method_name); if(params->size()) { bool absolute=false; if(params->size()>1) { @@ -274,7 +274,7 @@ static void _menu(Request& r, const Stri Value *delim_maybe_code=params->size()>1?¶ms->get(1):0; - Table& table=static_cast(r.self)->table(); + Table& table=static_cast(r.self)->table(&method_name); bool need_delim=false; int saved_current=table.current(); int size=table.size(); @@ -322,7 +322,7 @@ static void table_row_to_hash(Array::Ite } static void _hash(Request& r, const String& method_name, MethodParams *params) { Pool& pool=r.pool(); - Table& self_table=static_cast(r.self)->table(); + Table& self_table=static_cast(r.self)->table(&method_name); Value& result=*new(pool) VHash(pool); if(const Array *columns=self_table.columns()) if(columns->size()>0) { @@ -391,7 +391,7 @@ static void _sort(Request& r, const Stri reverse=params->as_no_junction(1, "order must not be code").as_string()=="desc": false; // default=asc - Table& old_table=static_cast(r.self)->table(); + Table& old_table=static_cast(r.self)->table(&method_name); Table& new_table=*new(pool) Table(pool, &method_name, old_table.columns()); Table_seq_item *seq=(Table_seq_item *)pool.malloc(sizeof(Table_seq_item)*old_table.size()); @@ -436,7 +436,7 @@ static bool _locate_expression(Request& Value& expression_code=params->as_junction(0, "must be expression"); - Table& table=static_cast(r.self)->table(); + Table& table=static_cast(r.self)->table(&method_name); int saved_current=table.current(); int size=table.size(); for(int row=0; row(r.self)->table(); + Table& table=static_cast(r.self)->table(&method_name); return table.locate( params->as_string(0, "column name must be string"), params->as_string(1, "value must be string") @@ -470,7 +470,7 @@ static void _locate(Request& r, const St static void _flip(Request& r, const String& method_name, MethodParams *params) { Pool& pool=r.pool(); - Table& old_table=static_cast(r.self)->table(); + Table& old_table=static_cast(r.self)->table(&method_name); Table& new_table=*new(pool) Table(pool, &method_name, 0/*nameless*/); if(old_table.size()) if(int old_cols=old_table.at(0).size()) @@ -497,7 +497,7 @@ static void _append(Request& r, const St Array& row=*new(pool) Array(pool); string.split(row, 0, "\t", 1, String::UL_AS_IS); - static_cast(r.self)->table()+=&row; + static_cast(r.self)->table(&method_name)+=&row; } static void _join(Request& r, const String& method_name, MethodParams *params) { @@ -510,7 +510,7 @@ static void _join(Request& r, const Stri "source is not a table"); Table& src=*maybe_src; - Table& dest=static_cast(r.self)->table(); + Table& dest=static_cast(r.self)->table(&method_name); if(&src == &dest) throw Exception("parser.runtime", &method_name, @@ -616,15 +616,15 @@ static void _sql(Request& r, const Strin statement_string.cstr(String::UL_UNSPECIFIED, r.connection(&method_name)); Table_sql_event_handlers handlers(pool, method_name, statement_string, statement_cstr); - try { #ifdef RESOURCES_DEBUG struct timeval mt[2]; //measure:before gettimeofday(&mt[0],NULL); #endif - r.connection(&method_name)->query( - statement_cstr, offset, limit, - handlers); + r.connection(&method_name)->query( + statement_cstr, offset, limit, + handlers, + statement_string); #ifdef RESOURCES_DEBUG //measure:after connect @@ -636,12 +636,6 @@ static void _sql(Request& r, const Strin r.sql_request_time+=t[1]-t[0]; #endif - } catch(const Exception& e) { // query problem - // more specific source [were url] - throw Exception("sql.execute", - &statement_string, - "%s", e.comment()); - } Table *result= handlers.table?handlers.table: // query resulted in table? return it @@ -658,7 +652,7 @@ static void _columns(Request& r, const S result_columns+=new(pool) String(pool, "column"); Table& result_table=*new(pool) Table(pool, &method_name, &result_columns); - Table& source_table=static_cast(r.self)->table(); + Table& source_table=static_cast(r.self)->table(&method_name); if(const Array *source_columns=source_table.columns()) { Array_iter i(*source_columns); while(i.has_next()) { @@ -676,7 +670,7 @@ static void _select(Request& r, const St Value& vcondition=params->as_junction(0, "condition must be expression"); - Table& source_table=static_cast(r.self)->table(); + Table& source_table=static_cast(r.self)->table(&method_name); Table& result_table=*new(pool) Table(pool, source_table.origin_string(), source_table.columns()