1996-07-09 08:22:35 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1999-02-14 00:22:53 +01:00
|
|
|
* misc.c
|
1997-09-07 07:04:48 +02:00
|
|
|
*
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
2002-06-20 22:29:54 +02:00
|
|
|
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
2000-01-26 06:58:53 +01:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* IDENTIFICATION
|
2003-06-27 16:45:32 +02:00
|
|
|
* $Header: /cvsroot/pgsql/src/backend/utils/adt/misc.c,v 1.29 2003/06/27 14:45:30 petere Exp $
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2002-09-02 04:47:07 +02:00
|
|
|
#include "postgres.h"
|
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
#include <sys/file.h>
|
1998-06-09 21:20:59 +02:00
|
|
|
#include <time.h>
|
2000-06-05 09:29:25 +02:00
|
|
|
|
2002-08-20 06:46:00 +02:00
|
|
|
#include "miscadmin.h"
|
1996-07-09 08:22:35 +02:00
|
|
|
#include "utils/builtins.h"
|
|
|
|
|
2000-06-05 09:29:25 +02:00
|
|
|
|
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* Check if data is Null
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
2000-06-05 09:29:25 +02:00
|
|
|
Datum
|
|
|
|
nullvalue(PG_FUNCTION_ARGS)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
2000-06-05 09:29:25 +02:00
|
|
|
if (PG_ARGISNULL(0))
|
|
|
|
PG_RETURN_BOOL(true);
|
|
|
|
PG_RETURN_BOOL(false);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
2000-06-05 09:29:25 +02:00
|
|
|
/*
|
|
|
|
* Check if data is not Null
|
|
|
|
*/
|
|
|
|
Datum
|
|
|
|
nonnullvalue(PG_FUNCTION_ARGS)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
2000-06-05 09:29:25 +02:00
|
|
|
if (PG_ARGISNULL(0))
|
|
|
|
PG_RETURN_BOOL(false);
|
|
|
|
PG_RETURN_BOOL(true);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
2002-08-20 06:46:00 +02:00
|
|
|
/*
|
|
|
|
* current_database()
|
|
|
|
* Expose the current database to the user
|
|
|
|
*/
|
|
|
|
Datum
|
|
|
|
current_database(PG_FUNCTION_ARGS)
|
|
|
|
{
|
2002-09-04 22:31:48 +02:00
|
|
|
Name db;
|
2002-08-20 06:46:00 +02:00
|
|
|
|
|
|
|
db = (Name) palloc(NAMEDATALEN);
|
|
|
|
|
2003-06-27 16:45:32 +02:00
|
|
|
namestrcpy(db, get_database_name(MyDatabaseId));
|
2002-08-20 06:46:00 +02:00
|
|
|
PG_RETURN_NAME(db);
|
|
|
|
}
|