diff --git a/.gitattributes b/.gitattributes index 6bb4c4291901bed32a4daf9be020a6a5b5a60b92..c43dc1b497c7ac026f83f85064642ad3c6da9f0b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -78,6 +78,7 @@ testfont binary /lib/modules/Sql.pmod/postgres.pike foreign_ident /lib/modules/Sql.pmod/sql.pike foreign_ident /lib/modules/Sql.pmod/sql_result.pike foreign_ident +/lib/modules/Sql.pmod/sql_util.pmod foreign_ident /lib/modules/Stdio.pmod foreign_ident /lib/modules/Stdio.pmod/Readline.pike foreign_ident /lib/modules/Stdio.pmod/Terminfo.pmod foreign_ident diff --git a/lib/modules/Sql.pmod/sql.pike b/lib/modules/Sql.pmod/sql.pike index 13710a04148fbc819369d2fc980c2e1d33c32751..a8363d02a063f7df16054285b00823d30dd2fe4d 100644 --- a/lib/modules/Sql.pmod/sql.pike +++ b/lib/modules/Sql.pmod/sql.pike @@ -1,5 +1,5 @@ /* - * $Id: sql.pike,v 1.32 1999/07/01 02:16:00 per Exp $ + * $Id: sql.pike,v 1.33 1999/07/01 20:13:40 grubba Exp $ * * Implements the generic parts of the SQL-interface * @@ -8,7 +8,7 @@ //. //. File: sql.pike -//. RCSID: $Id: sql.pike,v 1.32 1999/07/01 02:16:00 per Exp $ +//. RCSID: $Id: sql.pike,v 1.33 1999/07/01 20:13:40 grubba Exp $ //. Author: Henrik Grubbström (grubba@idonex.se) //. //. Synopsis: Implements the generic parts of the SQL-interface. @@ -35,11 +35,7 @@ int case_convert; //. - quote //. Quote a string so that it can safely be put in a query. //. > s - String to quote. -function(string:string) quote = lambda (string s) -{ - // This lambda is overridden from master_sql in create(). - return(replace(s, "\'", "\'\'")); -}; +function(string:string) quote = .sql_util.quote; //. - encode_time //. Converts a system time value to an appropriately formatted time @@ -258,15 +254,13 @@ void create(void|string|object host, void|string db, } } - function fallback = - lambda () {throw_error ("Function not supported in this database.");}; if (master_sql->quote) quote = master_sql->quote; - encode_time = master_sql->encode_time || fallback; - decode_time = master_sql->decode_time || fallback; - encode_date = master_sql->encode_date || fallback; - decode_date = master_sql->decode_date || fallback; - encode_datetime = master_sql->encode_datetime || fallback; - decode_datetime = master_sql->decode_datetime || fallback; + encode_time = master_sql->encode_time || .sql_util.fallback; + decode_time = master_sql->decode_time || .sql_util.fallback; + encode_date = master_sql->encode_date || .sql_util.fallback; + decode_date = master_sql->decode_date || .sql_util.fallback; + encode_datetime = master_sql->encode_datetime || .sql_util.fallback; + decode_datetime = master_sql->decode_datetime || .sql_util.fallback; } static private array(mapping(string:mixed)) res_obj_to_array(object res_obj) diff --git a/lib/modules/Sql.pmod/sql_util.pmod b/lib/modules/Sql.pmod/sql_util.pmod new file mode 100644 index 0000000000000000000000000000000000000000..c2db2709debc23d31aa61f268e562e743f9fd64e --- /dev/null +++ b/lib/modules/Sql.pmod/sql_util.pmod @@ -0,0 +1,37 @@ +/* + * $Id: sql_util.pmod,v 1.1 1999/07/01 20:13:41 grubba Exp $ + * + * Some SQL utility functions. + * They are kept here to avoid circular references. + * + * Henrik Grubbström 1999-07-01 + */ + +//. +//. File: sql_util.pmod +//. RCSID: $Id: sql_util.pmod,v 1.1 1999/07/01 20:13:41 grubba Exp $ +//. Author: Henrik Grubbström (grubba@idonex.se) +//. +//. Synopsis: Some SQL utility functions +//. +//. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +//. +//. These functions are kept here mainly to avoid circular references. +//. + +#define throw_error(X) throw(({ (X), backtrace() })) + +//. - quote +//. Quote a string so that it can safely be put in a query. +//. > s - String to quote. +string quote(string s) +{ + return(replace(s, "\'", "\'\'")); +} + +//. - fallback +//. Throw an error in case an unimplemented function is called. +void fallback(void) +{ + throw_error ("Function not supported in this database."); +}