diff -ur src_orig/modules/Postgres/pg_types.h src/modules/Postgres/pg_types.h --- src_orig/modules/Postgres/pg_types.h Mon Jan 16 10:54:24 2006 +++ src/modules/Postgres/pg_types.h Mon Jan 16 11:44:49 2006 @@ -31,7 +31,7 @@ }; /* The header name could be deceiving, but who cares? */ -extern struct program *postgres_program, *pgresult_program; +extern struct program *postgres_program, *pgresult_program, *NULL_program; #define FETCHSIZESTR "64" #define CURSORNAME "_pikecursor" diff -ur src_orig/modules/Postgres/pgresult.c src/modules/Postgres/pgresult.c --- src_orig/modules/Postgres/pgresult.c Mon Jan 16 10:54:24 2006 +++ src/modules/Postgres/pgresult.c Mon Jan 16 12:11:07 2006 @@ -367,7 +367,11 @@ break; #endif } - push_string(make_shared_binary_string(value,k)); + if (PQgetisnull(THIS->result, THIS->cursor, j)) { + push_object(clone_object(NULL_program, 0)); + } else { + push_string(make_shared_binary_string(value,k)); + } if(binbuf) free(binbuf); } diff -ur src_orig/modules/Postgres/postgres.c src/modules/Postgres/postgres.c --- src_orig/modules/Postgres/postgres.c Mon Jan 16 10:54:24 2006 +++ src/modules/Postgres/postgres.c Mon Jan 16 12:59:44 2006 @@ -71,6 +71,7 @@ #endif struct program * postgres_program; +struct program * NULL_program; static void set_error (char * newerror) { @@ -735,6 +736,12 @@ *! @endmodule */ +static void NULL_not(INT32 args) +{ + pop_n_elems(args); + push_int(1); +} + PIKE_MODULE_INIT { start_new_program(); @@ -785,6 +792,11 @@ postgres_program = end_program(); add_program_constant("postgres",postgres_program,0); + start_new_program(); + ADD_FUNCTION("`!", NULL_not, tFunc(tVoid, tInt), 0); + NULL_program = end_program(); + add_program_constant("NULL",NULL_program,0); + add_string_constant("version",PGSQL_VERSION,0); pgresult_init(); @@ -804,6 +816,11 @@ { free_program(pgresult_program); pgresult_program=0; + } + if(NULL_program) + { + free_program(NULL_program); + pgresult_program=NULL; } }