mirror of
https://github.com/postgres/postgres.git
synced 2025-06-05 23:56:58 +03:00
Simplify and standardize conversions between TEXT datums and ordinary C
strings. This patch introduces four support functions cstring_to_text, cstring_to_text_with_len, text_to_cstring, and text_to_cstring_buffer, and two macros CStringGetTextDatum and TextDatumGetCString. A number of existing macros that provided variants on these themes were removed. Most of the places that need to make such conversions now require just one function or macro call, in place of the multiple notational layers that used to be needed. There are no longer any direct calls of textout or textin, and we got most of the places that were using handmade conversions via memcpy (there may be a few still lurking, though). This commit doesn't make any serious effort to eliminate transient memory leaks caused by detoasting toasted text objects before they reach text_to_cstring. We changed PG_GETARG_TEXT_P to PG_GETARG_TEXT_PP in a few places where it was easy, but much more could be done. Brendan Jurd and Tom Lane
This commit is contained in:
parent
f948197b40
commit
220db7ccd8
@ -8,7 +8,7 @@
|
|||||||
* Author: Andreas Pflug <pgadmin@pse-consulting.de>
|
* Author: Andreas Pflug <pgadmin@pse-consulting.de>
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/contrib/adminpack/adminpack.c,v 1.10 2008/01/01 19:45:45 momjian Exp $
|
* $PostgreSQL: pgsql/contrib/adminpack/adminpack.c,v 1.11 2008/03/25 22:42:41 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -23,6 +23,7 @@
|
|||||||
#include "miscadmin.h"
|
#include "miscadmin.h"
|
||||||
#include "postmaster/syslogger.h"
|
#include "postmaster/syslogger.h"
|
||||||
#include "storage/fd.h"
|
#include "storage/fd.h"
|
||||||
|
#include "utils/builtins.h"
|
||||||
#include "utils/datetime.h"
|
#include "utils/datetime.h"
|
||||||
|
|
||||||
|
|
||||||
@ -68,11 +69,7 @@ typedef struct
|
|||||||
static char *
|
static char *
|
||||||
convert_and_check_filename(text *arg, bool logAllowed)
|
convert_and_check_filename(text *arg, bool logAllowed)
|
||||||
{
|
{
|
||||||
int input_len = VARSIZE(arg) - VARHDRSZ;
|
char *filename = text_to_cstring(arg);
|
||||||
char *filename = palloc(input_len + 1);
|
|
||||||
|
|
||||||
memcpy(filename, VARDATA(arg), input_len);
|
|
||||||
filename[input_len] = '\0';
|
|
||||||
|
|
||||||
canonicalize_path(filename); /* filename can change length here */
|
canonicalize_path(filename); /* filename can change length here */
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* darcy@druid.net
|
* darcy@druid.net
|
||||||
* http://www.druid.net/darcy/
|
* http://www.druid.net/darcy/
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/contrib/chkpass/chkpass.c,v 1.19 2007/02/27 23:48:05 tgl Exp $
|
* $PostgreSQL: pgsql/contrib/chkpass/chkpass.c,v 1.20 2008/03/25 22:42:41 tgl Exp $
|
||||||
* best viewed with tabs set to 4
|
* best viewed with tabs set to 4
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -17,6 +17,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "fmgr.h"
|
#include "fmgr.h"
|
||||||
|
#include "utils/builtins.h"
|
||||||
|
|
||||||
PG_MODULE_MAGIC;
|
PG_MODULE_MAGIC;
|
||||||
|
|
||||||
@ -124,15 +125,8 @@ Datum
|
|||||||
chkpass_rout(PG_FUNCTION_ARGS)
|
chkpass_rout(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
chkpass *password = (chkpass *) PG_GETARG_POINTER(0);
|
chkpass *password = (chkpass *) PG_GETARG_POINTER(0);
|
||||||
text *result;
|
|
||||||
int slen;
|
|
||||||
|
|
||||||
slen = strlen(password->password);
|
PG_RETURN_TEXT_P(cstring_to_text(password->password));
|
||||||
result = (text *) palloc(VARHDRSZ + slen);
|
|
||||||
SET_VARSIZE(result, VARHDRSZ + slen);
|
|
||||||
memcpy(VARDATA(result), password->password, slen);
|
|
||||||
|
|
||||||
PG_RETURN_TEXT_P(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -145,13 +139,10 @@ Datum
|
|||||||
chkpass_eq(PG_FUNCTION_ARGS)
|
chkpass_eq(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
chkpass *a1 = (chkpass *) PG_GETARG_POINTER(0);
|
chkpass *a1 = (chkpass *) PG_GETARG_POINTER(0);
|
||||||
text *a2 = (text *) PG_GETARG_TEXT_P(1);
|
text *a2 = PG_GETARG_TEXT_PP(1);
|
||||||
char str[10];
|
char str[9];
|
||||||
int sz;
|
|
||||||
|
|
||||||
sz = Min(VARSIZE(a2) - VARHDRSZ, 8);
|
text_to_cstring_buffer(a2, str, sizeof(str));
|
||||||
memcpy(str, VARDATA(a2), sz);
|
|
||||||
str[sz] = '\0';
|
|
||||||
PG_RETURN_BOOL(strcmp(a1->password, crypt(str, a1->password)) == 0);
|
PG_RETURN_BOOL(strcmp(a1->password, crypt(str, a1->password)) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,12 +151,9 @@ Datum
|
|||||||
chkpass_ne(PG_FUNCTION_ARGS)
|
chkpass_ne(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
chkpass *a1 = (chkpass *) PG_GETARG_POINTER(0);
|
chkpass *a1 = (chkpass *) PG_GETARG_POINTER(0);
|
||||||
text *a2 = (text *) PG_GETARG_TEXT_P(1);
|
text *a2 = PG_GETARG_TEXT_PP(1);
|
||||||
char str[10];
|
char str[9];
|
||||||
int sz;
|
|
||||||
|
|
||||||
sz = Min(VARSIZE(a2) - VARHDRSZ, 8);
|
text_to_cstring_buffer(a2, str, sizeof(str));
|
||||||
memcpy(str, VARDATA(a2), sz);
|
|
||||||
str[sz] = '\0';
|
|
||||||
PG_RETURN_BOOL(strcmp(a1->password, crypt(str, a1->password)) != 0);
|
PG_RETURN_BOOL(strcmp(a1->password, crypt(str, a1->password)) != 0);
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
* Darko Prenosil <Darko.Prenosil@finteh.hr>
|
* Darko Prenosil <Darko.Prenosil@finteh.hr>
|
||||||
* Shridhar Daithankar <shridhar_daithankar@persistent.co.in>
|
* Shridhar Daithankar <shridhar_daithankar@persistent.co.in>
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/contrib/dblink/dblink.c,v 1.69 2008/01/14 02:49:47 tgl Exp $
|
* $PostgreSQL: pgsql/contrib/dblink/dblink.c,v 1.70 2008/03/25 22:42:41 tgl Exp $
|
||||||
* Copyright (c) 2001-2008, PostgreSQL Global Development Group
|
* Copyright (c) 2001-2008, PostgreSQL Global Development Group
|
||||||
* ALL RIGHTS RESERVED;
|
* ALL RIGHTS RESERVED;
|
||||||
*
|
*
|
||||||
@ -116,8 +116,6 @@ typedef struct remoteConnHashEnt
|
|||||||
#define NUMCONN 16
|
#define NUMCONN 16
|
||||||
|
|
||||||
/* general utility */
|
/* general utility */
|
||||||
#define GET_TEXT(cstrp) DatumGetTextP(DirectFunctionCall1(textin, CStringGetDatum(cstrp)))
|
|
||||||
#define GET_STR(textp) DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(textp)))
|
|
||||||
#define xpfree(var_) \
|
#define xpfree(var_) \
|
||||||
do { \
|
do { \
|
||||||
if (var_ != NULL) \
|
if (var_ != NULL) \
|
||||||
@ -171,7 +169,7 @@ typedef struct remoteConnHashEnt
|
|||||||
|
|
||||||
#define DBLINK_GET_CONN \
|
#define DBLINK_GET_CONN \
|
||||||
do { \
|
do { \
|
||||||
char *conname_or_str = GET_STR(PG_GETARG_TEXT_P(0)); \
|
char *conname_or_str = text_to_cstring(PG_GETARG_TEXT_PP(0)); \
|
||||||
rconn = getConnectionByName(conname_or_str); \
|
rconn = getConnectionByName(conname_or_str); \
|
||||||
if(rconn) \
|
if(rconn) \
|
||||||
{ \
|
{ \
|
||||||
@ -197,7 +195,7 @@ typedef struct remoteConnHashEnt
|
|||||||
|
|
||||||
#define DBLINK_GET_NAMED_CONN \
|
#define DBLINK_GET_NAMED_CONN \
|
||||||
do { \
|
do { \
|
||||||
char *conname = GET_STR(PG_GETARG_TEXT_P(0)); \
|
char *conname = text_to_cstring(PG_GETARG_TEXT_PP(0)); \
|
||||||
rconn = getConnectionByName(conname); \
|
rconn = getConnectionByName(conname); \
|
||||||
if(rconn) \
|
if(rconn) \
|
||||||
conn = rconn->conn; \
|
conn = rconn->conn; \
|
||||||
@ -234,11 +232,11 @@ dblink_connect(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
if (PG_NARGS() == 2)
|
if (PG_NARGS() == 2)
|
||||||
{
|
{
|
||||||
connstr = GET_STR(PG_GETARG_TEXT_P(1));
|
connstr = text_to_cstring(PG_GETARG_TEXT_PP(1));
|
||||||
connname = GET_STR(PG_GETARG_TEXT_P(0));
|
connname = text_to_cstring(PG_GETARG_TEXT_PP(0));
|
||||||
}
|
}
|
||||||
else if (PG_NARGS() == 1)
|
else if (PG_NARGS() == 1)
|
||||||
connstr = GET_STR(PG_GETARG_TEXT_P(0));
|
connstr = text_to_cstring(PG_GETARG_TEXT_PP(0));
|
||||||
|
|
||||||
oldcontext = MemoryContextSwitchTo(TopMemoryContext);
|
oldcontext = MemoryContextSwitchTo(TopMemoryContext);
|
||||||
|
|
||||||
@ -272,7 +270,7 @@ dblink_connect(PG_FUNCTION_ARGS)
|
|||||||
else
|
else
|
||||||
pconn->conn = conn;
|
pconn->conn = conn;
|
||||||
|
|
||||||
PG_RETURN_TEXT_P(GET_TEXT("OK"));
|
PG_RETURN_TEXT_P(cstring_to_text("OK"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -290,7 +288,7 @@ dblink_disconnect(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
if (PG_NARGS() == 1)
|
if (PG_NARGS() == 1)
|
||||||
{
|
{
|
||||||
conname = GET_STR(PG_GETARG_TEXT_P(0));
|
conname = text_to_cstring(PG_GETARG_TEXT_PP(0));
|
||||||
rconn = getConnectionByName(conname);
|
rconn = getConnectionByName(conname);
|
||||||
if (rconn)
|
if (rconn)
|
||||||
conn = rconn->conn;
|
conn = rconn->conn;
|
||||||
@ -310,7 +308,7 @@ dblink_disconnect(PG_FUNCTION_ARGS)
|
|||||||
else
|
else
|
||||||
pconn->conn = NULL;
|
pconn->conn = NULL;
|
||||||
|
|
||||||
PG_RETURN_TEXT_P(GET_TEXT("OK"));
|
PG_RETURN_TEXT_P(cstring_to_text("OK"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -336,8 +334,8 @@ dblink_open(PG_FUNCTION_ARGS)
|
|||||||
if (PG_NARGS() == 2)
|
if (PG_NARGS() == 2)
|
||||||
{
|
{
|
||||||
/* text,text */
|
/* text,text */
|
||||||
curname = GET_STR(PG_GETARG_TEXT_P(0));
|
curname = text_to_cstring(PG_GETARG_TEXT_PP(0));
|
||||||
sql = GET_STR(PG_GETARG_TEXT_P(1));
|
sql = text_to_cstring(PG_GETARG_TEXT_PP(1));
|
||||||
rconn = pconn;
|
rconn = pconn;
|
||||||
}
|
}
|
||||||
else if (PG_NARGS() == 3)
|
else if (PG_NARGS() == 3)
|
||||||
@ -345,25 +343,25 @@ dblink_open(PG_FUNCTION_ARGS)
|
|||||||
/* might be text,text,text or text,text,bool */
|
/* might be text,text,text or text,text,bool */
|
||||||
if (get_fn_expr_argtype(fcinfo->flinfo, 2) == BOOLOID)
|
if (get_fn_expr_argtype(fcinfo->flinfo, 2) == BOOLOID)
|
||||||
{
|
{
|
||||||
curname = GET_STR(PG_GETARG_TEXT_P(0));
|
curname = text_to_cstring(PG_GETARG_TEXT_PP(0));
|
||||||
sql = GET_STR(PG_GETARG_TEXT_P(1));
|
sql = text_to_cstring(PG_GETARG_TEXT_PP(1));
|
||||||
fail = PG_GETARG_BOOL(2);
|
fail = PG_GETARG_BOOL(2);
|
||||||
rconn = pconn;
|
rconn = pconn;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
conname = GET_STR(PG_GETARG_TEXT_P(0));
|
conname = text_to_cstring(PG_GETARG_TEXT_PP(0));
|
||||||
curname = GET_STR(PG_GETARG_TEXT_P(1));
|
curname = text_to_cstring(PG_GETARG_TEXT_PP(1));
|
||||||
sql = GET_STR(PG_GETARG_TEXT_P(2));
|
sql = text_to_cstring(PG_GETARG_TEXT_PP(2));
|
||||||
rconn = getConnectionByName(conname);
|
rconn = getConnectionByName(conname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (PG_NARGS() == 4)
|
else if (PG_NARGS() == 4)
|
||||||
{
|
{
|
||||||
/* text,text,text,bool */
|
/* text,text,text,bool */
|
||||||
conname = GET_STR(PG_GETARG_TEXT_P(0));
|
conname = text_to_cstring(PG_GETARG_TEXT_PP(0));
|
||||||
curname = GET_STR(PG_GETARG_TEXT_P(1));
|
curname = text_to_cstring(PG_GETARG_TEXT_PP(1));
|
||||||
sql = GET_STR(PG_GETARG_TEXT_P(2));
|
sql = text_to_cstring(PG_GETARG_TEXT_PP(2));
|
||||||
fail = PG_GETARG_BOOL(3);
|
fail = PG_GETARG_BOOL(3);
|
||||||
rconn = getConnectionByName(conname);
|
rconn = getConnectionByName(conname);
|
||||||
}
|
}
|
||||||
@ -403,12 +401,12 @@ dblink_open(PG_FUNCTION_ARGS)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
DBLINK_RES_ERROR_AS_NOTICE("sql error");
|
DBLINK_RES_ERROR_AS_NOTICE("sql error");
|
||||||
PG_RETURN_TEXT_P(GET_TEXT("ERROR"));
|
PG_RETURN_TEXT_P(cstring_to_text("ERROR"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
PG_RETURN_TEXT_P(GET_TEXT("OK"));
|
PG_RETURN_TEXT_P(cstring_to_text("OK"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -433,7 +431,7 @@ dblink_close(PG_FUNCTION_ARGS)
|
|||||||
if (PG_NARGS() == 1)
|
if (PG_NARGS() == 1)
|
||||||
{
|
{
|
||||||
/* text */
|
/* text */
|
||||||
curname = GET_STR(PG_GETARG_TEXT_P(0));
|
curname = text_to_cstring(PG_GETARG_TEXT_PP(0));
|
||||||
rconn = pconn;
|
rconn = pconn;
|
||||||
}
|
}
|
||||||
else if (PG_NARGS() == 2)
|
else if (PG_NARGS() == 2)
|
||||||
@ -441,22 +439,22 @@ dblink_close(PG_FUNCTION_ARGS)
|
|||||||
/* might be text,text or text,bool */
|
/* might be text,text or text,bool */
|
||||||
if (get_fn_expr_argtype(fcinfo->flinfo, 1) == BOOLOID)
|
if (get_fn_expr_argtype(fcinfo->flinfo, 1) == BOOLOID)
|
||||||
{
|
{
|
||||||
curname = GET_STR(PG_GETARG_TEXT_P(0));
|
curname = text_to_cstring(PG_GETARG_TEXT_PP(0));
|
||||||
fail = PG_GETARG_BOOL(1);
|
fail = PG_GETARG_BOOL(1);
|
||||||
rconn = pconn;
|
rconn = pconn;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
conname = GET_STR(PG_GETARG_TEXT_P(0));
|
conname = text_to_cstring(PG_GETARG_TEXT_PP(0));
|
||||||
curname = GET_STR(PG_GETARG_TEXT_P(1));
|
curname = text_to_cstring(PG_GETARG_TEXT_PP(1));
|
||||||
rconn = getConnectionByName(conname);
|
rconn = getConnectionByName(conname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (PG_NARGS() == 3)
|
if (PG_NARGS() == 3)
|
||||||
{
|
{
|
||||||
/* text,text,bool */
|
/* text,text,bool */
|
||||||
conname = GET_STR(PG_GETARG_TEXT_P(0));
|
conname = text_to_cstring(PG_GETARG_TEXT_PP(0));
|
||||||
curname = GET_STR(PG_GETARG_TEXT_P(1));
|
curname = text_to_cstring(PG_GETARG_TEXT_PP(1));
|
||||||
fail = PG_GETARG_BOOL(2);
|
fail = PG_GETARG_BOOL(2);
|
||||||
rconn = getConnectionByName(conname);
|
rconn = getConnectionByName(conname);
|
||||||
}
|
}
|
||||||
@ -477,7 +475,7 @@ dblink_close(PG_FUNCTION_ARGS)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
DBLINK_RES_ERROR_AS_NOTICE("sql error");
|
DBLINK_RES_ERROR_AS_NOTICE("sql error");
|
||||||
PG_RETURN_TEXT_P(GET_TEXT("ERROR"));
|
PG_RETURN_TEXT_P(cstring_to_text("ERROR"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -500,7 +498,7 @@ dblink_close(PG_FUNCTION_ARGS)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PG_RETURN_TEXT_P(GET_TEXT("OK"));
|
PG_RETURN_TEXT_P(cstring_to_text("OK"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -535,8 +533,8 @@ dblink_fetch(PG_FUNCTION_ARGS)
|
|||||||
if (PG_NARGS() == 4)
|
if (PG_NARGS() == 4)
|
||||||
{
|
{
|
||||||
/* text,text,int,bool */
|
/* text,text,int,bool */
|
||||||
conname = GET_STR(PG_GETARG_TEXT_P(0));
|
conname = text_to_cstring(PG_GETARG_TEXT_PP(0));
|
||||||
curname = GET_STR(PG_GETARG_TEXT_P(1));
|
curname = text_to_cstring(PG_GETARG_TEXT_PP(1));
|
||||||
howmany = PG_GETARG_INT32(2);
|
howmany = PG_GETARG_INT32(2);
|
||||||
fail = PG_GETARG_BOOL(3);
|
fail = PG_GETARG_BOOL(3);
|
||||||
|
|
||||||
@ -549,15 +547,15 @@ dblink_fetch(PG_FUNCTION_ARGS)
|
|||||||
/* text,text,int or text,int,bool */
|
/* text,text,int or text,int,bool */
|
||||||
if (get_fn_expr_argtype(fcinfo->flinfo, 2) == BOOLOID)
|
if (get_fn_expr_argtype(fcinfo->flinfo, 2) == BOOLOID)
|
||||||
{
|
{
|
||||||
curname = GET_STR(PG_GETARG_TEXT_P(0));
|
curname = text_to_cstring(PG_GETARG_TEXT_PP(0));
|
||||||
howmany = PG_GETARG_INT32(1);
|
howmany = PG_GETARG_INT32(1);
|
||||||
fail = PG_GETARG_BOOL(2);
|
fail = PG_GETARG_BOOL(2);
|
||||||
conn = pconn->conn;
|
conn = pconn->conn;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
conname = GET_STR(PG_GETARG_TEXT_P(0));
|
conname = text_to_cstring(PG_GETARG_TEXT_PP(0));
|
||||||
curname = GET_STR(PG_GETARG_TEXT_P(1));
|
curname = text_to_cstring(PG_GETARG_TEXT_PP(1));
|
||||||
howmany = PG_GETARG_INT32(2);
|
howmany = PG_GETARG_INT32(2);
|
||||||
|
|
||||||
rconn = getConnectionByName(conname);
|
rconn = getConnectionByName(conname);
|
||||||
@ -568,7 +566,7 @@ dblink_fetch(PG_FUNCTION_ARGS)
|
|||||||
else if (PG_NARGS() == 2)
|
else if (PG_NARGS() == 2)
|
||||||
{
|
{
|
||||||
/* text,int */
|
/* text,int */
|
||||||
curname = GET_STR(PG_GETARG_TEXT_P(0));
|
curname = text_to_cstring(PG_GETARG_TEXT_PP(0));
|
||||||
howmany = PG_GETARG_INT32(1);
|
howmany = PG_GETARG_INT32(1);
|
||||||
conn = pconn->conn;
|
conn = pconn->conn;
|
||||||
}
|
}
|
||||||
@ -769,7 +767,7 @@ dblink_record_internal(FunctionCallInfo fcinfo, bool is_async, bool do_get)
|
|||||||
{
|
{
|
||||||
/* text,text,bool */
|
/* text,text,bool */
|
||||||
DBLINK_GET_CONN;
|
DBLINK_GET_CONN;
|
||||||
sql = GET_STR(PG_GETARG_TEXT_P(1));
|
sql = text_to_cstring(PG_GETARG_TEXT_PP(1));
|
||||||
fail = PG_GETARG_BOOL(2);
|
fail = PG_GETARG_BOOL(2);
|
||||||
}
|
}
|
||||||
else if (PG_NARGS() == 2)
|
else if (PG_NARGS() == 2)
|
||||||
@ -778,20 +776,20 @@ dblink_record_internal(FunctionCallInfo fcinfo, bool is_async, bool do_get)
|
|||||||
if (get_fn_expr_argtype(fcinfo->flinfo, 1) == BOOLOID)
|
if (get_fn_expr_argtype(fcinfo->flinfo, 1) == BOOLOID)
|
||||||
{
|
{
|
||||||
conn = pconn->conn;
|
conn = pconn->conn;
|
||||||
sql = GET_STR(PG_GETARG_TEXT_P(0));
|
sql = text_to_cstring(PG_GETARG_TEXT_PP(0));
|
||||||
fail = PG_GETARG_BOOL(1);
|
fail = PG_GETARG_BOOL(1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DBLINK_GET_CONN;
|
DBLINK_GET_CONN;
|
||||||
sql = GET_STR(PG_GETARG_TEXT_P(1));
|
sql = text_to_cstring(PG_GETARG_TEXT_PP(1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (PG_NARGS() == 1)
|
else if (PG_NARGS() == 1)
|
||||||
{
|
{
|
||||||
/* text */
|
/* text */
|
||||||
conn = pconn->conn;
|
conn = pconn->conn;
|
||||||
sql = GET_STR(PG_GETARG_TEXT_P(0));
|
sql = text_to_cstring(PG_GETARG_TEXT_PP(0));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
/* shouldn't happen */
|
/* shouldn't happen */
|
||||||
@ -821,7 +819,7 @@ dblink_record_internal(FunctionCallInfo fcinfo, bool is_async, bool do_get)
|
|||||||
if (PG_NARGS() == 2)
|
if (PG_NARGS() == 2)
|
||||||
{
|
{
|
||||||
DBLINK_GET_CONN;
|
DBLINK_GET_CONN;
|
||||||
sql = GET_STR(PG_GETARG_TEXT_P(1));
|
sql = text_to_cstring(PG_GETARG_TEXT_PP(1));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
/* shouldn't happen */
|
/* shouldn't happen */
|
||||||
@ -1024,7 +1022,7 @@ dblink_get_connections(PG_FUNCTION_ARGS)
|
|||||||
{
|
{
|
||||||
/* stash away current value */
|
/* stash away current value */
|
||||||
astate = accumArrayResult(astate,
|
astate = accumArrayResult(astate,
|
||||||
PointerGetDatum(GET_TEXT(hentry->name)),
|
CStringGetTextDatum(hentry->name),
|
||||||
false, TEXTOID, CurrentMemoryContext);
|
false, TEXTOID, CurrentMemoryContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1087,9 +1085,9 @@ dblink_cancel_query(PG_FUNCTION_ARGS)
|
|||||||
PQfreeCancel(cancel);
|
PQfreeCancel(cancel);
|
||||||
|
|
||||||
if (res == 1)
|
if (res == 1)
|
||||||
PG_RETURN_TEXT_P(GET_TEXT("OK"));
|
PG_RETURN_TEXT_P(cstring_to_text("OK"));
|
||||||
else
|
else
|
||||||
PG_RETURN_TEXT_P(GET_TEXT(errbuf));
|
PG_RETURN_TEXT_P(cstring_to_text(errbuf));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1116,9 +1114,9 @@ dblink_error_message(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
msg = PQerrorMessage(conn);
|
msg = PQerrorMessage(conn);
|
||||||
if (msg == NULL || msg[0] == '\0')
|
if (msg == NULL || msg[0] == '\0')
|
||||||
PG_RETURN_TEXT_P(GET_TEXT("OK"));
|
PG_RETURN_TEXT_P(cstring_to_text("OK"));
|
||||||
else
|
else
|
||||||
PG_RETURN_TEXT_P(GET_TEXT(msg));
|
PG_RETURN_TEXT_P(cstring_to_text(msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1146,7 +1144,7 @@ dblink_exec(PG_FUNCTION_ARGS)
|
|||||||
{
|
{
|
||||||
/* must be text,text,bool */
|
/* must be text,text,bool */
|
||||||
DBLINK_GET_CONN;
|
DBLINK_GET_CONN;
|
||||||
sql = GET_STR(PG_GETARG_TEXT_P(1));
|
sql = text_to_cstring(PG_GETARG_TEXT_PP(1));
|
||||||
fail = PG_GETARG_BOOL(2);
|
fail = PG_GETARG_BOOL(2);
|
||||||
}
|
}
|
||||||
else if (PG_NARGS() == 2)
|
else if (PG_NARGS() == 2)
|
||||||
@ -1155,20 +1153,20 @@ dblink_exec(PG_FUNCTION_ARGS)
|
|||||||
if (get_fn_expr_argtype(fcinfo->flinfo, 1) == BOOLOID)
|
if (get_fn_expr_argtype(fcinfo->flinfo, 1) == BOOLOID)
|
||||||
{
|
{
|
||||||
conn = pconn->conn;
|
conn = pconn->conn;
|
||||||
sql = GET_STR(PG_GETARG_TEXT_P(0));
|
sql = text_to_cstring(PG_GETARG_TEXT_PP(0));
|
||||||
fail = PG_GETARG_BOOL(1);
|
fail = PG_GETARG_BOOL(1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DBLINK_GET_CONN;
|
DBLINK_GET_CONN;
|
||||||
sql = GET_STR(PG_GETARG_TEXT_P(1));
|
sql = text_to_cstring(PG_GETARG_TEXT_PP(1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (PG_NARGS() == 1)
|
else if (PG_NARGS() == 1)
|
||||||
{
|
{
|
||||||
/* must be single text argument */
|
/* must be single text argument */
|
||||||
conn = pconn->conn;
|
conn = pconn->conn;
|
||||||
sql = GET_STR(PG_GETARG_TEXT_P(0));
|
sql = text_to_cstring(PG_GETARG_TEXT_PP(0));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
/* shouldn't happen */
|
/* shouldn't happen */
|
||||||
@ -1196,7 +1194,7 @@ dblink_exec(PG_FUNCTION_ARGS)
|
|||||||
* and save a copy of the command status string to return as our
|
* and save a copy of the command status string to return as our
|
||||||
* result tuple
|
* result tuple
|
||||||
*/
|
*/
|
||||||
sql_cmd_status = GET_TEXT("ERROR");
|
sql_cmd_status = cstring_to_text("ERROR");
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (PQresultStatus(res) == PGRES_COMMAND_OK)
|
else if (PQresultStatus(res) == PGRES_COMMAND_OK)
|
||||||
@ -1210,7 +1208,7 @@ dblink_exec(PG_FUNCTION_ARGS)
|
|||||||
* and save a copy of the command status string to return as our
|
* and save a copy of the command status string to return as our
|
||||||
* result tuple
|
* result tuple
|
||||||
*/
|
*/
|
||||||
sql_cmd_status = GET_TEXT(PQcmdStatus(res));
|
sql_cmd_status = cstring_to_text(PQcmdStatus(res));
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1267,7 +1265,7 @@ dblink_get_pkey(PG_FUNCTION_ARGS)
|
|||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_UNDEFINED_TABLE),
|
(errcode(ERRCODE_UNDEFINED_TABLE),
|
||||||
errmsg("relation \"%s\" does not exist",
|
errmsg("relation \"%s\" does not exist",
|
||||||
GET_STR(PG_GETARG_TEXT_P(0)))));
|
text_to_cstring(PG_GETARG_TEXT_PP(0)))));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* need a tuple descriptor representing one INT and one TEXT column
|
* need a tuple descriptor representing one INT and one TEXT column
|
||||||
@ -1387,7 +1385,7 @@ dblink_build_sql_insert(PG_FUNCTION_ARGS)
|
|||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_UNDEFINED_TABLE),
|
(errcode(ERRCODE_UNDEFINED_TABLE),
|
||||||
errmsg("relation \"%s\" does not exist",
|
errmsg("relation \"%s\" does not exist",
|
||||||
GET_STR(relname_text))));
|
text_to_cstring(relname_text))));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* There should be at least one key attribute
|
* There should be at least one key attribute
|
||||||
@ -1443,7 +1441,7 @@ dblink_build_sql_insert(PG_FUNCTION_ARGS)
|
|||||||
/*
|
/*
|
||||||
* And send it
|
* And send it
|
||||||
*/
|
*/
|
||||||
PG_RETURN_TEXT_P(GET_TEXT(sql));
|
PG_RETURN_TEXT_P(cstring_to_text(sql));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1484,7 +1482,7 @@ dblink_build_sql_delete(PG_FUNCTION_ARGS)
|
|||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_UNDEFINED_TABLE),
|
(errcode(ERRCODE_UNDEFINED_TABLE),
|
||||||
errmsg("relation \"%s\" does not exist",
|
errmsg("relation \"%s\" does not exist",
|
||||||
GET_STR(relname_text))));
|
text_to_cstring(relname_text))));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* There should be at least one key attribute
|
* There should be at least one key attribute
|
||||||
@ -1525,7 +1523,7 @@ dblink_build_sql_delete(PG_FUNCTION_ARGS)
|
|||||||
/*
|
/*
|
||||||
* And send it
|
* And send it
|
||||||
*/
|
*/
|
||||||
PG_RETURN_TEXT_P(GET_TEXT(sql));
|
PG_RETURN_TEXT_P(cstring_to_text(sql));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1573,7 +1571,7 @@ dblink_build_sql_update(PG_FUNCTION_ARGS)
|
|||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_UNDEFINED_TABLE),
|
(errcode(ERRCODE_UNDEFINED_TABLE),
|
||||||
errmsg("relation \"%s\" does not exist",
|
errmsg("relation \"%s\" does not exist",
|
||||||
GET_STR(relname_text))));
|
text_to_cstring(relname_text))));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* There should be one source array key values for each key attnum
|
* There should be one source array key values for each key attnum
|
||||||
@ -1629,7 +1627,7 @@ dblink_build_sql_update(PG_FUNCTION_ARGS)
|
|||||||
/*
|
/*
|
||||||
* And send it
|
* And send it
|
||||||
*/
|
*/
|
||||||
PG_RETURN_TEXT_P(GET_TEXT(sql));
|
PG_RETURN_TEXT_P(cstring_to_text(sql));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1643,7 +1641,7 @@ Datum
|
|||||||
dblink_current_query(PG_FUNCTION_ARGS)
|
dblink_current_query(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
if (debug_query_string)
|
if (debug_query_string)
|
||||||
PG_RETURN_TEXT_P(GET_TEXT(debug_query_string));
|
PG_RETURN_TEXT_P(cstring_to_text(debug_query_string));
|
||||||
else
|
else
|
||||||
PG_RETURN_NULL();
|
PG_RETURN_NULL();
|
||||||
}
|
}
|
||||||
@ -1763,8 +1761,7 @@ get_text_array_contents(ArrayType *array, int *numitems)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
values[i] = DatumGetCString(DirectFunctionCall1(textout,
|
values[i] = TextDatumGetCString(PointerGetDatum(ptr));
|
||||||
PointerGetDatum(ptr)));
|
|
||||||
ptr = att_addlength_pointer(ptr, typlen, ptr);
|
ptr = att_addlength_pointer(ptr, typlen, ptr);
|
||||||
ptr = (char *) att_align_nominal(ptr, typalign);
|
ptr = (char *) att_align_nominal(ptr, typalign);
|
||||||
}
|
}
|
||||||
@ -2026,9 +2023,10 @@ quote_literal_cstr(char *rawstr)
|
|||||||
text *result_text;
|
text *result_text;
|
||||||
char *result;
|
char *result;
|
||||||
|
|
||||||
rawstr_text = DatumGetTextP(DirectFunctionCall1(textin, CStringGetDatum(rawstr)));
|
rawstr_text = cstring_to_text(rawstr);
|
||||||
result_text = DatumGetTextP(DirectFunctionCall1(quote_literal, PointerGetDatum(rawstr_text)));
|
result_text = DatumGetTextP(DirectFunctionCall1(quote_literal,
|
||||||
result = DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(result_text)));
|
PointerGetDatum(rawstr_text)));
|
||||||
|
result = text_to_cstring(result_text);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -2044,9 +2042,10 @@ quote_ident_cstr(char *rawstr)
|
|||||||
text *result_text;
|
text *result_text;
|
||||||
char *result;
|
char *result;
|
||||||
|
|
||||||
rawstr_text = DatumGetTextP(DirectFunctionCall1(textin, CStringGetDatum(rawstr)));
|
rawstr_text = cstring_to_text(rawstr);
|
||||||
result_text = DatumGetTextP(DirectFunctionCall1(quote_ident, PointerGetDatum(rawstr_text)));
|
result_text = DatumGetTextP(DirectFunctionCall1(quote_ident,
|
||||||
result = DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(result_text)));
|
PointerGetDatum(rawstr_text)));
|
||||||
|
result = text_to_cstring(result_text);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* This is a port of the Double Metaphone algorithm for use in PostgreSQL.
|
* This is a port of the Double Metaphone algorithm for use in PostgreSQL.
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/contrib/fuzzystrmatch/dmetaphone.c,v 1.11 2007/02/27 23:48:05 tgl Exp $
|
* $PostgreSQL: pgsql/contrib/fuzzystrmatch/dmetaphone.c,v 1.12 2008/03/25 22:42:41 tgl Exp $
|
||||||
*
|
*
|
||||||
* Double Metaphone computes 2 "sounds like" strings - a primary and an
|
* Double Metaphone computes 2 "sounds like" strings - a primary and an
|
||||||
* alternate. In most cases they are the same, but for foreign names
|
* alternate. In most cases they are the same, but for foreign names
|
||||||
@ -101,7 +101,7 @@ The remaining code is authored by Andrew Dunstan <amdunstan@ncshp.org> and
|
|||||||
|
|
||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
|
|
||||||
#include "fmgr.h"
|
#include "utils/builtins.h"
|
||||||
|
|
||||||
/* turn off assertions for embedded function */
|
/* turn off assertions for embedded function */
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
@ -118,14 +118,12 @@ extern Datum dmetaphone(PG_FUNCTION_ARGS);
|
|||||||
extern Datum dmetaphone_alt(PG_FUNCTION_ARGS);
|
extern Datum dmetaphone_alt(PG_FUNCTION_ARGS);
|
||||||
|
|
||||||
/* prototype for the main function we got from the perl module */
|
/* prototype for the main function we got from the perl module */
|
||||||
static void
|
static void DoubleMetaphone(char *, char **);
|
||||||
DoubleMetaphone(char *, char **);
|
|
||||||
|
|
||||||
#ifndef DMETAPHONE_MAIN
|
#ifndef DMETAPHONE_MAIN
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The PostgreSQL visible dmetaphone function.
|
* The PostgreSQL visible dmetaphone function.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
PG_FUNCTION_INFO_V1(dmetaphone);
|
PG_FUNCTION_INFO_V1(dmetaphone);
|
||||||
@ -133,47 +131,28 @@ PG_FUNCTION_INFO_V1(dmetaphone);
|
|||||||
Datum
|
Datum
|
||||||
dmetaphone(PG_FUNCTION_ARGS)
|
dmetaphone(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
text *arg,
|
text *arg;
|
||||||
*result;
|
|
||||||
int alen,
|
|
||||||
rsize;
|
|
||||||
char *aptr,
|
char *aptr,
|
||||||
*codes[2],
|
*codes[2],
|
||||||
*code,
|
*code;
|
||||||
*rptr;
|
|
||||||
|
|
||||||
#ifdef DMETAPHONE_NOSTRICT
|
#ifdef DMETAPHONE_NOSTRICT
|
||||||
if (PG_ARGISNULL(0))
|
if (PG_ARGISNULL(0))
|
||||||
PG_RETURNNULL();
|
PG_RETURN_NULL();
|
||||||
#endif
|
#endif
|
||||||
arg = PG_GETARG_TEXT_P(0);
|
arg = PG_GETARG_TEXT_P(0);
|
||||||
alen = VARSIZE(arg) - VARHDRSZ;
|
aptr = text_to_cstring(arg);
|
||||||
|
|
||||||
/*
|
|
||||||
* Postgres' string values might not have trailing nuls. The VARSIZE will
|
|
||||||
* not include the nul in any case so we copy things out and add a
|
|
||||||
* trailing nul. When we copy back we ignore the nul (and we don't make
|
|
||||||
* space for it).
|
|
||||||
*/
|
|
||||||
|
|
||||||
aptr = palloc(alen + 1);
|
|
||||||
memcpy(aptr, VARDATA(arg), alen);
|
|
||||||
aptr[alen] = 0;
|
|
||||||
DoubleMetaphone(aptr, codes);
|
DoubleMetaphone(aptr, codes);
|
||||||
code = codes[0];
|
code = codes[0];
|
||||||
if (!code)
|
if (!code)
|
||||||
code = "";
|
code = "";
|
||||||
rsize = VARHDRSZ + strlen(code);
|
|
||||||
result = (text *) palloc(rsize);
|
PG_RETURN_TEXT_P(cstring_to_text(code));
|
||||||
rptr = VARDATA(result);
|
|
||||||
memcpy(rptr, code, rsize - VARHDRSZ);
|
|
||||||
SET_VARSIZE(result, rsize);
|
|
||||||
PG_RETURN_TEXT_P(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The PostgreSQL visible dmetaphone_alt function.
|
* The PostgreSQL visible dmetaphone_alt function.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
PG_FUNCTION_INFO_V1(dmetaphone_alt);
|
PG_FUNCTION_INFO_V1(dmetaphone_alt);
|
||||||
@ -181,34 +160,24 @@ PG_FUNCTION_INFO_V1(dmetaphone_alt);
|
|||||||
Datum
|
Datum
|
||||||
dmetaphone_alt(PG_FUNCTION_ARGS)
|
dmetaphone_alt(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
text *arg,
|
text *arg;
|
||||||
*result;
|
|
||||||
int alen,
|
|
||||||
rsize;
|
|
||||||
char *aptr,
|
char *aptr,
|
||||||
*codes[2],
|
*codes[2],
|
||||||
*code,
|
*code;
|
||||||
*rptr;
|
|
||||||
|
|
||||||
#ifdef DMETAPHONE_NOSTRICT
|
#ifdef DMETAPHONE_NOSTRICT
|
||||||
if (PG_ARGISNULL(0))
|
if (PG_ARGISNULL(0))
|
||||||
PG_RETURNNULL();
|
PG_RETURN_NULL();
|
||||||
#endif
|
#endif
|
||||||
arg = PG_GETARG_TEXT_P(0);
|
arg = PG_GETARG_TEXT_P(0);
|
||||||
alen = VARSIZE(arg) - VARHDRSZ;
|
aptr = text_to_cstring(arg);
|
||||||
aptr = palloc(alen + 1);
|
|
||||||
memcpy(aptr, VARDATA(arg), alen);
|
|
||||||
aptr[alen] = 0;
|
|
||||||
DoubleMetaphone(aptr, codes);
|
DoubleMetaphone(aptr, codes);
|
||||||
code = codes[1];
|
code = codes[1];
|
||||||
if (!code)
|
if (!code)
|
||||||
code = "";
|
code = "";
|
||||||
rsize = VARHDRSZ + strlen(code);
|
|
||||||
result = (text *) palloc(rsize);
|
PG_RETURN_TEXT_P(cstring_to_text(code));
|
||||||
rptr = VARDATA(result);
|
|
||||||
memcpy(rptr, code, rsize - VARHDRSZ);
|
|
||||||
SET_VARSIZE(result, rsize);
|
|
||||||
PG_RETURN_TEXT_P(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
*
|
*
|
||||||
* Joe Conway <mail@joeconway.com>
|
* Joe Conway <mail@joeconway.com>
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/contrib/fuzzystrmatch/fuzzystrmatch.c,v 1.25 2008/01/01 19:45:45 momjian Exp $
|
* $PostgreSQL: pgsql/contrib/fuzzystrmatch/fuzzystrmatch.c,v 1.26 2008/03/25 22:42:41 tgl Exp $
|
||||||
* Copyright (c) 2001-2008, PostgreSQL Global Development Group
|
* Copyright (c) 2001-2008, PostgreSQL Global Development Group
|
||||||
* ALL RIGHTS RESERVED;
|
* ALL RIGHTS RESERVED;
|
||||||
*
|
*
|
||||||
@ -56,11 +56,11 @@ PG_FUNCTION_INFO_V1(levenshtein);
|
|||||||
Datum
|
Datum
|
||||||
levenshtein(PG_FUNCTION_ARGS)
|
levenshtein(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
char *str_s;
|
char *str_s = TextDatumGetCString(PG_GETARG_DATUM(0));
|
||||||
|
char *str_t = TextDatumGetCString(PG_GETARG_DATUM(1));
|
||||||
|
int cols = strlen(str_s) + 1;
|
||||||
|
int rows = strlen(str_t) + 1;
|
||||||
char *str_s0;
|
char *str_s0;
|
||||||
char *str_t;
|
|
||||||
int cols = 0;
|
|
||||||
int rows = 0;
|
|
||||||
int *u_cells;
|
int *u_cells;
|
||||||
int *l_cells;
|
int *l_cells;
|
||||||
int *tmp;
|
int *tmp;
|
||||||
@ -68,16 +68,10 @@ levenshtein(PG_FUNCTION_ARGS)
|
|||||||
int j;
|
int j;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Fetch the arguments. str_s is referred to as the "source" cols = length
|
* str_s is referred to as the "source", str_t is referred to as the
|
||||||
* of source + 1 to allow for the initialization column str_t is referred
|
* "target", cols = length of source + 1 to allow for the initialization
|
||||||
* to as the "target", rows = length of target + 1 rows = length of target
|
* column, rows = length of target + 1 to allow for the initialization row
|
||||||
* + 1 to allow for the initialization row
|
|
||||||
*/
|
*/
|
||||||
str_s = DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(PG_GETARG_TEXT_P(0))));
|
|
||||||
str_t = DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(PG_GETARG_TEXT_P(1))));
|
|
||||||
|
|
||||||
cols = strlen(str_s) + 1;
|
|
||||||
rows = strlen(str_t) + 1;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Restrict the length of the strings being compared to something
|
* Restrict the length of the strings being compared to something
|
||||||
@ -201,25 +195,19 @@ levenshtein(PG_FUNCTION_ARGS)
|
|||||||
* Returns number of characters requested
|
* Returns number of characters requested
|
||||||
* (suggested value is 4)
|
* (suggested value is 4)
|
||||||
*/
|
*/
|
||||||
#define GET_TEXT(cstrp) DatumGetTextP(DirectFunctionCall1(textin, CStringGetDatum(cstrp)))
|
|
||||||
|
|
||||||
PG_FUNCTION_INFO_V1(metaphone);
|
PG_FUNCTION_INFO_V1(metaphone);
|
||||||
Datum
|
Datum
|
||||||
metaphone(PG_FUNCTION_ARGS)
|
metaphone(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
|
char *str_i = TextDatumGetCString(PG_GETARG_DATUM(0));
|
||||||
|
size_t str_i_len = strlen(str_i);
|
||||||
int reqlen;
|
int reqlen;
|
||||||
char *str_i;
|
|
||||||
size_t str_i_len;
|
|
||||||
char *metaph;
|
char *metaph;
|
||||||
text *result_text;
|
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
str_i = DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(PG_GETARG_TEXT_P(0))));
|
|
||||||
str_i_len = strlen(str_i);
|
|
||||||
|
|
||||||
/* return an empty string if we receive one */
|
/* return an empty string if we receive one */
|
||||||
if (!(str_i_len > 0))
|
if (!(str_i_len > 0))
|
||||||
PG_RETURN_TEXT_P(GET_TEXT(""));
|
PG_RETURN_TEXT_P(cstring_to_text(""));
|
||||||
|
|
||||||
if (str_i_len > MAX_METAPHONE_STRLEN)
|
if (str_i_len > MAX_METAPHONE_STRLEN)
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
@ -247,18 +235,12 @@ metaphone(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
retval = _metaphone(str_i, reqlen, &metaph);
|
retval = _metaphone(str_i, reqlen, &metaph);
|
||||||
if (retval == META_SUCCESS)
|
if (retval == META_SUCCESS)
|
||||||
{
|
PG_RETURN_TEXT_P(cstring_to_text(metaph));
|
||||||
result_text = DatumGetTextP(DirectFunctionCall1(textin, CStringGetDatum(metaph)));
|
|
||||||
PG_RETURN_TEXT_P(result_text);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* internal error */
|
/* internal error */
|
||||||
elog(ERROR, "metaphone: failure");
|
elog(ERROR, "metaphone: failure");
|
||||||
|
/* keep the compiler quiet */
|
||||||
/*
|
|
||||||
* Keep the compiler quiet
|
|
||||||
*/
|
|
||||||
PG_RETURN_NULL();
|
PG_RETURN_NULL();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -695,11 +677,11 @@ soundex(PG_FUNCTION_ARGS)
|
|||||||
char outstr[SOUNDEX_LEN + 1];
|
char outstr[SOUNDEX_LEN + 1];
|
||||||
char *arg;
|
char *arg;
|
||||||
|
|
||||||
arg = _textout(PG_GETARG_TEXT_P(0));
|
arg = text_to_cstring(PG_GETARG_TEXT_P(0));
|
||||||
|
|
||||||
_soundex(arg, outstr);
|
_soundex(arg, outstr);
|
||||||
|
|
||||||
PG_RETURN_TEXT_P(_textin(outstr));
|
PG_RETURN_TEXT_P(cstring_to_text(outstr));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -761,8 +743,8 @@ difference(PG_FUNCTION_ARGS)
|
|||||||
int i,
|
int i,
|
||||||
result;
|
result;
|
||||||
|
|
||||||
_soundex(_textout(PG_GETARG_TEXT_P(0)), sndx1);
|
_soundex(text_to_cstring(PG_GETARG_TEXT_P(0)), sndx1);
|
||||||
_soundex(_textout(PG_GETARG_TEXT_P(1)), sndx2);
|
_soundex(text_to_cstring(PG_GETARG_TEXT_P(1)), sndx2);
|
||||||
|
|
||||||
result = 0;
|
result = 0;
|
||||||
for (i = 0; i < SOUNDEX_LEN; i++)
|
for (i = 0; i < SOUNDEX_LEN; i++)
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
*
|
*
|
||||||
* Joe Conway <mail@joeconway.com>
|
* Joe Conway <mail@joeconway.com>
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/contrib/fuzzystrmatch/fuzzystrmatch.h,v 1.16 2008/01/01 19:45:45 momjian Exp $
|
* $PostgreSQL: pgsql/contrib/fuzzystrmatch/fuzzystrmatch.h,v 1.17 2008/03/25 22:42:41 tgl Exp $
|
||||||
* Copyright (c) 2001-2008, PostgreSQL Global Development Group
|
* Copyright (c) 2001-2008, PostgreSQL Global Development Group
|
||||||
* ALL RIGHTS RESERVED;
|
* ALL RIGHTS RESERVED;
|
||||||
*
|
*
|
||||||
@ -69,8 +69,6 @@ extern Datum difference(PG_FUNCTION_ARGS);
|
|||||||
static void _soundex(const char *instr, char *outstr);
|
static void _soundex(const char *instr, char *outstr);
|
||||||
|
|
||||||
#define SOUNDEX_LEN 4
|
#define SOUNDEX_LEN 4
|
||||||
#define _textin(str) DirectFunctionCall1(textin, CStringGetDatum(str))
|
|
||||||
#define _textout(str) DatumGetPointer(DirectFunctionCall1(textout, PointerGetDatum(str)))
|
|
||||||
|
|
||||||
/* ABCDEFGHIJKLMNOPQRSTUVWXYZ */
|
/* ABCDEFGHIJKLMNOPQRSTUVWXYZ */
|
||||||
static const char *soundex_table = "01230120022455012623010202";
|
static const char *soundex_table = "01230120022455012623010202";
|
||||||
|
@ -52,13 +52,12 @@ fetchval(PG_FUNCTION_ARGS)
|
|||||||
PG_RETURN_NULL();
|
PG_RETURN_NULL();
|
||||||
}
|
}
|
||||||
|
|
||||||
out = palloc(VARHDRSZ + entry->vallen);
|
out = cstring_to_text_with_len(STRPTR(hs) + entry->pos + entry->keylen,
|
||||||
memcpy(VARDATA(out), STRPTR(hs) + entry->pos + entry->keylen, entry->vallen);
|
entry->vallen);
|
||||||
SET_VARSIZE(out, VARHDRSZ + entry->vallen);
|
|
||||||
|
|
||||||
PG_FREE_IF_COPY(hs, 0);
|
PG_FREE_IF_COPY(hs, 0);
|
||||||
PG_FREE_IF_COPY(key, 1);
|
PG_FREE_IF_COPY(key, 1);
|
||||||
PG_RETURN_POINTER(out);
|
PG_RETURN_TEXT_P(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
PG_FUNCTION_INFO_V1(exists);
|
PG_FUNCTION_INFO_V1(exists);
|
||||||
@ -330,22 +329,19 @@ akeys(PG_FUNCTION_ARGS)
|
|||||||
d = (Datum *) palloc(sizeof(Datum) * (hs->size + 1));
|
d = (Datum *) palloc(sizeof(Datum) * (hs->size + 1));
|
||||||
while (ptr - ARRPTR(hs) < hs->size)
|
while (ptr - ARRPTR(hs) < hs->size)
|
||||||
{
|
{
|
||||||
text *item = (text *) palloc(VARHDRSZ + ptr->keylen);
|
text *item;
|
||||||
|
|
||||||
SET_VARSIZE(item, VARHDRSZ + ptr->keylen);
|
item = cstring_to_text_with_len(base + ptr->pos, ptr->keylen);
|
||||||
memcpy(VARDATA(item), base + ptr->pos, ptr->keylen);
|
|
||||||
d[ptr - ARRPTR(hs)] = PointerGetDatum(item);
|
d[ptr - ARRPTR(hs)] = PointerGetDatum(item);
|
||||||
ptr++;
|
ptr++;
|
||||||
}
|
}
|
||||||
|
|
||||||
a = construct_array(
|
a = construct_array(d,
|
||||||
d,
|
|
||||||
hs->size,
|
hs->size,
|
||||||
TEXTOID,
|
TEXTOID,
|
||||||
-1,
|
-1,
|
||||||
false,
|
false,
|
||||||
'i'
|
'i');
|
||||||
);
|
|
||||||
|
|
||||||
ptr = ARRPTR(hs);
|
ptr = ARRPTR(hs);
|
||||||
while (ptr - ARRPTR(hs) < hs->size)
|
while (ptr - ARRPTR(hs) < hs->size)
|
||||||
@ -374,23 +370,20 @@ avals(PG_FUNCTION_ARGS)
|
|||||||
d = (Datum *) palloc(sizeof(Datum) * (hs->size + 1));
|
d = (Datum *) palloc(sizeof(Datum) * (hs->size + 1));
|
||||||
while (ptr - ARRPTR(hs) < hs->size)
|
while (ptr - ARRPTR(hs) < hs->size)
|
||||||
{
|
{
|
||||||
int vallen = (ptr->valisnull) ? 0 : ptr->vallen;
|
text *item;
|
||||||
text *item = (text *) palloc(VARHDRSZ + vallen);
|
|
||||||
|
|
||||||
SET_VARSIZE(item, VARHDRSZ + vallen);
|
item = cstring_to_text_with_len(base + ptr->pos + ptr->keylen,
|
||||||
memcpy(VARDATA(item), base + ptr->pos + ptr->keylen, vallen);
|
(ptr->valisnull) ? 0 : ptr->vallen);
|
||||||
d[ptr - ARRPTR(hs)] = PointerGetDatum(item);
|
d[ptr - ARRPTR(hs)] = PointerGetDatum(item);
|
||||||
ptr++;
|
ptr++;
|
||||||
}
|
}
|
||||||
|
|
||||||
a = construct_array(
|
a = construct_array(d,
|
||||||
d,
|
|
||||||
hs->size,
|
hs->size,
|
||||||
TEXTOID,
|
TEXTOID,
|
||||||
-1,
|
-1,
|
||||||
false,
|
false,
|
||||||
'i'
|
'i');
|
||||||
);
|
|
||||||
|
|
||||||
ptr = ARRPTR(hs);
|
ptr = ARRPTR(hs);
|
||||||
while (ptr - ARRPTR(hs) < hs->size)
|
while (ptr - ARRPTR(hs) < hs->size)
|
||||||
@ -451,10 +444,10 @@ skeys(PG_FUNCTION_ARGS)
|
|||||||
if (st->i < st->hs->size)
|
if (st->i < st->hs->size)
|
||||||
{
|
{
|
||||||
HEntry *ptr = &(ARRPTR(st->hs)[st->i]);
|
HEntry *ptr = &(ARRPTR(st->hs)[st->i]);
|
||||||
text *item = (text *) palloc(VARHDRSZ + ptr->keylen);
|
text *item;
|
||||||
|
|
||||||
SET_VARSIZE(item, VARHDRSZ + ptr->keylen);
|
item = cstring_to_text_with_len(STRPTR(st->hs) + ptr->pos,
|
||||||
memcpy(VARDATA(item), STRPTR(st->hs) + ptr->pos, ptr->keylen);
|
ptr->keylen);
|
||||||
st->i++;
|
st->i++;
|
||||||
|
|
||||||
SRF_RETURN_NEXT(funcctx, PointerGetDatum(item));
|
SRF_RETURN_NEXT(funcctx, PointerGetDatum(item));
|
||||||
@ -502,11 +495,10 @@ svals(PG_FUNCTION_ARGS)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int vallen = ptr->vallen;
|
text *item;
|
||||||
text *item = (text *) palloc(VARHDRSZ + vallen);
|
|
||||||
|
|
||||||
SET_VARSIZE(item, VARHDRSZ + vallen);
|
item = cstring_to_text_with_len(STRPTR(st->hs) + ptr->pos + ptr->keylen,
|
||||||
memcpy(VARDATA(item), STRPTR(st->hs) + ptr->pos + ptr->keylen, vallen);
|
ptr->vallen);
|
||||||
st->i++;
|
st->i++;
|
||||||
|
|
||||||
SRF_RETURN_NEXT(funcctx, PointerGetDatum(item));
|
SRF_RETURN_NEXT(funcctx, PointerGetDatum(item));
|
||||||
@ -617,9 +609,7 @@ each(PG_FUNCTION_ARGS)
|
|||||||
text *item;
|
text *item;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
|
|
||||||
item = (text *) palloc(VARHDRSZ + ptr->keylen);
|
item = cstring_to_text_with_len(STRPTR(st->hs) + ptr->pos, ptr->keylen);
|
||||||
SET_VARSIZE(item, VARHDRSZ + ptr->keylen);
|
|
||||||
memcpy(VARDATA(item), STRPTR(st->hs) + ptr->pos, ptr->keylen);
|
|
||||||
dvalues[0] = PointerGetDatum(item);
|
dvalues[0] = PointerGetDatum(item);
|
||||||
|
|
||||||
if (ptr->valisnull)
|
if (ptr->valisnull)
|
||||||
@ -629,11 +619,8 @@ each(PG_FUNCTION_ARGS)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int vallen = ptr->vallen;
|
item = cstring_to_text_with_len(STRPTR(st->hs) + ptr->pos + ptr->keylen,
|
||||||
|
ptr->vallen);
|
||||||
item = (text *) palloc(VARHDRSZ + vallen);
|
|
||||||
SET_VARSIZE(item, VARHDRSZ + vallen);
|
|
||||||
memcpy(VARDATA(item), STRPTR(st->hs) + ptr->pos + ptr->keylen, vallen);
|
|
||||||
dvalues[1] = PointerGetDatum(item);
|
dvalues[1] = PointerGetDatum(item);
|
||||||
}
|
}
|
||||||
st->i++;
|
st->i++;
|
||||||
|
@ -765,9 +765,7 @@ querytree(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
if (len == 0)
|
if (len == 0)
|
||||||
{
|
{
|
||||||
res = (text *) palloc(1 + VARHDRSZ);
|
res = cstring_to_text("T");
|
||||||
SET_VARSIZE(res, 1 + VARHDRSZ);
|
|
||||||
*((char *) VARDATA(res)) = 'T';
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -776,12 +774,9 @@ querytree(PG_FUNCTION_ARGS)
|
|||||||
nrm.cur = nrm.buf = (char *) palloc(sizeof(char) * nrm.buflen);
|
nrm.cur = nrm.buf = (char *) palloc(sizeof(char) * nrm.buflen);
|
||||||
*(nrm.cur) = '\0';
|
*(nrm.cur) = '\0';
|
||||||
infix(&nrm, true);
|
infix(&nrm, true);
|
||||||
|
res = cstring_to_text_with_len(nrm.buf, nrm.cur - nrm.buf);
|
||||||
res = (text *) palloc(nrm.cur - nrm.buf + VARHDRSZ);
|
|
||||||
SET_VARSIZE(res, nrm.cur - nrm.buf + VARHDRSZ);
|
|
||||||
memcpy(VARDATA(res), nrm.buf, nrm.cur - nrm.buf);
|
|
||||||
}
|
}
|
||||||
pfree(q);
|
pfree(q);
|
||||||
|
|
||||||
PG_RETURN_POINTER(res);
|
PG_RETURN_TEXT_P(res);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* op function for ltree
|
* op function for ltree
|
||||||
* Teodor Sigaev <teodor@stack.net>
|
* Teodor Sigaev <teodor@stack.net>
|
||||||
* $PostgreSQL: pgsql/contrib/ltree/ltree_op.c,v 1.17 2008/03/09 00:32:09 tgl Exp $
|
* $PostgreSQL: pgsql/contrib/ltree/ltree_op.c,v 1.18 2008/03/25 22:42:41 tgl Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ltree.h"
|
#include "ltree.h"
|
||||||
@ -314,19 +314,15 @@ Datum
|
|||||||
ltree_addtext(PG_FUNCTION_ARGS)
|
ltree_addtext(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
ltree *a = PG_GETARG_LTREE(0);
|
ltree *a = PG_GETARG_LTREE(0);
|
||||||
text *b = PG_GETARG_TEXT_P(1);
|
text *b = PG_GETARG_TEXT_PP(1);
|
||||||
char *s;
|
char *s;
|
||||||
ltree *r,
|
ltree *r,
|
||||||
*tmp;
|
*tmp;
|
||||||
|
|
||||||
s = (char *) palloc(VARSIZE(b) - VARHDRSZ + 1);
|
s = text_to_cstring(b);
|
||||||
memcpy(s, VARDATA(b), VARSIZE(b) - VARHDRSZ);
|
|
||||||
s[VARSIZE(b) - VARHDRSZ] = '\0';
|
|
||||||
|
|
||||||
tmp = (ltree *) DatumGetPointer(DirectFunctionCall1(
|
tmp = (ltree *) DatumGetPointer(DirectFunctionCall1(ltree_in,
|
||||||
ltree_in,
|
PointerGetDatum(s)));
|
||||||
PointerGetDatum(s)
|
|
||||||
));
|
|
||||||
|
|
||||||
pfree(s);
|
pfree(s);
|
||||||
|
|
||||||
@ -403,19 +399,15 @@ Datum
|
|||||||
ltree_textadd(PG_FUNCTION_ARGS)
|
ltree_textadd(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
ltree *a = PG_GETARG_LTREE(1);
|
ltree *a = PG_GETARG_LTREE(1);
|
||||||
text *b = PG_GETARG_TEXT_P(0);
|
text *b = PG_GETARG_TEXT_PP(0);
|
||||||
char *s;
|
char *s;
|
||||||
ltree *r,
|
ltree *r,
|
||||||
*tmp;
|
*tmp;
|
||||||
|
|
||||||
s = (char *) palloc(VARSIZE(b) - VARHDRSZ + 1);
|
s = text_to_cstring(b);
|
||||||
memcpy(s, VARDATA(b), VARSIZE(b) - VARHDRSZ);
|
|
||||||
s[VARSIZE(b) - VARHDRSZ] = '\0';
|
|
||||||
|
|
||||||
tmp = (ltree *) DatumGetPointer(DirectFunctionCall1(
|
tmp = (ltree *) DatumGetPointer(DirectFunctionCall1(ltree_in,
|
||||||
ltree_in,
|
PointerGetDatum(s)));
|
||||||
PointerGetDatum(s)
|
|
||||||
));
|
|
||||||
|
|
||||||
pfree(s);
|
pfree(s);
|
||||||
|
|
||||||
@ -517,17 +509,14 @@ lca(PG_FUNCTION_ARGS)
|
|||||||
Datum
|
Datum
|
||||||
text2ltree(PG_FUNCTION_ARGS)
|
text2ltree(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
text *in = PG_GETARG_TEXT_P(0);
|
text *in = PG_GETARG_TEXT_PP(0);
|
||||||
char *s = (char *) palloc(VARSIZE(in) - VARHDRSZ + 1);
|
char *s;
|
||||||
ltree *out;
|
ltree *out;
|
||||||
|
|
||||||
memcpy(s, VARDATA(in), VARSIZE(in) - VARHDRSZ);
|
s = text_to_cstring(in);
|
||||||
s[VARSIZE(in) - VARHDRSZ] = '\0';
|
|
||||||
|
|
||||||
out = (ltree *) DatumGetPointer(DirectFunctionCall1(
|
out = (ltree *) DatumGetPointer(DirectFunctionCall1(ltree_in,
|
||||||
ltree_in,
|
PointerGetDatum(s)));
|
||||||
PointerGetDatum(s)
|
|
||||||
));
|
|
||||||
pfree(s);
|
pfree(s);
|
||||||
PG_FREE_IF_COPY(in, 0);
|
PG_FREE_IF_COPY(in, 0);
|
||||||
PG_RETURN_POINTER(out);
|
PG_RETURN_POINTER(out);
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
* Copyright (c) 2007-2008, PostgreSQL Global Development Group
|
* Copyright (c) 2007-2008, PostgreSQL Global Development Group
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/contrib/pageinspect/heapfuncs.c,v 1.4 2008/01/01 20:31:21 tgl Exp $
|
* $PostgreSQL: pgsql/contrib/pageinspect/heapfuncs.c,v 1.5 2008/03/25 22:42:41 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -36,8 +36,6 @@
|
|||||||
|
|
||||||
Datum heap_page_items(PG_FUNCTION_ARGS);
|
Datum heap_page_items(PG_FUNCTION_ARGS);
|
||||||
|
|
||||||
#define GET_TEXT(str_) \
|
|
||||||
DirectFunctionCall1(textin, CStringGetDatum(str_))
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* bits_to_text
|
* bits_to_text
|
||||||
@ -190,8 +188,8 @@ heap_page_items(PG_FUNCTION_ARGS)
|
|||||||
bits_len = tuphdr->t_hoff -
|
bits_len = tuphdr->t_hoff -
|
||||||
(((char *) tuphdr->t_bits) -((char *) tuphdr));
|
(((char *) tuphdr->t_bits) -((char *) tuphdr));
|
||||||
|
|
||||||
values[11] = GET_TEXT(
|
values[11] = CStringGetTextDatum(
|
||||||
bits_to_text(tuphdr->t_bits, bits_len * 8));
|
bits_to_text(tuphdr->t_bits, bits_len * 8));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
nulls[11] = true;
|
nulls[11] = true;
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
* Copyright (c) 2007-2008, PostgreSQL Global Development Group
|
* Copyright (c) 2007-2008, PostgreSQL Global Development Group
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/contrib/pageinspect/rawpage.c,v 1.4 2008/01/01 20:31:21 tgl Exp $
|
* $PostgreSQL: pgsql/contrib/pageinspect/rawpage.c,v 1.5 2008/03/25 22:42:41 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -144,7 +144,7 @@ page_header(PG_FUNCTION_ARGS)
|
|||||||
lsn = PageGetLSN(page);
|
lsn = PageGetLSN(page);
|
||||||
snprintf(lsnchar, sizeof(lsnchar), "%X/%X", lsn.xlogid, lsn.xrecoff);
|
snprintf(lsnchar, sizeof(lsnchar), "%X/%X", lsn.xlogid, lsn.xrecoff);
|
||||||
|
|
||||||
values[0] = DirectFunctionCall1(textin, CStringGetDatum(lsnchar));
|
values[0] = CStringGetTextDatum(lsnchar);
|
||||||
values[1] = UInt16GetDatum(PageGetTLI(page));
|
values[1] = UInt16GetDatum(PageGetTLI(page));
|
||||||
values[2] = UInt16GetDatum(page->pd_flags);
|
values[2] = UInt16GetDatum(page->pd_flags);
|
||||||
values[3] = UInt16GetDatum(page->pd_lower);
|
values[3] = UInt16GetDatum(page->pd_lower);
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/contrib/pgcrypto/pgcrypto.c,v 1.26 2007/02/27 23:48:06 tgl Exp $
|
* $PostgreSQL: pgsql/contrib/pgcrypto/pgcrypto.c,v 1.27 2008/03/25 22:42:41 tgl Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
@ -35,6 +35,7 @@
|
|||||||
|
|
||||||
#include "fmgr.h"
|
#include "fmgr.h"
|
||||||
#include "parser/scansup.h"
|
#include "parser/scansup.h"
|
||||||
|
#include "utils/builtins.h"
|
||||||
|
|
||||||
#include "px.h"
|
#include "px.h"
|
||||||
#include "px-crypt.h"
|
#include "px-crypt.h"
|
||||||
@ -132,30 +133,20 @@ PG_FUNCTION_INFO_V1(pg_gen_salt);
|
|||||||
Datum
|
Datum
|
||||||
pg_gen_salt(PG_FUNCTION_ARGS)
|
pg_gen_salt(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
text *arg0;
|
text *arg0 = PG_GETARG_TEXT_PP(0);
|
||||||
int len;
|
int len;
|
||||||
text *res;
|
|
||||||
char buf[PX_MAX_SALT_LEN + 1];
|
char buf[PX_MAX_SALT_LEN + 1];
|
||||||
|
|
||||||
arg0 = PG_GETARG_TEXT_P(0);
|
text_to_cstring_buffer(arg0, buf, sizeof(buf));
|
||||||
|
|
||||||
len = VARSIZE(arg0) - VARHDRSZ;
|
|
||||||
len = len > PX_MAX_SALT_LEN ? PX_MAX_SALT_LEN : len;
|
|
||||||
memcpy(buf, VARDATA(arg0), len);
|
|
||||||
buf[len] = 0;
|
|
||||||
len = px_gen_salt(buf, buf, 0);
|
len = px_gen_salt(buf, buf, 0);
|
||||||
if (len < 0)
|
if (len < 0)
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||||
errmsg("gen_salt: %s", px_strerror(len))));
|
errmsg("gen_salt: %s", px_strerror(len))));
|
||||||
|
|
||||||
res = (text *) palloc(len + VARHDRSZ);
|
|
||||||
SET_VARSIZE(res, len + VARHDRSZ);
|
|
||||||
memcpy(VARDATA(res), buf, len);
|
|
||||||
|
|
||||||
PG_FREE_IF_COPY(arg0, 0);
|
PG_FREE_IF_COPY(arg0, 0);
|
||||||
|
|
||||||
PG_RETURN_TEXT_P(res);
|
PG_RETURN_TEXT_P(cstring_to_text_with_len(buf, len));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* SQL function: pg_gen_salt(text, int4) returns text */
|
/* SQL function: pg_gen_salt(text, int4) returns text */
|
||||||
@ -164,32 +155,21 @@ PG_FUNCTION_INFO_V1(pg_gen_salt_rounds);
|
|||||||
Datum
|
Datum
|
||||||
pg_gen_salt_rounds(PG_FUNCTION_ARGS)
|
pg_gen_salt_rounds(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
text *arg0;
|
text *arg0 = PG_GETARG_TEXT_PP(0);
|
||||||
int rounds;
|
int rounds = PG_GETARG_INT32(1);
|
||||||
int len;
|
int len;
|
||||||
text *res;
|
|
||||||
char buf[PX_MAX_SALT_LEN + 1];
|
char buf[PX_MAX_SALT_LEN + 1];
|
||||||
|
|
||||||
arg0 = PG_GETARG_TEXT_P(0);
|
text_to_cstring_buffer(arg0, buf, sizeof(buf));
|
||||||
rounds = PG_GETARG_INT32(1);
|
|
||||||
|
|
||||||
len = VARSIZE(arg0) - VARHDRSZ;
|
|
||||||
len = len > PX_MAX_SALT_LEN ? PX_MAX_SALT_LEN : len;
|
|
||||||
memcpy(buf, VARDATA(arg0), len);
|
|
||||||
buf[len] = 0;
|
|
||||||
len = px_gen_salt(buf, buf, rounds);
|
len = px_gen_salt(buf, buf, rounds);
|
||||||
if (len < 0)
|
if (len < 0)
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||||
errmsg("gen_salt: %s", px_strerror(len))));
|
errmsg("gen_salt: %s", px_strerror(len))));
|
||||||
|
|
||||||
res = (text *) palloc(len + VARHDRSZ);
|
|
||||||
SET_VARSIZE(res, len + VARHDRSZ);
|
|
||||||
memcpy(VARDATA(res), buf, len);
|
|
||||||
|
|
||||||
PG_FREE_IF_COPY(arg0, 0);
|
PG_FREE_IF_COPY(arg0, 0);
|
||||||
|
|
||||||
PG_RETURN_TEXT_P(res);
|
PG_RETURN_TEXT_P(cstring_to_text_with_len(buf, len));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* SQL function: pg_crypt(psw:text, salt:text) returns text */
|
/* SQL function: pg_crypt(psw:text, salt:text) returns text */
|
||||||
@ -198,30 +178,16 @@ PG_FUNCTION_INFO_V1(pg_crypt);
|
|||||||
Datum
|
Datum
|
||||||
pg_crypt(PG_FUNCTION_ARGS)
|
pg_crypt(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
text *arg0;
|
text *arg0 = PG_GETARG_TEXT_PP(0);
|
||||||
text *arg1;
|
text *arg1 = PG_GETARG_TEXT_PP(1);
|
||||||
unsigned len0,
|
|
||||||
len1,
|
|
||||||
clen;
|
|
||||||
char *buf0,
|
char *buf0,
|
||||||
*buf1,
|
*buf1,
|
||||||
*cres,
|
*cres,
|
||||||
*resbuf;
|
*resbuf;
|
||||||
text *res;
|
text *res;
|
||||||
|
|
||||||
arg0 = PG_GETARG_TEXT_P(0);
|
buf0 = text_to_cstring(arg0);
|
||||||
arg1 = PG_GETARG_TEXT_P(1);
|
buf1 = text_to_cstring(arg1);
|
||||||
len0 = VARSIZE(arg0) - VARHDRSZ;
|
|
||||||
len1 = VARSIZE(arg1) - VARHDRSZ;
|
|
||||||
|
|
||||||
buf0 = palloc(len0 + 1);
|
|
||||||
buf1 = palloc(len1 + 1);
|
|
||||||
|
|
||||||
memcpy(buf0, VARDATA(arg0), len0);
|
|
||||||
memcpy(buf1, VARDATA(arg1), len1);
|
|
||||||
|
|
||||||
buf0[len0] = '\0';
|
|
||||||
buf1[len1] = '\0';
|
|
||||||
|
|
||||||
resbuf = palloc0(PX_MAX_CRYPT);
|
resbuf = palloc0(PX_MAX_CRYPT);
|
||||||
|
|
||||||
@ -235,11 +201,8 @@ pg_crypt(PG_FUNCTION_ARGS)
|
|||||||
(errcode(ERRCODE_EXTERNAL_ROUTINE_INVOCATION_EXCEPTION),
|
(errcode(ERRCODE_EXTERNAL_ROUTINE_INVOCATION_EXCEPTION),
|
||||||
errmsg("crypt(3) returned NULL")));
|
errmsg("crypt(3) returned NULL")));
|
||||||
|
|
||||||
clen = strlen(cres);
|
res = cstring_to_text(cres);
|
||||||
|
|
||||||
res = (text *) palloc(clen + VARHDRSZ);
|
|
||||||
SET_VARSIZE(res, clen + VARHDRSZ);
|
|
||||||
memcpy(VARDATA(res), cres, clen);
|
|
||||||
pfree(resbuf);
|
pfree(resbuf);
|
||||||
|
|
||||||
PG_FREE_IF_COPY(arg0, 0);
|
PG_FREE_IF_COPY(arg0, 0);
|
||||||
|
@ -88,8 +88,7 @@ autoinc(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
i++;
|
i++;
|
||||||
chattrs[chnattrs] = attnum;
|
chattrs[chnattrs] = attnum;
|
||||||
seqname = DirectFunctionCall1(textin,
|
seqname = CStringGetTextDatum(args[i]);
|
||||||
CStringGetDatum(args[i]));
|
|
||||||
newvals[chnattrs] = DirectFunctionCall1(nextval, seqname);
|
newvals[chnattrs] = DirectFunctionCall1(nextval, seqname);
|
||||||
/* nextval now returns int64; coerce down to int32 */
|
/* nextval now returns int64; coerce down to int32 */
|
||||||
newvals[chnattrs] = Int32GetDatum((int32) DatumGetInt64(newvals[chnattrs]));
|
newvals[chnattrs] = Int32GetDatum((int32) DatumGetInt64(newvals[chnattrs]));
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* insert_username.c
|
* insert_username.c
|
||||||
* $Modified: Thu Oct 16 08:13:42 1997 by brook $
|
* $Modified: Thu Oct 16 08:13:42 1997 by brook $
|
||||||
* $PostgreSQL: pgsql/contrib/spi/insert_username.c,v 1.15 2007/02/01 19:10:23 momjian Exp $
|
* $PostgreSQL: pgsql/contrib/spi/insert_username.c,v 1.16 2008/03/25 22:42:42 tgl Exp $
|
||||||
*
|
*
|
||||||
* insert user name in response to a trigger
|
* insert user name in response to a trigger
|
||||||
* usage: insert_username (column_name)
|
* usage: insert_username (column_name)
|
||||||
@ -77,8 +77,7 @@ insert_username(PG_FUNCTION_ARGS)
|
|||||||
args[0], relname)));
|
args[0], relname)));
|
||||||
|
|
||||||
/* create fields containing name */
|
/* create fields containing name */
|
||||||
newval = DirectFunctionCall1(textin,
|
newval = CStringGetTextDatum(GetUserNameFromId(GetUserId()));
|
||||||
CStringGetDatum(GetUserNameFromId(GetUserId())));
|
|
||||||
|
|
||||||
/* construct new tuple */
|
/* construct new tuple */
|
||||||
rettuple = SPI_modifytuple(rel, rettuple, 1, &attnum, &newval, NULL);
|
rettuple = SPI_modifytuple(rel, rettuple, 1, &attnum, &newval, NULL);
|
||||||
|
@ -172,7 +172,7 @@ timetravel(PG_FUNCTION_ARGS)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* create fields containing name */
|
/* create fields containing name */
|
||||||
newuser = DirectFunctionCall1(textin, CStringGetDatum(GetUserNameFromId(GetUserId())));
|
newuser = CStringGetTextDatum(GetUserNameFromId(GetUserId()));
|
||||||
|
|
||||||
nulltext = (Datum) NULL;
|
nulltext = (Datum) NULL;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* Written by Victor B. Wagner <vitus@cryptocom.ru>, Cryptocom LTD
|
* Written by Victor B. Wagner <vitus@cryptocom.ru>, Cryptocom LTD
|
||||||
* This file is distributed under BSD-style license.
|
* This file is distributed under BSD-style license.
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/contrib/sslinfo/sslinfo.c,v 1.6 2007/02/27 23:48:06 tgl Exp $
|
* $PostgreSQL: pgsql/contrib/sslinfo/sslinfo.c,v 1.7 2008/03/25 22:42:42 tgl Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
@ -133,10 +133,7 @@ ASN1_STRING_to_text(ASN1_STRING *str)
|
|||||||
size - 1,
|
size - 1,
|
||||||
PG_UTF8,
|
PG_UTF8,
|
||||||
GetDatabaseEncoding());
|
GetDatabaseEncoding());
|
||||||
outlen = strlen(dp);
|
result = cstring_to_text(dp);
|
||||||
result = palloc(VARHDRSZ + outlen);
|
|
||||||
memcpy(VARDATA(result), dp, outlen);
|
|
||||||
SET_VARSIZE(result, VARHDRSZ + outlen);
|
|
||||||
|
|
||||||
if (dp != sp)
|
if (dp != sp)
|
||||||
pfree(dp);
|
pfree(dp);
|
||||||
@ -161,21 +158,12 @@ ASN1_STRING_to_text(ASN1_STRING *str)
|
|||||||
Datum
|
Datum
|
||||||
X509_NAME_field_to_text(X509_NAME *name, text *fieldName)
|
X509_NAME_field_to_text(X509_NAME *name, text *fieldName)
|
||||||
{
|
{
|
||||||
char *sp;
|
|
||||||
char *string_fieldname;
|
char *string_fieldname;
|
||||||
char *dp;
|
|
||||||
size_t name_len = VARSIZE(fieldName) - VARHDRSZ;
|
|
||||||
int nid,
|
int nid,
|
||||||
index,
|
index;
|
||||||
i;
|
|
||||||
ASN1_STRING *data;
|
ASN1_STRING *data;
|
||||||
|
|
||||||
string_fieldname = palloc(name_len + 1);
|
string_fieldname = text_to_cstring(fieldName);
|
||||||
sp = VARDATA(fieldName);
|
|
||||||
dp = string_fieldname;
|
|
||||||
for (i = 0; i < name_len; i++)
|
|
||||||
*dp++ = *sp++;
|
|
||||||
*dp = '\0';
|
|
||||||
nid = OBJ_txt2nid(string_fieldname);
|
nid = OBJ_txt2nid(string_fieldname);
|
||||||
if (nid == NID_undef)
|
if (nid == NID_undef)
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
@ -281,10 +269,8 @@ X509_NAME_to_text(X509_NAME *name)
|
|||||||
count = X509_NAME_entry_count(name);
|
count = X509_NAME_entry_count(name);
|
||||||
X509_NAME_ENTRY *e;
|
X509_NAME_ENTRY *e;
|
||||||
ASN1_STRING *v;
|
ASN1_STRING *v;
|
||||||
|
|
||||||
const char *field_name;
|
const char *field_name;
|
||||||
size_t size,
|
size_t size;
|
||||||
outlen;
|
|
||||||
char *sp;
|
char *sp;
|
||||||
char *dp;
|
char *dp;
|
||||||
text *result;
|
text *result;
|
||||||
@ -314,10 +300,7 @@ X509_NAME_to_text(X509_NAME *name)
|
|||||||
GetDatabaseEncoding());
|
GetDatabaseEncoding());
|
||||||
BIO_free(membuf);
|
BIO_free(membuf);
|
||||||
|
|
||||||
outlen = strlen(dp);
|
result = cstring_to_text(dp);
|
||||||
result = palloc(VARHDRSZ + outlen);
|
|
||||||
memcpy(VARDATA(result), dp, outlen);
|
|
||||||
SET_VARSIZE(result, VARHDRSZ + outlen);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* pg_do_encoding_conversion has annoying habit of returning source
|
* pg_do_encoding_conversion has annoying habit of returning source
|
||||||
|
@ -95,8 +95,6 @@ typedef struct
|
|||||||
char *lastrowid; /* rowid of the last tuple sent */
|
char *lastrowid; /* rowid of the last tuple sent */
|
||||||
} crosstab_fctx;
|
} crosstab_fctx;
|
||||||
|
|
||||||
#define GET_TEXT(cstrp) DatumGetTextP(DirectFunctionCall1(textin, CStringGetDatum(cstrp)))
|
|
||||||
#define GET_STR(textp) DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(textp)))
|
|
||||||
#define xpfree(var_) \
|
#define xpfree(var_) \
|
||||||
do { \
|
do { \
|
||||||
if (var_ != NULL) \
|
if (var_ != NULL) \
|
||||||
@ -370,7 +368,7 @@ crosstab(PG_FUNCTION_ARGS)
|
|||||||
/* stuff done only on the first call of the function */
|
/* stuff done only on the first call of the function */
|
||||||
if (SRF_IS_FIRSTCALL())
|
if (SRF_IS_FIRSTCALL())
|
||||||
{
|
{
|
||||||
char *sql = GET_STR(PG_GETARG_TEXT_P(0));
|
char *sql = text_to_cstring(PG_GETARG_TEXT_PP(0));
|
||||||
TupleDesc tupdesc;
|
TupleDesc tupdesc;
|
||||||
int ret;
|
int ret;
|
||||||
int proc;
|
int proc;
|
||||||
@ -695,8 +693,8 @@ PG_FUNCTION_INFO_V1(crosstab_hash);
|
|||||||
Datum
|
Datum
|
||||||
crosstab_hash(PG_FUNCTION_ARGS)
|
crosstab_hash(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
char *sql = GET_STR(PG_GETARG_TEXT_P(0));
|
char *sql = text_to_cstring(PG_GETARG_TEXT_PP(0));
|
||||||
char *cats_sql = GET_STR(PG_GETARG_TEXT_P(1));
|
char *cats_sql = text_to_cstring(PG_GETARG_TEXT_PP(1));
|
||||||
ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo;
|
ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo;
|
||||||
TupleDesc tupdesc;
|
TupleDesc tupdesc;
|
||||||
MemoryContext per_query_ctx;
|
MemoryContext per_query_ctx;
|
||||||
@ -1052,10 +1050,10 @@ PG_FUNCTION_INFO_V1(connectby_text);
|
|||||||
Datum
|
Datum
|
||||||
connectby_text(PG_FUNCTION_ARGS)
|
connectby_text(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
char *relname = GET_STR(PG_GETARG_TEXT_P(0));
|
char *relname = text_to_cstring(PG_GETARG_TEXT_PP(0));
|
||||||
char *key_fld = GET_STR(PG_GETARG_TEXT_P(1));
|
char *key_fld = text_to_cstring(PG_GETARG_TEXT_PP(1));
|
||||||
char *parent_key_fld = GET_STR(PG_GETARG_TEXT_P(2));
|
char *parent_key_fld = text_to_cstring(PG_GETARG_TEXT_PP(2));
|
||||||
char *start_with = GET_STR(PG_GETARG_TEXT_P(3));
|
char *start_with = text_to_cstring(PG_GETARG_TEXT_PP(3));
|
||||||
int max_depth = PG_GETARG_INT32(4);
|
int max_depth = PG_GETARG_INT32(4);
|
||||||
char *branch_delim = NULL;
|
char *branch_delim = NULL;
|
||||||
bool show_branch = false;
|
bool show_branch = false;
|
||||||
@ -1079,7 +1077,7 @@ connectby_text(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
if (fcinfo->nargs == 6)
|
if (fcinfo->nargs == 6)
|
||||||
{
|
{
|
||||||
branch_delim = GET_STR(PG_GETARG_TEXT_P(5));
|
branch_delim = text_to_cstring(PG_GETARG_TEXT_PP(5));
|
||||||
show_branch = true;
|
show_branch = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1129,11 +1127,11 @@ PG_FUNCTION_INFO_V1(connectby_text_serial);
|
|||||||
Datum
|
Datum
|
||||||
connectby_text_serial(PG_FUNCTION_ARGS)
|
connectby_text_serial(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
char *relname = GET_STR(PG_GETARG_TEXT_P(0));
|
char *relname = text_to_cstring(PG_GETARG_TEXT_PP(0));
|
||||||
char *key_fld = GET_STR(PG_GETARG_TEXT_P(1));
|
char *key_fld = text_to_cstring(PG_GETARG_TEXT_PP(1));
|
||||||
char *parent_key_fld = GET_STR(PG_GETARG_TEXT_P(2));
|
char *parent_key_fld = text_to_cstring(PG_GETARG_TEXT_PP(2));
|
||||||
char *orderby_fld = GET_STR(PG_GETARG_TEXT_P(3));
|
char *orderby_fld = text_to_cstring(PG_GETARG_TEXT_PP(3));
|
||||||
char *start_with = GET_STR(PG_GETARG_TEXT_P(4));
|
char *start_with = text_to_cstring(PG_GETARG_TEXT_PP(4));
|
||||||
int max_depth = PG_GETARG_INT32(5);
|
int max_depth = PG_GETARG_INT32(5);
|
||||||
char *branch_delim = NULL;
|
char *branch_delim = NULL;
|
||||||
bool show_branch = false;
|
bool show_branch = false;
|
||||||
@ -1158,7 +1156,7 @@ connectby_text_serial(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
if (fcinfo->nargs == 7)
|
if (fcinfo->nargs == 7)
|
||||||
{
|
{
|
||||||
branch_delim = GET_STR(PG_GETARG_TEXT_P(6));
|
branch_delim = text_to_cstring(PG_GETARG_TEXT_PP(6));
|
||||||
show_branch = true;
|
show_branch = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1645,9 +1643,10 @@ quote_literal_cstr(char *rawstr)
|
|||||||
text *result_text;
|
text *result_text;
|
||||||
char *result;
|
char *result;
|
||||||
|
|
||||||
rawstr_text = DatumGetTextP(DirectFunctionCall1(textin, CStringGetDatum(rawstr)));
|
rawstr_text = cstring_to_text(rawstr);
|
||||||
result_text = DatumGetTextP(DirectFunctionCall1(quote_literal, PointerGetDatum(rawstr_text)));
|
result_text = DatumGetTextP(DirectFunctionCall1(quote_literal,
|
||||||
result = DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(result_text)));
|
PointerGetDatum(rawstr_text)));
|
||||||
|
result = text_to_cstring(result_text);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/contrib/tsearch2/tsearch2.c,v 1.5 2008/01/01 19:45:45 momjian Exp $
|
* $PostgreSQL: pgsql/contrib/tsearch2/tsearch2.c,v 1.6 2008/03/25 22:42:42 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -41,14 +41,9 @@ static Oid current_parser_oid = InvalidOid;
|
|||||||
fcinfo->nargs++; \
|
fcinfo->nargs++; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define TextPGetCString(t) \
|
|
||||||
DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(t)))
|
|
||||||
#define CStringGetTextP(c) \
|
|
||||||
DatumGetTextP(DirectFunctionCall1(textin, CStringGetDatum(c)))
|
|
||||||
|
|
||||||
#define TextGetObjectId(infunction, text) \
|
#define TextGetObjectId(infunction, text) \
|
||||||
DatumGetObjectId(DirectFunctionCall1(infunction, \
|
DatumGetObjectId(DirectFunctionCall1(infunction, \
|
||||||
DirectFunctionCall1(textout, PointerGetDatum(text))))
|
CStringGetDatum(text_to_cstring(text))))
|
||||||
|
|
||||||
#define UNSUPPORTED_FUNCTION(name) \
|
#define UNSUPPORTED_FUNCTION(name) \
|
||||||
Datum name(PG_FUNCTION_ARGS); \
|
Datum name(PG_FUNCTION_ARGS); \
|
||||||
@ -151,7 +146,7 @@ UNSUPPORTED_FUNCTION(tsa_get_covers);
|
|||||||
Datum
|
Datum
|
||||||
tsa_lexize_byname(PG_FUNCTION_ARGS)
|
tsa_lexize_byname(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
text *dictname = PG_GETARG_TEXT_P(0);
|
text *dictname = PG_GETARG_TEXT_PP(0);
|
||||||
Datum arg1 = PG_GETARG_DATUM(1);
|
Datum arg1 = PG_GETARG_DATUM(1);
|
||||||
|
|
||||||
return DirectFunctionCall2(ts_lexize,
|
return DirectFunctionCall2(ts_lexize,
|
||||||
@ -192,10 +187,10 @@ tsa_set_curdict(PG_FUNCTION_ARGS)
|
|||||||
Datum
|
Datum
|
||||||
tsa_set_curdict_byname(PG_FUNCTION_ARGS)
|
tsa_set_curdict_byname(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
text *name = PG_GETARG_TEXT_P(0);
|
text *name = PG_GETARG_TEXT_PP(0);
|
||||||
Oid dict_oid;
|
Oid dict_oid;
|
||||||
|
|
||||||
dict_oid = TSDictionaryGetDictid(stringToQualifiedNameList(TextPGetCString(name)), false);
|
dict_oid = TSDictionaryGetDictid(stringToQualifiedNameList(text_to_cstring(name)), false);
|
||||||
|
|
||||||
current_dictionary_oid = dict_oid;
|
current_dictionary_oid = dict_oid;
|
||||||
|
|
||||||
@ -231,10 +226,10 @@ tsa_set_curprs(PG_FUNCTION_ARGS)
|
|||||||
Datum
|
Datum
|
||||||
tsa_set_curprs_byname(PG_FUNCTION_ARGS)
|
tsa_set_curprs_byname(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
text *name = PG_GETARG_TEXT_P(0);
|
text *name = PG_GETARG_TEXT_PP(0);
|
||||||
Oid parser_oid;
|
Oid parser_oid;
|
||||||
|
|
||||||
parser_oid = TSParserGetPrsid(stringToQualifiedNameList(TextPGetCString(name)), false);
|
parser_oid = TSParserGetPrsid(stringToQualifiedNameList(text_to_cstring(name)), false);
|
||||||
|
|
||||||
current_parser_oid = parser_oid;
|
current_parser_oid = parser_oid;
|
||||||
|
|
||||||
@ -272,10 +267,10 @@ tsa_set_curcfg(PG_FUNCTION_ARGS)
|
|||||||
Datum
|
Datum
|
||||||
tsa_set_curcfg_byname(PG_FUNCTION_ARGS)
|
tsa_set_curcfg_byname(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
text *arg0 = PG_GETARG_TEXT_P(0);
|
text *arg0 = PG_GETARG_TEXT_PP(0);
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
name = TextPGetCString(arg0);
|
name = text_to_cstring(arg0);
|
||||||
|
|
||||||
set_config_option("default_text_search_config", name,
|
set_config_option("default_text_search_config", name,
|
||||||
PGC_USERSET,
|
PGC_USERSET,
|
||||||
@ -290,7 +285,7 @@ tsa_set_curcfg_byname(PG_FUNCTION_ARGS)
|
|||||||
Datum
|
Datum
|
||||||
tsa_to_tsvector_name(PG_FUNCTION_ARGS)
|
tsa_to_tsvector_name(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
text *cfgname = PG_GETARG_TEXT_P(0);
|
text *cfgname = PG_GETARG_TEXT_PP(0);
|
||||||
Datum arg1 = PG_GETARG_DATUM(1);
|
Datum arg1 = PG_GETARG_DATUM(1);
|
||||||
Oid config_oid;
|
Oid config_oid;
|
||||||
|
|
||||||
@ -304,7 +299,7 @@ tsa_to_tsvector_name(PG_FUNCTION_ARGS)
|
|||||||
Datum
|
Datum
|
||||||
tsa_to_tsquery_name(PG_FUNCTION_ARGS)
|
tsa_to_tsquery_name(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
text *cfgname = PG_GETARG_TEXT_P(0);
|
text *cfgname = PG_GETARG_TEXT_PP(0);
|
||||||
Datum arg1 = PG_GETARG_DATUM(1);
|
Datum arg1 = PG_GETARG_DATUM(1);
|
||||||
Oid config_oid;
|
Oid config_oid;
|
||||||
|
|
||||||
@ -319,7 +314,7 @@ tsa_to_tsquery_name(PG_FUNCTION_ARGS)
|
|||||||
Datum
|
Datum
|
||||||
tsa_plainto_tsquery_name(PG_FUNCTION_ARGS)
|
tsa_plainto_tsquery_name(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
text *cfgname = PG_GETARG_TEXT_P(0);
|
text *cfgname = PG_GETARG_TEXT_PP(0);
|
||||||
Datum arg1 = PG_GETARG_DATUM(1);
|
Datum arg1 = PG_GETARG_DATUM(1);
|
||||||
Oid config_oid;
|
Oid config_oid;
|
||||||
|
|
||||||
@ -341,7 +336,7 @@ tsa_headline_byname(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
/* first parameter has to be converted to oid */
|
/* first parameter has to be converted to oid */
|
||||||
config_oid = DatumGetObjectId(DirectFunctionCall1(regconfigin,
|
config_oid = DatumGetObjectId(DirectFunctionCall1(regconfigin,
|
||||||
DirectFunctionCall1(textout, arg0)));
|
CStringGetDatum(TextDatumGetCString(arg0))));
|
||||||
|
|
||||||
if (PG_NARGS() == 3)
|
if (PG_NARGS() == 3)
|
||||||
result = DirectFunctionCall3(ts_headline_byid,
|
result = DirectFunctionCall3(ts_headline_byid,
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 2007-2008 PostgreSQL Global Development Group
|
* Copyright (c) 2007-2008 PostgreSQL Global Development Group
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/contrib/uuid-ossp/uuid-ossp.c,v 1.7 2008/01/01 20:31:21 tgl Exp $
|
* $PostgreSQL: pgsql/contrib/uuid-ossp/uuid-ossp.c,v 1.8 2008/03/25 22:42:42 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -214,7 +214,7 @@ uuid_generate_v35_internal(int mode, pg_uuid_t *ns, text *name)
|
|||||||
|
|
||||||
result = uuid_generate_internal(mode,
|
result = uuid_generate_internal(mode,
|
||||||
ns_uuid,
|
ns_uuid,
|
||||||
DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(name))));
|
text_to_cstring(name));
|
||||||
|
|
||||||
rc = uuid_destroy(ns_uuid);
|
rc = uuid_destroy(ns_uuid);
|
||||||
if (rc != UUID_RC_OK)
|
if (rc != UUID_RC_OK)
|
||||||
|
@ -55,11 +55,6 @@ Datum xpath_table(PG_FUNCTION_ARGS);
|
|||||||
char *errbuf; /* per line error buffer */
|
char *errbuf; /* per line error buffer */
|
||||||
char *pgxml_errorMsg = NULL; /* overall error message */
|
char *pgxml_errorMsg = NULL; /* overall error message */
|
||||||
|
|
||||||
/* Convenience macros */
|
|
||||||
|
|
||||||
#define GET_TEXT(cstrp) DatumGetTextP(DirectFunctionCall1(textin, CStringGetDatum(cstrp)))
|
|
||||||
#define GET_STR(textp) DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(textp)))
|
|
||||||
|
|
||||||
#define ERRBUF_SIZE 200
|
#define ERRBUF_SIZE 200
|
||||||
|
|
||||||
/* memory handling passthrough functions (e.g. palloc, pstrdup are
|
/* memory handling passthrough functions (e.g. palloc, pstrdup are
|
||||||
@ -651,11 +646,11 @@ xpath_table(PG_FUNCTION_ARGS)
|
|||||||
MemoryContext oldcontext;
|
MemoryContext oldcontext;
|
||||||
|
|
||||||
/* Function parameters */
|
/* Function parameters */
|
||||||
char *pkeyfield = GET_STR(PG_GETARG_TEXT_P(0));
|
char *pkeyfield = text_to_cstring(PG_GETARG_TEXT_PP(0));
|
||||||
char *xmlfield = GET_STR(PG_GETARG_TEXT_P(1));
|
char *xmlfield = text_to_cstring(PG_GETARG_TEXT_PP(1));
|
||||||
char *relname = GET_STR(PG_GETARG_TEXT_P(2));
|
char *relname = text_to_cstring(PG_GETARG_TEXT_PP(2));
|
||||||
char *xpathset = GET_STR(PG_GETARG_TEXT_P(3));
|
char *xpathset = text_to_cstring(PG_GETARG_TEXT_PP(3));
|
||||||
char *condition = GET_STR(PG_GETARG_TEXT_P(4));
|
char *condition = text_to_cstring(PG_GETARG_TEXT_PP(4));
|
||||||
|
|
||||||
char **values;
|
char **values;
|
||||||
xmlChar **xpaths;
|
xmlChar **xpaths;
|
||||||
|
@ -22,13 +22,10 @@
|
|||||||
|
|
||||||
|
|
||||||
/* declarations to come from xpath.c */
|
/* declarations to come from xpath.c */
|
||||||
|
|
||||||
extern void elog_error(int level, char *explain, int force);
|
extern void elog_error(int level, char *explain, int force);
|
||||||
extern void pgxml_parser_init();
|
extern void pgxml_parser_init();
|
||||||
extern xmlChar *pgxml_texttoxmlchar(text *textstring);
|
extern xmlChar *pgxml_texttoxmlchar(text *textstring);
|
||||||
|
|
||||||
#define GET_STR(textp) DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(textp)))
|
|
||||||
|
|
||||||
/* local defs */
|
/* local defs */
|
||||||
static void parse_params(const char **params, text *paramstr);
|
static void parse_params(const char **params, text *paramstr);
|
||||||
|
|
||||||
@ -76,7 +73,7 @@ xslt_process(PG_FUNCTION_ARGS)
|
|||||||
if (VARDATA(doct)[0] == '<')
|
if (VARDATA(doct)[0] == '<')
|
||||||
doctree = xmlParseMemory((char *) VARDATA(doct), VARSIZE(doct) - VARHDRSZ);
|
doctree = xmlParseMemory((char *) VARDATA(doct), VARSIZE(doct) - VARHDRSZ);
|
||||||
else
|
else
|
||||||
doctree = xmlParseFile(GET_STR(doct));
|
doctree = xmlParseFile(text_to_cstring(doct));
|
||||||
|
|
||||||
if (doctree == NULL)
|
if (doctree == NULL)
|
||||||
{
|
{
|
||||||
@ -102,7 +99,7 @@ xslt_process(PG_FUNCTION_ARGS)
|
|||||||
stylesheet = xsltParseStylesheetDoc(ssdoc);
|
stylesheet = xsltParseStylesheetDoc(ssdoc);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
stylesheet = xsltParseStylesheetFile((xmlChar *) GET_STR(ssheet));
|
stylesheet = xsltParseStylesheetFile((xmlChar *) text_to_cstring(ssheet));
|
||||||
|
|
||||||
|
|
||||||
if (stylesheet == NULL)
|
if (stylesheet == NULL)
|
||||||
@ -145,7 +142,7 @@ parse_params(const char **params, text *paramstr)
|
|||||||
char *nvsep = "=";
|
char *nvsep = "=";
|
||||||
char *itsep = ",";
|
char *itsep = ",";
|
||||||
|
|
||||||
pstr = GET_STR(paramstr);
|
pstr = text_to_cstring(paramstr);
|
||||||
|
|
||||||
pos = pstr;
|
pos = pstr;
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/spi.sgml,v 1.60 2008/02/12 04:09:44 tgl Exp $ -->
|
<!-- $PostgreSQL: pgsql/doc/src/sgml/spi.sgml,v 1.61 2008/03/25 22:42:42 tgl Exp $ -->
|
||||||
|
|
||||||
<chapter id="spi">
|
<chapter id="spi">
|
||||||
<title>Server Programming Interface</title>
|
<title>Server Programming Interface</title>
|
||||||
@ -3343,8 +3343,7 @@ execq(text *sql, int cnt)
|
|||||||
int proc;
|
int proc;
|
||||||
|
|
||||||
/* Convert given text object to a C string */
|
/* Convert given text object to a C string */
|
||||||
command = DatumGetCString(DirectFunctionCall1(textout,
|
command = text_to_cstring(sql);
|
||||||
PointerGetDatum(sql)));
|
|
||||||
|
|
||||||
SPI_connect();
|
SPI_connect();
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/access/common/reloptions.c,v 1.8 2008/01/01 19:45:46 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/access/common/reloptions.c,v 1.9 2008/03/25 22:42:42 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -180,7 +180,7 @@ untransformRelOptions(Datum options)
|
|||||||
char *p;
|
char *p;
|
||||||
Node *val = NULL;
|
Node *val = NULL;
|
||||||
|
|
||||||
s = DatumGetCString(DirectFunctionCall1(textout, optiondatums[i]));
|
s = TextDatumGetCString(optiondatums[i]);
|
||||||
p = strchr(s, '=');
|
p = strchr(s, '=');
|
||||||
if (p)
|
if (p)
|
||||||
{
|
{
|
||||||
@ -266,7 +266,7 @@ parseRelOptions(Datum options, int numkeywords, const char *const * keywords,
|
|||||||
char *s;
|
char *s;
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
s = DatumGetCString(DirectFunctionCall1(textout, optiondatums[i]));
|
s = TextDatumGetCString(optiondatums[i]);
|
||||||
p = strchr(s, '=');
|
p = strchr(s, '=');
|
||||||
if (p)
|
if (p)
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/access/transam/twophase.c,v 1.40 2008/03/17 02:18:55 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/access/transam/twophase.c,v 1.41 2008/03/25 22:42:42 tgl Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* Each global transaction is associated with a global transaction
|
* Each global transaction is associated with a global transaction
|
||||||
@ -623,7 +623,7 @@ pg_prepared_xact(PG_FUNCTION_ARGS)
|
|||||||
MemSet(nulls, 0, sizeof(nulls));
|
MemSet(nulls, 0, sizeof(nulls));
|
||||||
|
|
||||||
values[0] = TransactionIdGetDatum(gxact->proc.xid);
|
values[0] = TransactionIdGetDatum(gxact->proc.xid);
|
||||||
values[1] = DirectFunctionCall1(textin, CStringGetDatum(gxact->gid));
|
values[1] = CStringGetTextDatum(gxact->gid);
|
||||||
values[2] = TimestampTzGetDatum(gxact->prepared_at);
|
values[2] = TimestampTzGetDatum(gxact->prepared_at);
|
||||||
values[3] = ObjectIdGetDatum(gxact->owner);
|
values[3] = ObjectIdGetDatum(gxact->owner);
|
||||||
values[4] = ObjectIdGetDatum(gxact->proc.databaseId);
|
values[4] = ObjectIdGetDatum(gxact->proc.databaseId);
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.294 2008/03/10 02:13:22 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.295 2008/03/25 22:42:42 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -6380,7 +6380,6 @@ Datum
|
|||||||
pg_start_backup(PG_FUNCTION_ARGS)
|
pg_start_backup(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
text *backupid = PG_GETARG_TEXT_P(0);
|
text *backupid = PG_GETARG_TEXT_P(0);
|
||||||
text *result;
|
|
||||||
char *backupidstr;
|
char *backupidstr;
|
||||||
XLogRecPtr checkpointloc;
|
XLogRecPtr checkpointloc;
|
||||||
XLogRecPtr startpoint;
|
XLogRecPtr startpoint;
|
||||||
@ -6410,8 +6409,7 @@ pg_start_backup(PG_FUNCTION_ARGS)
|
|||||||
errhint("archive_command must be defined before "
|
errhint("archive_command must be defined before "
|
||||||
"online backups can be made safely.")));
|
"online backups can be made safely.")));
|
||||||
|
|
||||||
backupidstr = DatumGetCString(DirectFunctionCall1(textout,
|
backupidstr = text_to_cstring(backupid);
|
||||||
PointerGetDatum(backupid)));
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mark backup active in shared memory. We must do full-page WAL writes
|
* Mark backup active in shared memory. We must do full-page WAL writes
|
||||||
@ -6531,9 +6529,7 @@ pg_start_backup(PG_FUNCTION_ARGS)
|
|||||||
*/
|
*/
|
||||||
snprintf(xlogfilename, sizeof(xlogfilename), "%X/%X",
|
snprintf(xlogfilename, sizeof(xlogfilename), "%X/%X",
|
||||||
startpoint.xlogid, startpoint.xrecoff);
|
startpoint.xlogid, startpoint.xrecoff);
|
||||||
result = DatumGetTextP(DirectFunctionCall1(textin,
|
PG_RETURN_TEXT_P(cstring_to_text(xlogfilename));
|
||||||
CStringGetDatum(xlogfilename)));
|
|
||||||
PG_RETURN_TEXT_P(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -6547,7 +6543,6 @@ pg_start_backup(PG_FUNCTION_ARGS)
|
|||||||
Datum
|
Datum
|
||||||
pg_stop_backup(PG_FUNCTION_ARGS)
|
pg_stop_backup(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
text *result;
|
|
||||||
XLogRecPtr startpoint;
|
XLogRecPtr startpoint;
|
||||||
XLogRecPtr stoppoint;
|
XLogRecPtr stoppoint;
|
||||||
pg_time_t stamp_time;
|
pg_time_t stamp_time;
|
||||||
@ -6669,9 +6664,7 @@ pg_stop_backup(PG_FUNCTION_ARGS)
|
|||||||
*/
|
*/
|
||||||
snprintf(stopxlogfilename, sizeof(stopxlogfilename), "%X/%X",
|
snprintf(stopxlogfilename, sizeof(stopxlogfilename), "%X/%X",
|
||||||
stoppoint.xlogid, stoppoint.xrecoff);
|
stoppoint.xlogid, stoppoint.xrecoff);
|
||||||
result = DatumGetTextP(DirectFunctionCall1(textin,
|
PG_RETURN_TEXT_P(cstring_to_text(stopxlogfilename));
|
||||||
CStringGetDatum(stopxlogfilename)));
|
|
||||||
PG_RETURN_TEXT_P(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -6680,7 +6673,6 @@ pg_stop_backup(PG_FUNCTION_ARGS)
|
|||||||
Datum
|
Datum
|
||||||
pg_switch_xlog(PG_FUNCTION_ARGS)
|
pg_switch_xlog(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
text *result;
|
|
||||||
XLogRecPtr switchpoint;
|
XLogRecPtr switchpoint;
|
||||||
char location[MAXFNAMELEN];
|
char location[MAXFNAMELEN];
|
||||||
|
|
||||||
@ -6696,9 +6688,7 @@ pg_switch_xlog(PG_FUNCTION_ARGS)
|
|||||||
*/
|
*/
|
||||||
snprintf(location, sizeof(location), "%X/%X",
|
snprintf(location, sizeof(location), "%X/%X",
|
||||||
switchpoint.xlogid, switchpoint.xrecoff);
|
switchpoint.xlogid, switchpoint.xrecoff);
|
||||||
result = DatumGetTextP(DirectFunctionCall1(textin,
|
PG_RETURN_TEXT_P(cstring_to_text(location));
|
||||||
CStringGetDatum(location)));
|
|
||||||
PG_RETURN_TEXT_P(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -6711,7 +6701,6 @@ pg_switch_xlog(PG_FUNCTION_ARGS)
|
|||||||
Datum
|
Datum
|
||||||
pg_current_xlog_location(PG_FUNCTION_ARGS)
|
pg_current_xlog_location(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
text *result;
|
|
||||||
char location[MAXFNAMELEN];
|
char location[MAXFNAMELEN];
|
||||||
|
|
||||||
/* Make sure we have an up-to-date local LogwrtResult */
|
/* Make sure we have an up-to-date local LogwrtResult */
|
||||||
@ -6726,10 +6715,7 @@ pg_current_xlog_location(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
snprintf(location, sizeof(location), "%X/%X",
|
snprintf(location, sizeof(location), "%X/%X",
|
||||||
LogwrtResult.Write.xlogid, LogwrtResult.Write.xrecoff);
|
LogwrtResult.Write.xlogid, LogwrtResult.Write.xrecoff);
|
||||||
|
PG_RETURN_TEXT_P(cstring_to_text(location));
|
||||||
result = DatumGetTextP(DirectFunctionCall1(textin,
|
|
||||||
CStringGetDatum(location)));
|
|
||||||
PG_RETURN_TEXT_P(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -6740,7 +6726,6 @@ pg_current_xlog_location(PG_FUNCTION_ARGS)
|
|||||||
Datum
|
Datum
|
||||||
pg_current_xlog_insert_location(PG_FUNCTION_ARGS)
|
pg_current_xlog_insert_location(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
text *result;
|
|
||||||
XLogCtlInsert *Insert = &XLogCtl->Insert;
|
XLogCtlInsert *Insert = &XLogCtl->Insert;
|
||||||
XLogRecPtr current_recptr;
|
XLogRecPtr current_recptr;
|
||||||
char location[MAXFNAMELEN];
|
char location[MAXFNAMELEN];
|
||||||
@ -6754,10 +6739,7 @@ pg_current_xlog_insert_location(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
snprintf(location, sizeof(location), "%X/%X",
|
snprintf(location, sizeof(location), "%X/%X",
|
||||||
current_recptr.xlogid, current_recptr.xrecoff);
|
current_recptr.xlogid, current_recptr.xrecoff);
|
||||||
|
PG_RETURN_TEXT_P(cstring_to_text(location));
|
||||||
result = DatumGetTextP(DirectFunctionCall1(textin,
|
|
||||||
CStringGetDatum(location)));
|
|
||||||
PG_RETURN_TEXT_P(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -6789,8 +6771,7 @@ pg_xlogfile_name_offset(PG_FUNCTION_ARGS)
|
|||||||
/*
|
/*
|
||||||
* Read input and parse
|
* Read input and parse
|
||||||
*/
|
*/
|
||||||
locationstr = DatumGetCString(DirectFunctionCall1(textout,
|
locationstr = text_to_cstring(location);
|
||||||
PointerGetDatum(location)));
|
|
||||||
|
|
||||||
if (sscanf(locationstr, "%X/%X", &uxlogid, &uxrecoff) != 2)
|
if (sscanf(locationstr, "%X/%X", &uxlogid, &uxrecoff) != 2)
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
@ -6819,8 +6800,7 @@ pg_xlogfile_name_offset(PG_FUNCTION_ARGS)
|
|||||||
XLByteToPrevSeg(locationpoint, xlogid, xlogseg);
|
XLByteToPrevSeg(locationpoint, xlogid, xlogseg);
|
||||||
XLogFileName(xlogfilename, ThisTimeLineID, xlogid, xlogseg);
|
XLogFileName(xlogfilename, ThisTimeLineID, xlogid, xlogseg);
|
||||||
|
|
||||||
values[0] = DirectFunctionCall1(textin,
|
values[0] = CStringGetTextDatum(xlogfilename);
|
||||||
CStringGetDatum(xlogfilename));
|
|
||||||
isnull[0] = false;
|
isnull[0] = false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -6849,7 +6829,6 @@ Datum
|
|||||||
pg_xlogfile_name(PG_FUNCTION_ARGS)
|
pg_xlogfile_name(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
text *location = PG_GETARG_TEXT_P(0);
|
text *location = PG_GETARG_TEXT_P(0);
|
||||||
text *result;
|
|
||||||
char *locationstr;
|
char *locationstr;
|
||||||
unsigned int uxlogid;
|
unsigned int uxlogid;
|
||||||
unsigned int uxrecoff;
|
unsigned int uxrecoff;
|
||||||
@ -6858,8 +6837,7 @@ pg_xlogfile_name(PG_FUNCTION_ARGS)
|
|||||||
XLogRecPtr locationpoint;
|
XLogRecPtr locationpoint;
|
||||||
char xlogfilename[MAXFNAMELEN];
|
char xlogfilename[MAXFNAMELEN];
|
||||||
|
|
||||||
locationstr = DatumGetCString(DirectFunctionCall1(textout,
|
locationstr = text_to_cstring(location);
|
||||||
PointerGetDatum(location)));
|
|
||||||
|
|
||||||
if (sscanf(locationstr, "%X/%X", &uxlogid, &uxrecoff) != 2)
|
if (sscanf(locationstr, "%X/%X", &uxlogid, &uxrecoff) != 2)
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
@ -6873,9 +6851,7 @@ pg_xlogfile_name(PG_FUNCTION_ARGS)
|
|||||||
XLByteToPrevSeg(locationpoint, xlogid, xlogseg);
|
XLByteToPrevSeg(locationpoint, xlogid, xlogseg);
|
||||||
XLogFileName(xlogfilename, ThisTimeLineID, xlogid, xlogseg);
|
XLogFileName(xlogfilename, ThisTimeLineID, xlogid, xlogseg);
|
||||||
|
|
||||||
result = DatumGetTextP(DirectFunctionCall1(textin,
|
PG_RETURN_TEXT_P(cstring_to_text(xlogfilename));
|
||||||
CStringGetDatum(xlogfilename)));
|
|
||||||
PG_RETURN_TEXT_P(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/catalog/heap.c,v 1.327 2008/01/01 19:45:48 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/catalog/heap.c,v 1.328 2008/03/25 22:42:42 tgl Exp $
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* INTERFACE ROUTINES
|
* INTERFACE ROUTINES
|
||||||
@ -1459,10 +1459,8 @@ StoreAttrDefault(Relation rel, AttrNumber attnum, char *adbin)
|
|||||||
*/
|
*/
|
||||||
values[Anum_pg_attrdef_adrelid - 1] = RelationGetRelid(rel);
|
values[Anum_pg_attrdef_adrelid - 1] = RelationGetRelid(rel);
|
||||||
values[Anum_pg_attrdef_adnum - 1] = attnum;
|
values[Anum_pg_attrdef_adnum - 1] = attnum;
|
||||||
values[Anum_pg_attrdef_adbin - 1] = DirectFunctionCall1(textin,
|
values[Anum_pg_attrdef_adbin - 1] = CStringGetTextDatum(adbin);
|
||||||
CStringGetDatum(adbin));
|
values[Anum_pg_attrdef_adsrc - 1] = CStringGetTextDatum(adsrc);
|
||||||
values[Anum_pg_attrdef_adsrc - 1] = DirectFunctionCall1(textin,
|
|
||||||
CStringGetDatum(adsrc));
|
|
||||||
|
|
||||||
adrel = heap_open(AttrDefaultRelationId, RowExclusiveLock);
|
adrel = heap_open(AttrDefaultRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/catalog/index.c,v 1.292 2008/01/30 19:46:48 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/catalog/index.c,v 1.293 2008/03/25 22:42:42 tgl Exp $
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* INTERFACE ROUTINES
|
* INTERFACE ROUTINES
|
||||||
@ -374,8 +374,7 @@ UpdateIndexRelation(Oid indexoid,
|
|||||||
char *exprsString;
|
char *exprsString;
|
||||||
|
|
||||||
exprsString = nodeToString(indexInfo->ii_Expressions);
|
exprsString = nodeToString(indexInfo->ii_Expressions);
|
||||||
exprsDatum = DirectFunctionCall1(textin,
|
exprsDatum = CStringGetTextDatum(exprsString);
|
||||||
CStringGetDatum(exprsString));
|
|
||||||
pfree(exprsString);
|
pfree(exprsString);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -390,8 +389,7 @@ UpdateIndexRelation(Oid indexoid,
|
|||||||
char *predString;
|
char *predString;
|
||||||
|
|
||||||
predString = nodeToString(make_ands_explicit(indexInfo->ii_Predicate));
|
predString = nodeToString(make_ands_explicit(indexInfo->ii_Predicate));
|
||||||
predDatum = DirectFunctionCall1(textin,
|
predDatum = CStringGetTextDatum(predString);
|
||||||
CStringGetDatum(predString));
|
|
||||||
pfree(predString);
|
pfree(predString);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/catalog/pg_aggregate.c,v 1.90 2008/01/11 18:39:40 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/catalog/pg_aggregate.c,v 1.91 2008/03/25 22:42:42 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -232,8 +232,7 @@ AggregateCreate(const char *aggName,
|
|||||||
values[Anum_pg_aggregate_aggsortop - 1] = ObjectIdGetDatum(sortop);
|
values[Anum_pg_aggregate_aggsortop - 1] = ObjectIdGetDatum(sortop);
|
||||||
values[Anum_pg_aggregate_aggtranstype - 1] = ObjectIdGetDatum(aggTransType);
|
values[Anum_pg_aggregate_aggtranstype - 1] = ObjectIdGetDatum(aggTransType);
|
||||||
if (agginitval)
|
if (agginitval)
|
||||||
values[Anum_pg_aggregate_agginitval - 1] =
|
values[Anum_pg_aggregate_agginitval - 1] = CStringGetTextDatum(agginitval);
|
||||||
DirectFunctionCall1(textin, CStringGetDatum(agginitval));
|
|
||||||
else
|
else
|
||||||
nulls[Anum_pg_aggregate_agginitval - 1] = 'n';
|
nulls[Anum_pg_aggregate_agginitval - 1] = 'n';
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/catalog/pg_constraint.c,v 1.38 2008/01/17 18:56:54 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/catalog/pg_constraint.c,v 1.39 2008/03/25 22:42:42 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -174,8 +174,7 @@ CreateConstraintEntry(const char *constraintName,
|
|||||||
* initialize the binary form of the check constraint.
|
* initialize the binary form of the check constraint.
|
||||||
*/
|
*/
|
||||||
if (conBin)
|
if (conBin)
|
||||||
values[Anum_pg_constraint_conbin - 1] = DirectFunctionCall1(textin,
|
values[Anum_pg_constraint_conbin - 1] = CStringGetTextDatum(conBin);
|
||||||
CStringGetDatum(conBin));
|
|
||||||
else
|
else
|
||||||
nulls[Anum_pg_constraint_conbin - 1] = 'n';
|
nulls[Anum_pg_constraint_conbin - 1] = 'n';
|
||||||
|
|
||||||
@ -183,8 +182,7 @@ CreateConstraintEntry(const char *constraintName,
|
|||||||
* initialize the text form of the check constraint
|
* initialize the text form of the check constraint
|
||||||
*/
|
*/
|
||||||
if (conSrc)
|
if (conSrc)
|
||||||
values[Anum_pg_constraint_consrc - 1] = DirectFunctionCall1(textin,
|
values[Anum_pg_constraint_consrc - 1] = CStringGetTextDatum(conSrc);
|
||||||
CStringGetDatum(conSrc));
|
|
||||||
else
|
else
|
||||||
nulls[Anum_pg_constraint_consrc - 1] = 'n';
|
nulls[Anum_pg_constraint_consrc - 1] = 'n';
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/catalog/pg_proc.c,v 1.149 2008/03/18 22:04:14 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/catalog/pg_proc.c,v 1.150 2008/03/25 22:42:42 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -248,10 +248,8 @@ ProcedureCreate(const char *procedureName,
|
|||||||
values[Anum_pg_proc_proargnames - 1] = parameterNames;
|
values[Anum_pg_proc_proargnames - 1] = parameterNames;
|
||||||
else
|
else
|
||||||
nulls[Anum_pg_proc_proargnames - 1] = 'n';
|
nulls[Anum_pg_proc_proargnames - 1] = 'n';
|
||||||
values[Anum_pg_proc_prosrc - 1] = DirectFunctionCall1(textin,
|
values[Anum_pg_proc_prosrc - 1] = CStringGetTextDatum(prosrc);
|
||||||
CStringGetDatum(prosrc));
|
values[Anum_pg_proc_probin - 1] = CStringGetTextDatum(probin);
|
||||||
values[Anum_pg_proc_probin - 1] = DirectFunctionCall1(textin,
|
|
||||||
CStringGetDatum(probin));
|
|
||||||
if (proconfig != PointerGetDatum(NULL))
|
if (proconfig != PointerGetDatum(NULL))
|
||||||
values[Anum_pg_proc_proconfig - 1] = proconfig;
|
values[Anum_pg_proc_proconfig - 1] = proconfig;
|
||||||
else
|
else
|
||||||
@ -449,7 +447,7 @@ fmgr_internal_validator(PG_FUNCTION_ARGS)
|
|||||||
tmp = SysCacheGetAttr(PROCOID, tuple, Anum_pg_proc_prosrc, &isnull);
|
tmp = SysCacheGetAttr(PROCOID, tuple, Anum_pg_proc_prosrc, &isnull);
|
||||||
if (isnull)
|
if (isnull)
|
||||||
elog(ERROR, "null prosrc");
|
elog(ERROR, "null prosrc");
|
||||||
prosrc = DatumGetCString(DirectFunctionCall1(textout, tmp));
|
prosrc = TextDatumGetCString(tmp);
|
||||||
|
|
||||||
if (fmgr_internal_function(prosrc) == InvalidOid)
|
if (fmgr_internal_function(prosrc) == InvalidOid)
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
@ -499,12 +497,12 @@ fmgr_c_validator(PG_FUNCTION_ARGS)
|
|||||||
tmp = SysCacheGetAttr(PROCOID, tuple, Anum_pg_proc_prosrc, &isnull);
|
tmp = SysCacheGetAttr(PROCOID, tuple, Anum_pg_proc_prosrc, &isnull);
|
||||||
if (isnull)
|
if (isnull)
|
||||||
elog(ERROR, "null prosrc");
|
elog(ERROR, "null prosrc");
|
||||||
prosrc = DatumGetCString(DirectFunctionCall1(textout, tmp));
|
prosrc = TextDatumGetCString(tmp);
|
||||||
|
|
||||||
tmp = SysCacheGetAttr(PROCOID, tuple, Anum_pg_proc_probin, &isnull);
|
tmp = SysCacheGetAttr(PROCOID, tuple, Anum_pg_proc_probin, &isnull);
|
||||||
if (isnull)
|
if (isnull)
|
||||||
elog(ERROR, "null probin");
|
elog(ERROR, "null probin");
|
||||||
probin = DatumGetCString(DirectFunctionCall1(textout, tmp));
|
probin = TextDatumGetCString(tmp);
|
||||||
|
|
||||||
(void) load_external_function(probin, prosrc, true, &libraryhandle);
|
(void) load_external_function(probin, prosrc, true, &libraryhandle);
|
||||||
(void) fetch_finfo_record(libraryhandle, prosrc);
|
(void) fetch_finfo_record(libraryhandle, prosrc);
|
||||||
@ -576,7 +574,7 @@ fmgr_sql_validator(PG_FUNCTION_ARGS)
|
|||||||
if (isnull)
|
if (isnull)
|
||||||
elog(ERROR, "null prosrc");
|
elog(ERROR, "null prosrc");
|
||||||
|
|
||||||
prosrc = DatumGetCString(DirectFunctionCall1(textout, tmp));
|
prosrc = TextDatumGetCString(tmp);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Setup error traceback support for ereport().
|
* Setup error traceback support for ereport().
|
||||||
@ -631,7 +629,7 @@ sql_function_parse_error_callback(void *arg)
|
|||||||
tmp = SysCacheGetAttr(PROCOID, tuple, Anum_pg_proc_prosrc, &isnull);
|
tmp = SysCacheGetAttr(PROCOID, tuple, Anum_pg_proc_prosrc, &isnull);
|
||||||
if (isnull)
|
if (isnull)
|
||||||
elog(ERROR, "null prosrc");
|
elog(ERROR, "null prosrc");
|
||||||
prosrc = DatumGetCString(DirectFunctionCall1(textout, tmp));
|
prosrc = TextDatumGetCString(tmp);
|
||||||
|
|
||||||
if (!function_parse_error_transpose(prosrc))
|
if (!function_parse_error_transpose(prosrc))
|
||||||
{
|
{
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/catalog/pg_type.c,v 1.116 2008/03/19 18:38:30 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/catalog/pg_type.c,v 1.117 2008/03/25 22:42:42 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -275,8 +275,7 @@ TypeCreate(Oid newTypeOid,
|
|||||||
* course.
|
* course.
|
||||||
*/
|
*/
|
||||||
if (defaultTypeBin)
|
if (defaultTypeBin)
|
||||||
values[i] = DirectFunctionCall1(textin,
|
values[i] = CStringGetTextDatum(defaultTypeBin);
|
||||||
CStringGetDatum(defaultTypeBin));
|
|
||||||
else
|
else
|
||||||
nulls[i] = 'n';
|
nulls[i] = 'n';
|
||||||
i++; /* typdefaultbin */
|
i++; /* typdefaultbin */
|
||||||
@ -285,8 +284,7 @@ TypeCreate(Oid newTypeOid,
|
|||||||
* initialize the default value for this type.
|
* initialize the default value for this type.
|
||||||
*/
|
*/
|
||||||
if (defaultTypeValue)
|
if (defaultTypeValue)
|
||||||
values[i] = DirectFunctionCall1(textin,
|
values[i] = CStringGetTextDatum(defaultTypeValue);
|
||||||
CStringGetDatum(defaultTypeValue));
|
|
||||||
else
|
else
|
||||||
nulls[i] = 'n';
|
nulls[i] = 'n';
|
||||||
i++; /* typdefault */
|
i++; /* typdefault */
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
* Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/commands/comment.c,v 1.100 2008/01/01 19:45:48 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/commands/comment.c,v 1.101 2008/03/25 22:42:42 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -215,7 +215,7 @@ CreateComments(Oid oid, Oid classoid, int32 subid, char *comment)
|
|||||||
values[i++] = ObjectIdGetDatum(oid);
|
values[i++] = ObjectIdGetDatum(oid);
|
||||||
values[i++] = ObjectIdGetDatum(classoid);
|
values[i++] = ObjectIdGetDatum(classoid);
|
||||||
values[i++] = Int32GetDatum(subid);
|
values[i++] = Int32GetDatum(subid);
|
||||||
values[i++] = DirectFunctionCall1(textin, CStringGetDatum(comment));
|
values[i++] = CStringGetTextDatum(comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Use the index to search for a matching old tuple */
|
/* Use the index to search for a matching old tuple */
|
||||||
@ -314,7 +314,7 @@ CreateSharedComments(Oid oid, Oid classoid, char *comment)
|
|||||||
i = 0;
|
i = 0;
|
||||||
values[i++] = ObjectIdGetDatum(oid);
|
values[i++] = ObjectIdGetDatum(oid);
|
||||||
values[i++] = ObjectIdGetDatum(classoid);
|
values[i++] = ObjectIdGetDatum(classoid);
|
||||||
values[i++] = DirectFunctionCall1(textin, CStringGetDatum(comment));
|
values[i++] = CStringGetTextDatum(comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Use the index to search for a matching old tuple */
|
/* Use the index to search for a matching old tuple */
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/commands/functioncmds.c,v 1.88 2008/01/01 19:45:49 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/commands/functioncmds.c,v 1.89 2008/03/25 22:42:42 tgl Exp $
|
||||||
*
|
*
|
||||||
* DESCRIPTION
|
* DESCRIPTION
|
||||||
* These routines take the parse tree and pick out the
|
* These routines take the parse tree and pick out the
|
||||||
@ -237,8 +237,7 @@ examine_parameter_list(List *parameters, Oid languageOid,
|
|||||||
|
|
||||||
if (fp->name && fp->name[0])
|
if (fp->name && fp->name[0])
|
||||||
{
|
{
|
||||||
paramNames[i] = DirectFunctionCall1(textin,
|
paramNames[i] = CStringGetTextDatum(fp->name);
|
||||||
CStringGetDatum(fp->name));
|
|
||||||
have_names = true;
|
have_names = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,8 +268,7 @@ examine_parameter_list(List *parameters, Oid languageOid,
|
|||||||
for (i = 0; i < parameterCount; i++)
|
for (i = 0; i < parameterCount; i++)
|
||||||
{
|
{
|
||||||
if (paramNames[i] == PointerGetDatum(NULL))
|
if (paramNames[i] == PointerGetDatum(NULL))
|
||||||
paramNames[i] = DirectFunctionCall1(textin,
|
paramNames[i] = CStringGetTextDatum("");
|
||||||
CStringGetDatum(""));
|
|
||||||
}
|
}
|
||||||
*parameterNames = construct_array(paramNames, parameterCount, TEXTOID,
|
*parameterNames = construct_array(paramNames, parameterCount, TEXTOID,
|
||||||
-1, false, 'i');
|
-1, false, 'i');
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
* Copyright (c) 2002-2008, PostgreSQL Global Development Group
|
* Copyright (c) 2002-2008, PostgreSQL Global Development Group
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/commands/prepare.c,v 1.81 2008/03/25 19:26:53 neilc Exp $
|
* $PostgreSQL: pgsql/src/backend/commands/prepare.c,v 1.82 2008/03/25 22:42:42 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -772,14 +772,12 @@ pg_prepared_statement(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
MemSet(nulls, 0, sizeof(nulls));
|
MemSet(nulls, 0, sizeof(nulls));
|
||||||
|
|
||||||
values[0] = DirectFunctionCall1(textin,
|
values[0] = CStringGetTextDatum(prep_stmt->stmt_name);
|
||||||
CStringGetDatum(prep_stmt->stmt_name));
|
|
||||||
|
|
||||||
if (prep_stmt->plansource->query_string == NULL)
|
if (prep_stmt->plansource->query_string == NULL)
|
||||||
nulls[1] = true;
|
nulls[1] = true;
|
||||||
else
|
else
|
||||||
values[1] = DirectFunctionCall1(textin,
|
values[1] = CStringGetTextDatum(prep_stmt->plansource->query_string);
|
||||||
CStringGetDatum(prep_stmt->plansource->query_string));
|
|
||||||
|
|
||||||
values[2] = TimestampTzGetDatum(prep_stmt->prepare_time);
|
values[2] = TimestampTzGetDatum(prep_stmt->prepare_time);
|
||||||
values[3] = build_regtype_array(prep_stmt->plansource->param_types,
|
values[3] = build_regtype_array(prep_stmt->plansource->param_types,
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/commands/proclang.c,v 1.74 2008/01/01 19:45:49 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/commands/proclang.c,v 1.75 2008/03/25 22:42:42 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -360,20 +360,17 @@ find_language_template(const char *languageName)
|
|||||||
datum = heap_getattr(tup, Anum_pg_pltemplate_tmplhandler,
|
datum = heap_getattr(tup, Anum_pg_pltemplate_tmplhandler,
|
||||||
RelationGetDescr(rel), &isnull);
|
RelationGetDescr(rel), &isnull);
|
||||||
if (!isnull)
|
if (!isnull)
|
||||||
result->tmplhandler =
|
result->tmplhandler = TextDatumGetCString(datum);
|
||||||
DatumGetCString(DirectFunctionCall1(textout, datum));
|
|
||||||
|
|
||||||
datum = heap_getattr(tup, Anum_pg_pltemplate_tmplvalidator,
|
datum = heap_getattr(tup, Anum_pg_pltemplate_tmplvalidator,
|
||||||
RelationGetDescr(rel), &isnull);
|
RelationGetDescr(rel), &isnull);
|
||||||
if (!isnull)
|
if (!isnull)
|
||||||
result->tmplvalidator =
|
result->tmplvalidator = TextDatumGetCString(datum);
|
||||||
DatumGetCString(DirectFunctionCall1(textout, datum));
|
|
||||||
|
|
||||||
datum = heap_getattr(tup, Anum_pg_pltemplate_tmpllibrary,
|
datum = heap_getattr(tup, Anum_pg_pltemplate_tmpllibrary,
|
||||||
RelationGetDescr(rel), &isnull);
|
RelationGetDescr(rel), &isnull);
|
||||||
if (!isnull)
|
if (!isnull)
|
||||||
result->tmpllibrary =
|
result->tmpllibrary = TextDatumGetCString(datum);
|
||||||
DatumGetCString(DirectFunctionCall1(textout, datum));
|
|
||||||
|
|
||||||
/* Ignore template if handler or library info is missing */
|
/* Ignore template if handler or library info is missing */
|
||||||
if (!result->tmplhandler || !result->tmpllibrary)
|
if (!result->tmplhandler || !result->tmpllibrary)
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.243 2008/03/19 18:38:30 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.244 2008/03/25 22:42:42 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -6183,7 +6183,7 @@ decompile_conbin(HeapTuple contup, TupleDesc tupdesc)
|
|||||||
|
|
||||||
expr = DirectFunctionCall2(pg_get_expr, attr,
|
expr = DirectFunctionCall2(pg_get_expr, attr,
|
||||||
ObjectIdGetDatum(con->conrelid));
|
ObjectIdGetDatum(con->conrelid));
|
||||||
return DatumGetCString(DirectFunctionCall1(textout, expr));
|
return TextDatumGetCString(expr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/commands/tablespace.c,v 1.53 2008/01/01 19:45:49 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/commands/tablespace.c,v 1.54 2008/03/25 22:42:43 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -282,7 +282,7 @@ CreateTableSpace(CreateTableSpaceStmt *stmt)
|
|||||||
values[Anum_pg_tablespace_spcowner - 1] =
|
values[Anum_pg_tablespace_spcowner - 1] =
|
||||||
ObjectIdGetDatum(ownerId);
|
ObjectIdGetDatum(ownerId);
|
||||||
values[Anum_pg_tablespace_spclocation - 1] =
|
values[Anum_pg_tablespace_spclocation - 1] =
|
||||||
DirectFunctionCall1(textin, CStringGetDatum(location));
|
CStringGetTextDatum(location);
|
||||||
nulls[Anum_pg_tablespace_spcacl - 1] = 'n';
|
nulls[Anum_pg_tablespace_spcacl - 1] = 'n';
|
||||||
|
|
||||||
tuple = heap_formtuple(rel->rd_att, values, nulls);
|
tuple = heap_formtuple(rel->rd_att, values, nulls);
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/commands/tsearchcmds.c,v 1.9 2008/01/01 19:45:49 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/commands/tsearchcmds.c,v 1.10 2008/03/25 22:42:43 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -1999,7 +1999,7 @@ serialize_deflist(List *deflist)
|
|||||||
appendStringInfo(&buf, ", ");
|
appendStringInfo(&buf, ", ");
|
||||||
}
|
}
|
||||||
|
|
||||||
result = CStringGetTextP(buf.data);
|
result = cstring_to_text_with_len(buf.data, buf.len);
|
||||||
pfree(buf.data);
|
pfree(buf.data);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -2099,7 +2099,7 @@ deserialize_deflist(Datum txt)
|
|||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||||
errmsg("invalid parameter list format: \"%s\"",
|
errmsg("invalid parameter list format: \"%s\"",
|
||||||
TextPGetCString(in))));
|
text_to_cstring(in))));
|
||||||
break;
|
break;
|
||||||
case CS_WAITVALUE:
|
case CS_WAITVALUE:
|
||||||
if (*ptr == '\'')
|
if (*ptr == '\'')
|
||||||
@ -2210,7 +2210,7 @@ deserialize_deflist(Datum txt)
|
|||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||||
errmsg("invalid parameter list format: \"%s\"",
|
errmsg("invalid parameter list format: \"%s\"",
|
||||||
TextPGetCString(in))));
|
text_to_cstring(in))));
|
||||||
|
|
||||||
pfree(workspace);
|
pfree(workspace);
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/commands/typecmds.c,v 1.114 2008/03/19 18:38:30 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/commands/typecmds.c,v 1.115 2008/03/25 22:42:43 tgl Exp $
|
||||||
*
|
*
|
||||||
* DESCRIPTION
|
* DESCRIPTION
|
||||||
* The "DefineFoo" routines take the parse tree and pick out the
|
* The "DefineFoo" routines take the parse tree and pick out the
|
||||||
@ -697,13 +697,13 @@ DefineDomain(CreateDomainStmt *stmt)
|
|||||||
datum = SysCacheGetAttr(TYPEOID, typeTup,
|
datum = SysCacheGetAttr(TYPEOID, typeTup,
|
||||||
Anum_pg_type_typdefault, &isnull);
|
Anum_pg_type_typdefault, &isnull);
|
||||||
if (!isnull)
|
if (!isnull)
|
||||||
defaultValue = DatumGetCString(DirectFunctionCall1(textout, datum));
|
defaultValue = TextDatumGetCString(datum);
|
||||||
|
|
||||||
/* Inherited default binary value */
|
/* Inherited default binary value */
|
||||||
datum = SysCacheGetAttr(TYPEOID, typeTup,
|
datum = SysCacheGetAttr(TYPEOID, typeTup,
|
||||||
Anum_pg_type_typdefaultbin, &isnull);
|
Anum_pg_type_typdefaultbin, &isnull);
|
||||||
if (!isnull)
|
if (!isnull)
|
||||||
defaultValueBin = DatumGetCString(DirectFunctionCall1(textout, datum));
|
defaultValueBin = TextDatumGetCString(datum);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Run through constraints manually to avoid the additional processing
|
* Run through constraints manually to avoid the additional processing
|
||||||
@ -1497,12 +1497,10 @@ AlterDomainDefault(List *names, Node *defaultRaw)
|
|||||||
/*
|
/*
|
||||||
* Form an updated tuple with the new default and write it back.
|
* Form an updated tuple with the new default and write it back.
|
||||||
*/
|
*/
|
||||||
new_record[Anum_pg_type_typdefaultbin - 1] = DirectFunctionCall1(textin,
|
new_record[Anum_pg_type_typdefaultbin - 1] = CStringGetTextDatum(nodeToString(defaultExpr));
|
||||||
CStringGetDatum(nodeToString(defaultExpr)));
|
|
||||||
|
|
||||||
new_record_repl[Anum_pg_type_typdefaultbin - 1] = 'r';
|
new_record_repl[Anum_pg_type_typdefaultbin - 1] = 'r';
|
||||||
new_record[Anum_pg_type_typdefault - 1] = DirectFunctionCall1(textin,
|
new_record[Anum_pg_type_typdefault - 1] = CStringGetTextDatum(defaultValue);
|
||||||
CStringGetDatum(defaultValue));
|
|
||||||
new_record_repl[Anum_pg_type_typdefault - 1] = 'r';
|
new_record_repl[Anum_pg_type_typdefault - 1] = 'r';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2292,9 +2290,7 @@ GetDomainConstraints(Oid typeOid)
|
|||||||
elog(ERROR, "domain \"%s\" constraint \"%s\" has NULL conbin",
|
elog(ERROR, "domain \"%s\" constraint \"%s\" has NULL conbin",
|
||||||
NameStr(typTup->typname), NameStr(c->conname));
|
NameStr(typTup->typname), NameStr(c->conname));
|
||||||
|
|
||||||
check_expr = (Expr *)
|
check_expr = (Expr *) stringToNode(TextDatumGetCString(val));
|
||||||
stringToNode(DatumGetCString(DirectFunctionCall1(textout,
|
|
||||||
val)));
|
|
||||||
|
|
||||||
/* ExecInitExpr assumes we already fixed opfuncids */
|
/* ExecInitExpr assumes we already fixed opfuncids */
|
||||||
fix_opfuncids((Node *) check_expr);
|
fix_opfuncids((Node *) check_expr);
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/backend/commands/user.c,v 1.179 2008/03/24 19:47:35 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/commands/user.c,v 1.180 2008/03/25 22:42:43 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -311,14 +311,14 @@ CreateRole(CreateRoleStmt *stmt)
|
|||||||
{
|
{
|
||||||
if (!encrypt_password || isMD5(password))
|
if (!encrypt_password || isMD5(password))
|
||||||
new_record[Anum_pg_authid_rolpassword - 1] =
|
new_record[Anum_pg_authid_rolpassword - 1] =
|
||||||
DirectFunctionCall1(textin, CStringGetDatum(password));
|
CStringGetTextDatum(password);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!pg_md5_encrypt(password, stmt->role, strlen(stmt->role),
|
if (!pg_md5_encrypt(password, stmt->role, strlen(stmt->role),
|
||||||
encrypted_password))
|
encrypted_password))
|
||||||
elog(ERROR, "password encryption failed");
|
elog(ERROR, "password encryption failed");
|
||||||
new_record[Anum_pg_authid_rolpassword - 1] =
|
new_record[Anum_pg_authid_rolpassword - 1] =
|
||||||
DirectFunctionCall1(textin, CStringGetDatum(encrypted_password));
|
CStringGetTextDatum(encrypted_password);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -639,14 +639,14 @@ AlterRole(AlterRoleStmt *stmt)
|
|||||||
{
|
{
|
||||||
if (!encrypt_password || isMD5(password))
|
if (!encrypt_password || isMD5(password))
|
||||||
new_record[Anum_pg_authid_rolpassword - 1] =
|
new_record[Anum_pg_authid_rolpassword - 1] =
|
||||||
DirectFunctionCall1(textin, CStringGetDatum(password));
|
CStringGetTextDatum(password);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!pg_md5_encrypt(password, stmt->role, strlen(stmt->role),
|
if (!pg_md5_encrypt(password, stmt->role, strlen(stmt->role),
|
||||||
encrypted_password))
|
encrypted_password))
|
||||||
elog(ERROR, "password encryption failed");
|
elog(ERROR, "password encryption failed");
|
||||||
new_record[Anum_pg_authid_rolpassword - 1] =
|
new_record[Anum_pg_authid_rolpassword - 1] =
|
||||||
DirectFunctionCall1(textin, CStringGetDatum(encrypted_password));
|
CStringGetTextDatum(encrypted_password);
|
||||||
}
|
}
|
||||||
new_record_repl[Anum_pg_authid_rolpassword - 1] = 'r';
|
new_record_repl[Anum_pg_authid_rolpassword - 1] = 'r';
|
||||||
}
|
}
|
||||||
@ -1060,7 +1060,7 @@ RenameRole(const char *oldname, const char *newname)
|
|||||||
|
|
||||||
datum = heap_getattr(oldtuple, Anum_pg_authid_rolpassword, dsc, &isnull);
|
datum = heap_getattr(oldtuple, Anum_pg_authid_rolpassword, dsc, &isnull);
|
||||||
|
|
||||||
if (!isnull && isMD5(DatumGetCString(DirectFunctionCall1(textout, datum))))
|
if (!isnull && isMD5(TextDatumGetCString(datum)))
|
||||||
{
|
{
|
||||||
/* MD5 uses the username as salt, so just clear it on a rename */
|
/* MD5 uses the username as salt, so just clear it on a rename */
|
||||||
repl_repl[Anum_pg_authid_rolpassword - 1] = 'r';
|
repl_repl[Anum_pg_authid_rolpassword - 1] = 'r';
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/backend/executor/execCurrent.c,v 1.5 2008/01/01 19:45:49 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/executor/execCurrent.c,v 1.6 2008/03/25 22:42:43 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -150,8 +150,7 @@ fetch_param_value(ExprContext *econtext, int paramId)
|
|||||||
{
|
{
|
||||||
Assert(prm->ptype == REFCURSOROID);
|
Assert(prm->ptype == REFCURSOROID);
|
||||||
/* We know that refcursor uses text's I/O routines */
|
/* We know that refcursor uses text's I/O routines */
|
||||||
return DatumGetCString(DirectFunctionCall1(textout,
|
return TextDatumGetCString(prm->value);
|
||||||
prm->value));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/executor/execQual.c,v 1.227 2008/03/25 19:26:53 neilc Exp $
|
* $PostgreSQL: pgsql/src/backend/executor/execQual.c,v 1.228 2008/03/25 22:42:43 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -3039,13 +3039,7 @@ ExecEvalXml(XmlExprState *xmlExpr, ExprContext *econtext,
|
|||||||
if (*isNull)
|
if (*isNull)
|
||||||
result = NULL;
|
result = NULL;
|
||||||
else
|
else
|
||||||
{
|
result = cstring_to_text_with_len(buf.data, buf.len);
|
||||||
int len = buf.len + VARHDRSZ;
|
|
||||||
|
|
||||||
result = palloc(len);
|
|
||||||
SET_VARSIZE(result, len);
|
|
||||||
memcpy(VARDATA(result), buf.data, buf.len);
|
|
||||||
}
|
|
||||||
|
|
||||||
pfree(buf.data);
|
pfree(buf.data);
|
||||||
return PointerGetDatum(result);
|
return PointerGetDatum(result);
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/executor/functions.c,v 1.121 2008/03/18 22:04:14 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/executor/functions.c,v 1.122 2008/03/25 22:42:43 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -244,7 +244,7 @@ init_sql_fcache(FmgrInfo *finfo)
|
|||||||
&isNull);
|
&isNull);
|
||||||
if (isNull)
|
if (isNull)
|
||||||
elog(ERROR, "null prosrc for function %u", foid);
|
elog(ERROR, "null prosrc for function %u", foid);
|
||||||
fcache->src = DatumGetCString(DirectFunctionCall1(textout, tmp));
|
fcache->src = TextDatumGetCString(tmp);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parse and rewrite the queries in the function text.
|
* Parse and rewrite the queries in the function text.
|
||||||
@ -777,7 +777,7 @@ sql_exec_error_callback(void *arg)
|
|||||||
&isnull);
|
&isnull);
|
||||||
if (isnull)
|
if (isnull)
|
||||||
elog(ERROR, "null prosrc");
|
elog(ERROR, "null prosrc");
|
||||||
prosrc = DatumGetCString(DirectFunctionCall1(textout, tmp));
|
prosrc = TextDatumGetCString(tmp);
|
||||||
errposition(0);
|
errposition(0);
|
||||||
internalerrposition(syntaxerrposition);
|
internalerrposition(syntaxerrposition);
|
||||||
internalerrquery(prosrc);
|
internalerrquery(prosrc);
|
||||||
|
@ -61,7 +61,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/executor/nodeAgg.c,v 1.156 2008/01/11 18:39:40 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/executor/nodeAgg.c,v 1.157 2008/03/25 22:42:43 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -1549,7 +1549,7 @@ GetAggInitVal(Datum textInitVal, Oid transtype)
|
|||||||
Datum initVal;
|
Datum initVal;
|
||||||
|
|
||||||
getTypeInputInfo(transtype, &typinput, &typioparam);
|
getTypeInputInfo(transtype, &typinput, &typioparam);
|
||||||
strInitVal = DatumGetCString(DirectFunctionCall1(textout, textInitVal));
|
strInitVal = TextDatumGetCString(textInitVal);
|
||||||
initVal = OidInputFunctionCall(typinput, strInitVal,
|
initVal = OidInputFunctionCall(typinput, strInitVal,
|
||||||
typioparam, -1);
|
typioparam, -1);
|
||||||
pfree(strInitVal);
|
pfree(strInitVal);
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/libpq/be-fsstubs.c,v 1.88 2008/03/22 01:55:14 ishii Exp $
|
* $PostgreSQL: pgsql/src/backend/libpq/be-fsstubs.c,v 1.89 2008/03/25 22:42:43 tgl Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* This should be moved to a more appropriate place. It is here
|
* This should be moved to a more appropriate place. It is here
|
||||||
@ -47,6 +47,7 @@
|
|||||||
#include "miscadmin.h"
|
#include "miscadmin.h"
|
||||||
#include "storage/fd.h"
|
#include "storage/fd.h"
|
||||||
#include "storage/large_object.h"
|
#include "storage/large_object.h"
|
||||||
|
#include "utils/builtins.h"
|
||||||
#include "utils/memutils.h"
|
#include "utils/memutils.h"
|
||||||
|
|
||||||
|
|
||||||
@ -320,7 +321,7 @@ lowrite(PG_FUNCTION_ARGS)
|
|||||||
Datum
|
Datum
|
||||||
lo_import(PG_FUNCTION_ARGS)
|
lo_import(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
text *filename = PG_GETARG_TEXT_P(0);
|
text *filename = PG_GETARG_TEXT_PP(0);
|
||||||
|
|
||||||
PG_RETURN_OID(lo_import_internal(filename, InvalidOid));
|
PG_RETURN_OID(lo_import_internal(filename, InvalidOid));
|
||||||
}
|
}
|
||||||
@ -332,7 +333,7 @@ lo_import(PG_FUNCTION_ARGS)
|
|||||||
Datum
|
Datum
|
||||||
lo_import_with_oid(PG_FUNCTION_ARGS)
|
lo_import_with_oid(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
text *filename = PG_GETARG_TEXT_P(0);
|
text *filename = PG_GETARG_TEXT_PP(0);
|
||||||
Oid oid = PG_GETARG_OID(1);
|
Oid oid = PG_GETARG_OID(1);
|
||||||
|
|
||||||
PG_RETURN_OID(lo_import_internal(filename, oid));
|
PG_RETURN_OID(lo_import_internal(filename, oid));
|
||||||
@ -362,11 +363,7 @@ lo_import_internal(text *filename, Oid lobjOid)
|
|||||||
/*
|
/*
|
||||||
* open the file to be read in
|
* open the file to be read in
|
||||||
*/
|
*/
|
||||||
nbytes = VARSIZE(filename) - VARHDRSZ;
|
text_to_cstring_buffer(filename, fnamebuf, sizeof(fnamebuf));
|
||||||
if (nbytes >= MAXPGPATH)
|
|
||||||
nbytes = MAXPGPATH - 1;
|
|
||||||
memcpy(fnamebuf, VARDATA(filename), nbytes);
|
|
||||||
fnamebuf[nbytes] = '\0';
|
|
||||||
fd = PathNameOpenFile(fnamebuf, O_RDONLY | PG_BINARY, 0666);
|
fd = PathNameOpenFile(fnamebuf, O_RDONLY | PG_BINARY, 0666);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
@ -410,7 +407,7 @@ Datum
|
|||||||
lo_export(PG_FUNCTION_ARGS)
|
lo_export(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
Oid lobjId = PG_GETARG_OID(0);
|
Oid lobjId = PG_GETARG_OID(0);
|
||||||
text *filename = PG_GETARG_TEXT_P(1);
|
text *filename = PG_GETARG_TEXT_PP(1);
|
||||||
File fd;
|
File fd;
|
||||||
int nbytes,
|
int nbytes,
|
||||||
tmp;
|
tmp;
|
||||||
@ -441,11 +438,7 @@ lo_export(PG_FUNCTION_ARGS)
|
|||||||
* 022. This code used to drop it all the way to 0, but creating
|
* 022. This code used to drop it all the way to 0, but creating
|
||||||
* world-writable export files doesn't seem wise.
|
* world-writable export files doesn't seem wise.
|
||||||
*/
|
*/
|
||||||
nbytes = VARSIZE(filename) - VARHDRSZ;
|
text_to_cstring_buffer(filename, fnamebuf, sizeof(fnamebuf));
|
||||||
if (nbytes >= MAXPGPATH)
|
|
||||||
nbytes = MAXPGPATH - 1;
|
|
||||||
memcpy(fnamebuf, VARDATA(filename), nbytes);
|
|
||||||
fnamebuf[nbytes] = '\0';
|
|
||||||
oumask = umask((mode_t) 0022);
|
oumask = umask((mode_t) 0022);
|
||||||
fd = PathNameOpenFile(fnamebuf, O_CREAT | O_WRONLY | O_TRUNC | PG_BINARY, 0666);
|
fd = PathNameOpenFile(fnamebuf, O_CREAT | O_WRONLY | O_TRUNC | PG_BINARY, 0666);
|
||||||
umask(oumask);
|
umask(oumask);
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/optimizer/path/indxpath.c,v 1.227 2008/02/07 17:53:53 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/optimizer/path/indxpath.c,v 1.228 2008/03/25 22:42:43 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -2711,8 +2711,7 @@ prefix_quals(Node *leftop, Oid opfamily,
|
|||||||
switch (prefix_const->consttype)
|
switch (prefix_const->consttype)
|
||||||
{
|
{
|
||||||
case TEXTOID:
|
case TEXTOID:
|
||||||
prefix = DatumGetCString(DirectFunctionCall1(textout,
|
prefix = TextDatumGetCString(prefix_const->constvalue);
|
||||||
prefix_const->constvalue));
|
|
||||||
break;
|
break;
|
||||||
case BYTEAOID:
|
case BYTEAOID:
|
||||||
prefix = DatumGetCString(DirectFunctionCall1(byteaout,
|
prefix = DatumGetCString(DirectFunctionCall1(byteaout,
|
||||||
@ -2868,15 +2867,15 @@ static Datum
|
|||||||
string_to_datum(const char *str, Oid datatype)
|
string_to_datum(const char *str, Oid datatype)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* We cheat a little by assuming that textin() will do for bpchar and
|
* We cheat a little by assuming that CStringGetTextDatum() will do for
|
||||||
* varchar constants too...
|
* bpchar and varchar constants too...
|
||||||
*/
|
*/
|
||||||
if (datatype == NAMEOID)
|
if (datatype == NAMEOID)
|
||||||
return DirectFunctionCall1(namein, CStringGetDatum(str));
|
return DirectFunctionCall1(namein, CStringGetDatum(str));
|
||||||
else if (datatype == BYTEAOID)
|
else if (datatype == BYTEAOID)
|
||||||
return DirectFunctionCall1(byteain, CStringGetDatum(str));
|
return DirectFunctionCall1(byteain, CStringGetDatum(str));
|
||||||
else
|
else
|
||||||
return DirectFunctionCall1(textin, CStringGetDatum(str));
|
return CStringGetTextDatum(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/optimizer/util/clauses.c,v 1.255 2008/03/18 22:04:14 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/optimizer/util/clauses.c,v 1.256 2008/03/25 22:42:43 tgl Exp $
|
||||||
*
|
*
|
||||||
* HISTORY
|
* HISTORY
|
||||||
* AUTHOR DATE MAJOR EVENT
|
* AUTHOR DATE MAJOR EVENT
|
||||||
@ -3002,7 +3002,7 @@ inline_function(Oid funcid, Oid result_type, List *args,
|
|||||||
&isNull);
|
&isNull);
|
||||||
if (isNull)
|
if (isNull)
|
||||||
elog(ERROR, "null prosrc for function %u", funcid);
|
elog(ERROR, "null prosrc for function %u", funcid);
|
||||||
src = DatumGetCString(DirectFunctionCall1(textout, tmp));
|
src = TextDatumGetCString(tmp);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We just do parsing and parse analysis, not rewriting, because rewriting
|
* We just do parsing and parse analysis, not rewriting, because rewriting
|
||||||
@ -3227,7 +3227,7 @@ sql_inline_error_callback(void *arg)
|
|||||||
&isnull);
|
&isnull);
|
||||||
if (isnull)
|
if (isnull)
|
||||||
elog(ERROR, "null prosrc");
|
elog(ERROR, "null prosrc");
|
||||||
prosrc = DatumGetCString(DirectFunctionCall1(textout, tmp));
|
prosrc = TextDatumGetCString(tmp);
|
||||||
errposition(0);
|
errposition(0);
|
||||||
internalerrposition(syntaxerrposition);
|
internalerrposition(syntaxerrposition);
|
||||||
internalerrquery(prosrc);
|
internalerrquery(prosrc);
|
||||||
@ -3454,7 +3454,7 @@ inline_set_returning_function(PlannerInfo *root, Node *node)
|
|||||||
&isNull);
|
&isNull);
|
||||||
if (isNull)
|
if (isNull)
|
||||||
elog(ERROR, "null prosrc for function %u", fexpr->funcid);
|
elog(ERROR, "null prosrc for function %u", fexpr->funcid);
|
||||||
src = DatumGetCString(DirectFunctionCall1(textout, tmp));
|
src = TextDatumGetCString(tmp);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parse, analyze, and rewrite (unlike inline_function(), we can't
|
* Parse, analyze, and rewrite (unlike inline_function(), we can't
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/backend/parser/parse_utilcmd.c,v 2.10 2008/03/21 22:10:56 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/parser/parse_utilcmd.c,v 2.11 2008/03/25 22:42:43 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -811,7 +811,7 @@ generateClonedIndexStmt(CreateStmtContext *cxt, Relation source_idx,
|
|||||||
{
|
{
|
||||||
char *exprsString;
|
char *exprsString;
|
||||||
|
|
||||||
exprsString = DatumGetCString(DirectFunctionCall1(textout, datum));
|
exprsString = TextDatumGetCString(datum);
|
||||||
indexprs = (List *) stringToNode(exprsString);
|
indexprs = (List *) stringToNode(exprsString);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -904,7 +904,7 @@ generateClonedIndexStmt(CreateStmtContext *cxt, Relation source_idx,
|
|||||||
char *pred_str;
|
char *pred_str;
|
||||||
|
|
||||||
/* Convert text string to node tree */
|
/* Convert text string to node tree */
|
||||||
pred_str = DatumGetCString(DirectFunctionCall1(textout, datum));
|
pred_str = TextDatumGetCString(datum);
|
||||||
index->whereClause = (Node *) stringToNode(pred_str);
|
index->whereClause = (Node *) stringToNode(pred_str);
|
||||||
/* Adjust attribute numbers */
|
/* Adjust attribute numbers */
|
||||||
change_varattnos_of_a_node(index->whereClause, attmap);
|
change_varattnos_of_a_node(index->whereClause, attmap);
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/rewrite/rewriteDefine.c,v 1.124 2008/01/01 19:45:51 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/rewrite/rewriteDefine.c,v 1.125 2008/03/25 22:42:43 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -83,8 +83,8 @@ InsertRule(char *rulname,
|
|||||||
values[i++] = CharGetDatum(evtype + '0'); /* ev_type */
|
values[i++] = CharGetDatum(evtype + '0'); /* ev_type */
|
||||||
values[i++] = CharGetDatum(RULE_FIRES_ON_ORIGIN); /* ev_enabled */
|
values[i++] = CharGetDatum(RULE_FIRES_ON_ORIGIN); /* ev_enabled */
|
||||||
values[i++] = BoolGetDatum(evinstead); /* is_instead */
|
values[i++] = BoolGetDatum(evinstead); /* is_instead */
|
||||||
values[i++] = DirectFunctionCall1(textin, CStringGetDatum(evqual)); /* ev_qual */
|
values[i++] = CStringGetTextDatum(evqual); /* ev_qual */
|
||||||
values[i++] = DirectFunctionCall1(textin, CStringGetDatum(actiontree)); /* ev_action */
|
values[i++] = CStringGetTextDatum(actiontree); /* ev_action */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Ready to store new pg_rewrite tuple
|
* Ready to store new pg_rewrite tuple
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/tsearch/dict.c,v 1.4 2008/01/01 19:45:52 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/tsearch/dict.c,v 1.5 2008/03/25 22:42:43 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -64,7 +64,7 @@ ts_lexize(PG_FUNCTION_ARGS)
|
|||||||
ptr = res;
|
ptr = res;
|
||||||
while (ptr->lexeme)
|
while (ptr->lexeme)
|
||||||
{
|
{
|
||||||
da[ptr - res] = DirectFunctionCall1(textin, CStringGetDatum(ptr->lexeme));
|
da[ptr - res] = CStringGetTextDatum(ptr->lexeme);
|
||||||
ptr++;
|
ptr++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/tsearch/to_tsany.c,v 1.10 2008/03/07 14:30:20 teodor Exp $
|
* $PostgreSQL: pgsql/src/backend/tsearch/to_tsany.c,v 1.11 2008/03/25 22:42:43 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -337,7 +337,7 @@ to_tsquery_byid(PG_FUNCTION_ARGS)
|
|||||||
QueryItem *res;
|
QueryItem *res;
|
||||||
int4 len;
|
int4 len;
|
||||||
|
|
||||||
query = parse_tsquery(TextPGetCString(in), pushval_morph, ObjectIdGetDatum(cfgid), false);
|
query = parse_tsquery(text_to_cstring(in), pushval_morph, ObjectIdGetDatum(cfgid), false);
|
||||||
|
|
||||||
if (query->size == 0)
|
if (query->size == 0)
|
||||||
PG_RETURN_TSQUERY(query);
|
PG_RETURN_TSQUERY(query);
|
||||||
@ -387,7 +387,7 @@ plainto_tsquery_byid(PG_FUNCTION_ARGS)
|
|||||||
QueryItem *res;
|
QueryItem *res;
|
||||||
int4 len;
|
int4 len;
|
||||||
|
|
||||||
query = parse_tsquery(TextPGetCString(in), pushval_morph, ObjectIdGetDatum(cfgid), true);
|
query = parse_tsquery(text_to_cstring(in), pushval_morph, ObjectIdGetDatum(cfgid), true);
|
||||||
|
|
||||||
if (query->size == 0)
|
if (query->size == 0)
|
||||||
PG_RETURN_TSQUERY(query);
|
PG_RETURN_TSQUERY(query);
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/adt/acl.c,v 1.139 2008/01/01 19:45:52 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/adt/acl.c,v 1.140 2008/03/25 22:42:43 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -1313,10 +1313,7 @@ makeaclitem(PG_FUNCTION_ARGS)
|
|||||||
static AclMode
|
static AclMode
|
||||||
convert_priv_string(text *priv_type_text)
|
convert_priv_string(text *priv_type_text)
|
||||||
{
|
{
|
||||||
char *priv_type;
|
char *priv_type = text_to_cstring(priv_type_text);
|
||||||
|
|
||||||
priv_type = DatumGetCString(DirectFunctionCall1(textout,
|
|
||||||
PointerGetDatum(priv_type_text)));
|
|
||||||
|
|
||||||
if (pg_strcasecmp(priv_type, "SELECT") == 0)
|
if (pg_strcasecmp(priv_type, "SELECT") == 0)
|
||||||
return ACL_SELECT;
|
return ACL_SELECT;
|
||||||
@ -1526,10 +1523,7 @@ convert_table_name(text *tablename)
|
|||||||
static AclMode
|
static AclMode
|
||||||
convert_table_priv_string(text *priv_type_text)
|
convert_table_priv_string(text *priv_type_text)
|
||||||
{
|
{
|
||||||
char *priv_type;
|
char *priv_type = text_to_cstring(priv_type_text);
|
||||||
|
|
||||||
priv_type = DatumGetCString(DirectFunctionCall1(textout,
|
|
||||||
PointerGetDatum(priv_type_text)));
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return mode from priv_type string
|
* Return mode from priv_type string
|
||||||
@ -1736,12 +1730,9 @@ has_database_privilege_id_id(PG_FUNCTION_ARGS)
|
|||||||
static Oid
|
static Oid
|
||||||
convert_database_name(text *databasename)
|
convert_database_name(text *databasename)
|
||||||
{
|
{
|
||||||
char *dbname;
|
char *dbname = text_to_cstring(databasename);
|
||||||
Oid oid;
|
Oid oid;
|
||||||
|
|
||||||
dbname = DatumGetCString(DirectFunctionCall1(textout,
|
|
||||||
PointerGetDatum(databasename)));
|
|
||||||
|
|
||||||
oid = get_database_oid(dbname);
|
oid = get_database_oid(dbname);
|
||||||
if (!OidIsValid(oid))
|
if (!OidIsValid(oid))
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
@ -1758,10 +1749,7 @@ convert_database_name(text *databasename)
|
|||||||
static AclMode
|
static AclMode
|
||||||
convert_database_priv_string(text *priv_type_text)
|
convert_database_priv_string(text *priv_type_text)
|
||||||
{
|
{
|
||||||
char *priv_type;
|
char *priv_type = text_to_cstring(priv_type_text);
|
||||||
|
|
||||||
priv_type = DatumGetCString(DirectFunctionCall1(textout,
|
|
||||||
PointerGetDatum(priv_type_text)));
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return mode from priv_type string
|
* Return mode from priv_type string
|
||||||
@ -1953,12 +1941,9 @@ has_function_privilege_id_id(PG_FUNCTION_ARGS)
|
|||||||
static Oid
|
static Oid
|
||||||
convert_function_name(text *functionname)
|
convert_function_name(text *functionname)
|
||||||
{
|
{
|
||||||
char *funcname;
|
char *funcname = text_to_cstring(functionname);
|
||||||
Oid oid;
|
Oid oid;
|
||||||
|
|
||||||
funcname = DatumGetCString(DirectFunctionCall1(textout,
|
|
||||||
PointerGetDatum(functionname)));
|
|
||||||
|
|
||||||
oid = DatumGetObjectId(DirectFunctionCall1(regprocedurein,
|
oid = DatumGetObjectId(DirectFunctionCall1(regprocedurein,
|
||||||
CStringGetDatum(funcname)));
|
CStringGetDatum(funcname)));
|
||||||
|
|
||||||
@ -1977,10 +1962,7 @@ convert_function_name(text *functionname)
|
|||||||
static AclMode
|
static AclMode
|
||||||
convert_function_priv_string(text *priv_type_text)
|
convert_function_priv_string(text *priv_type_text)
|
||||||
{
|
{
|
||||||
char *priv_type;
|
char *priv_type = text_to_cstring(priv_type_text);
|
||||||
|
|
||||||
priv_type = DatumGetCString(DirectFunctionCall1(textout,
|
|
||||||
PointerGetDatum(priv_type_text)));
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return mode from priv_type string
|
* Return mode from priv_type string
|
||||||
@ -2157,12 +2139,9 @@ has_language_privilege_id_id(PG_FUNCTION_ARGS)
|
|||||||
static Oid
|
static Oid
|
||||||
convert_language_name(text *languagename)
|
convert_language_name(text *languagename)
|
||||||
{
|
{
|
||||||
char *langname;
|
char *langname = text_to_cstring(languagename);
|
||||||
Oid oid;
|
Oid oid;
|
||||||
|
|
||||||
langname = DatumGetCString(DirectFunctionCall1(textout,
|
|
||||||
PointerGetDatum(languagename)));
|
|
||||||
|
|
||||||
oid = GetSysCacheOid(LANGNAME,
|
oid = GetSysCacheOid(LANGNAME,
|
||||||
CStringGetDatum(langname),
|
CStringGetDatum(langname),
|
||||||
0, 0, 0);
|
0, 0, 0);
|
||||||
@ -2181,10 +2160,7 @@ convert_language_name(text *languagename)
|
|||||||
static AclMode
|
static AclMode
|
||||||
convert_language_priv_string(text *priv_type_text)
|
convert_language_priv_string(text *priv_type_text)
|
||||||
{
|
{
|
||||||
char *priv_type;
|
char *priv_type = text_to_cstring(priv_type_text);
|
||||||
|
|
||||||
priv_type = DatumGetCString(DirectFunctionCall1(textout,
|
|
||||||
PointerGetDatum(priv_type_text)));
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return mode from priv_type string
|
* Return mode from priv_type string
|
||||||
@ -2361,12 +2337,9 @@ has_schema_privilege_id_id(PG_FUNCTION_ARGS)
|
|||||||
static Oid
|
static Oid
|
||||||
convert_schema_name(text *schemaname)
|
convert_schema_name(text *schemaname)
|
||||||
{
|
{
|
||||||
char *nspname;
|
char *nspname = text_to_cstring(schemaname);
|
||||||
Oid oid;
|
Oid oid;
|
||||||
|
|
||||||
nspname = DatumGetCString(DirectFunctionCall1(textout,
|
|
||||||
PointerGetDatum(schemaname)));
|
|
||||||
|
|
||||||
oid = GetSysCacheOid(NAMESPACENAME,
|
oid = GetSysCacheOid(NAMESPACENAME,
|
||||||
CStringGetDatum(nspname),
|
CStringGetDatum(nspname),
|
||||||
0, 0, 0);
|
0, 0, 0);
|
||||||
@ -2385,10 +2358,7 @@ convert_schema_name(text *schemaname)
|
|||||||
static AclMode
|
static AclMode
|
||||||
convert_schema_priv_string(text *priv_type_text)
|
convert_schema_priv_string(text *priv_type_text)
|
||||||
{
|
{
|
||||||
char *priv_type;
|
char *priv_type = text_to_cstring(priv_type_text);
|
||||||
|
|
||||||
priv_type = DatumGetCString(DirectFunctionCall1(textout,
|
|
||||||
PointerGetDatum(priv_type_text)));
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return mode from priv_type string
|
* Return mode from priv_type string
|
||||||
@ -2569,11 +2539,9 @@ has_tablespace_privilege_id_id(PG_FUNCTION_ARGS)
|
|||||||
static Oid
|
static Oid
|
||||||
convert_tablespace_name(text *tablespacename)
|
convert_tablespace_name(text *tablespacename)
|
||||||
{
|
{
|
||||||
char *spcname;
|
char *spcname = text_to_cstring(tablespacename);
|
||||||
Oid oid;
|
Oid oid;
|
||||||
|
|
||||||
spcname = DatumGetCString(DirectFunctionCall1(textout,
|
|
||||||
PointerGetDatum(tablespacename)));
|
|
||||||
oid = get_tablespace_oid(spcname);
|
oid = get_tablespace_oid(spcname);
|
||||||
|
|
||||||
if (!OidIsValid(oid))
|
if (!OidIsValid(oid))
|
||||||
@ -2591,10 +2559,7 @@ convert_tablespace_name(text *tablespacename)
|
|||||||
static AclMode
|
static AclMode
|
||||||
convert_tablespace_priv_string(text *priv_type_text)
|
convert_tablespace_priv_string(text *priv_type_text)
|
||||||
{
|
{
|
||||||
char *priv_type;
|
char *priv_type = text_to_cstring(priv_type_text);
|
||||||
|
|
||||||
priv_type = DatumGetCString(DirectFunctionCall1(textout,
|
|
||||||
PointerGetDatum(priv_type_text)));
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return mode from priv_type string
|
* Return mode from priv_type string
|
||||||
@ -2777,10 +2742,7 @@ pg_has_role_id_id(PG_FUNCTION_ARGS)
|
|||||||
static AclMode
|
static AclMode
|
||||||
convert_role_priv_string(text *priv_type_text)
|
convert_role_priv_string(text *priv_type_text)
|
||||||
{
|
{
|
||||||
char *priv_type;
|
char *priv_type = text_to_cstring(priv_type_text);
|
||||||
|
|
||||||
priv_type = DatumGetCString(DirectFunctionCall1(textout,
|
|
||||||
PointerGetDatum(priv_type_text)));
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return mode from priv_type string
|
* Return mode from priv_type string
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.141 2008/02/29 20:58:33 alvherre Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.142 2008/03/25 22:42:43 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -1533,39 +1533,33 @@ Datum
|
|||||||
array_dims(PG_FUNCTION_ARGS)
|
array_dims(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
ArrayType *v = PG_GETARG_ARRAYTYPE_P(0);
|
ArrayType *v = PG_GETARG_ARRAYTYPE_P(0);
|
||||||
text *result;
|
|
||||||
char *p;
|
char *p;
|
||||||
int nbytes,
|
int i;
|
||||||
i;
|
|
||||||
int *dimv,
|
int *dimv,
|
||||||
*lb;
|
*lb;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 33 since we assume 15 digits per number + ':' +'[]'
|
||||||
|
*
|
||||||
|
* +1 for trailing null
|
||||||
|
*/
|
||||||
|
char buf[MAXDIM * 33 + 1];
|
||||||
|
|
||||||
/* Sanity check: does it look like an array at all? */
|
/* Sanity check: does it look like an array at all? */
|
||||||
if (ARR_NDIM(v) <= 0 || ARR_NDIM(v) > MAXDIM)
|
if (ARR_NDIM(v) <= 0 || ARR_NDIM(v) > MAXDIM)
|
||||||
PG_RETURN_NULL();
|
PG_RETURN_NULL();
|
||||||
|
|
||||||
nbytes = ARR_NDIM(v) * 33 + 1;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 33 since we assume 15 digits per number + ':' +'[]'
|
|
||||||
*
|
|
||||||
* +1 allows for temp trailing null
|
|
||||||
*/
|
|
||||||
|
|
||||||
result = (text *) palloc(nbytes + VARHDRSZ);
|
|
||||||
p = VARDATA(result);
|
|
||||||
|
|
||||||
dimv = ARR_DIMS(v);
|
dimv = ARR_DIMS(v);
|
||||||
lb = ARR_LBOUND(v);
|
lb = ARR_LBOUND(v);
|
||||||
|
|
||||||
|
p = buf;
|
||||||
for (i = 0; i < ARR_NDIM(v); i++)
|
for (i = 0; i < ARR_NDIM(v); i++)
|
||||||
{
|
{
|
||||||
sprintf(p, "[%d:%d]", lb[i], dimv[i] + lb[i] - 1);
|
sprintf(p, "[%d:%d]", lb[i], dimv[i] + lb[i] - 1);
|
||||||
p += strlen(p);
|
p += strlen(p);
|
||||||
}
|
}
|
||||||
SET_VARSIZE(result, strlen(VARDATA(result)) + VARHDRSZ);
|
|
||||||
|
|
||||||
PG_RETURN_TEXT_P(result);
|
PG_RETURN_TEXT_P(cstring_to_text(buf));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/adt/bool.c,v 1.42 2008/01/01 19:45:52 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/adt/bool.c,v 1.43 2008/03/25 22:42:43 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -152,14 +152,14 @@ Datum
|
|||||||
booltext(PG_FUNCTION_ARGS)
|
booltext(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
bool arg1 = PG_GETARG_BOOL(0);
|
bool arg1 = PG_GETARG_BOOL(0);
|
||||||
char *str;
|
const char *str;
|
||||||
|
|
||||||
if (arg1)
|
if (arg1)
|
||||||
str = "true";
|
str = "true";
|
||||||
else
|
else
|
||||||
str = "false";
|
str = "false";
|
||||||
|
|
||||||
PG_RETURN_DATUM(DirectFunctionCall1(textin, CStringGetDatum(str)));
|
PG_RETURN_TEXT_P(cstring_to_text(str));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
* this version handles 64 bit numbers and so can hold values up to
|
* this version handles 64 bit numbers and so can hold values up to
|
||||||
* $92,233,720,368,547,758.07.
|
* $92,233,720,368,547,758.07.
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/adt/cash.c,v 1.77 2007/11/24 16:18:48 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/adt/cash.c,v 1.78 2008/03/25 22:42:43 tgl Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
@ -24,6 +24,7 @@
|
|||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
|
|
||||||
#include "libpq/pqformat.h"
|
#include "libpq/pqformat.h"
|
||||||
|
#include "utils/builtins.h"
|
||||||
#include "utils/cash.h"
|
#include "utils/cash.h"
|
||||||
#include "utils/pg_locale.h"
|
#include "utils/pg_locale.h"
|
||||||
|
|
||||||
@ -796,7 +797,6 @@ cash_words(PG_FUNCTION_ARGS)
|
|||||||
Cash m4;
|
Cash m4;
|
||||||
Cash m5;
|
Cash m5;
|
||||||
Cash m6;
|
Cash m6;
|
||||||
text *result;
|
|
||||||
|
|
||||||
/* work with positive numbers */
|
/* work with positive numbers */
|
||||||
if (value < 0)
|
if (value < 0)
|
||||||
@ -862,10 +862,6 @@ cash_words(PG_FUNCTION_ARGS)
|
|||||||
/* capitalize output */
|
/* capitalize output */
|
||||||
buf[0] = pg_toupper((unsigned char) buf[0]);
|
buf[0] = pg_toupper((unsigned char) buf[0]);
|
||||||
|
|
||||||
/* make a text type for output */
|
/* return as text datum */
|
||||||
result = (text *) palloc(strlen(buf) + VARHDRSZ);
|
PG_RETURN_TEXT_P(cstring_to_text(buf));
|
||||||
SET_VARSIZE(result, strlen(buf) + VARHDRSZ);
|
|
||||||
memcpy(VARDATA(result), buf, strlen(buf));
|
|
||||||
|
|
||||||
PG_RETURN_TEXT_P(result);
|
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/adt/date.c,v 1.140 2008/03/21 01:31:42 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/adt/date.c,v 1.141 2008/03/25 22:42:43 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -1594,15 +1594,15 @@ time_mi_interval(PG_FUNCTION_ARGS)
|
|||||||
Datum
|
Datum
|
||||||
time_part(PG_FUNCTION_ARGS)
|
time_part(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
text *units = PG_GETARG_TEXT_P(0);
|
text *units = PG_GETARG_TEXT_PP(0);
|
||||||
TimeADT time = PG_GETARG_TIMEADT(1);
|
TimeADT time = PG_GETARG_TIMEADT(1);
|
||||||
float8 result;
|
float8 result;
|
||||||
int type,
|
int type,
|
||||||
val;
|
val;
|
||||||
char *lowunits;
|
char *lowunits;
|
||||||
|
|
||||||
lowunits = downcase_truncate_identifier(VARDATA(units),
|
lowunits = downcase_truncate_identifier(VARDATA_ANY(units),
|
||||||
VARSIZE(units) - VARHDRSZ,
|
VARSIZE_ANY_EXHDR(units),
|
||||||
false);
|
false);
|
||||||
|
|
||||||
type = DecodeUnits(0, lowunits, &val);
|
type = DecodeUnits(0, lowunits, &val);
|
||||||
@ -1666,9 +1666,7 @@ time_part(PG_FUNCTION_ARGS)
|
|||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||||
errmsg("\"time\" units \"%s\" not recognized",
|
errmsg("\"time\" units \"%s\" not recognized",
|
||||||
DatumGetCString(DirectFunctionCall1(textout,
|
lowunits)));
|
||||||
PointerGetDatum(units))))));
|
|
||||||
|
|
||||||
result = 0;
|
result = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1685,8 +1683,7 @@ time_part(PG_FUNCTION_ARGS)
|
|||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||||
errmsg("\"time\" units \"%s\" not recognized",
|
errmsg("\"time\" units \"%s\" not recognized",
|
||||||
DatumGetCString(DirectFunctionCall1(textout,
|
lowunits)));
|
||||||
PointerGetDatum(units))))));
|
|
||||||
result = 0;
|
result = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2323,15 +2320,15 @@ datetimetz_timestamptz(PG_FUNCTION_ARGS)
|
|||||||
Datum
|
Datum
|
||||||
timetz_part(PG_FUNCTION_ARGS)
|
timetz_part(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
text *units = PG_GETARG_TEXT_P(0);
|
text *units = PG_GETARG_TEXT_PP(0);
|
||||||
TimeTzADT *time = PG_GETARG_TIMETZADT_P(1);
|
TimeTzADT *time = PG_GETARG_TIMETZADT_P(1);
|
||||||
float8 result;
|
float8 result;
|
||||||
int type,
|
int type,
|
||||||
val;
|
val;
|
||||||
char *lowunits;
|
char *lowunits;
|
||||||
|
|
||||||
lowunits = downcase_truncate_identifier(VARDATA(units),
|
lowunits = downcase_truncate_identifier(VARDATA_ANY(units),
|
||||||
VARSIZE(units) - VARHDRSZ,
|
VARSIZE_ANY_EXHDR(units),
|
||||||
false);
|
false);
|
||||||
|
|
||||||
type = DecodeUnits(0, lowunits, &val);
|
type = DecodeUnits(0, lowunits, &val);
|
||||||
@ -2408,9 +2405,7 @@ timetz_part(PG_FUNCTION_ARGS)
|
|||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||||
errmsg("\"time with time zone\" units \"%s\" not recognized",
|
errmsg("\"time with time zone\" units \"%s\" not recognized",
|
||||||
DatumGetCString(DirectFunctionCall1(textout,
|
lowunits)));
|
||||||
PointerGetDatum(units))))));
|
|
||||||
|
|
||||||
result = 0;
|
result = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2427,9 +2422,7 @@ timetz_part(PG_FUNCTION_ARGS)
|
|||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||||
errmsg("\"time with time zone\" units \"%s\" not recognized",
|
errmsg("\"time with time zone\" units \"%s\" not recognized",
|
||||||
DatumGetCString(DirectFunctionCall1(textout,
|
lowunits)));
|
||||||
PointerGetDatum(units))))));
|
|
||||||
|
|
||||||
result = 0;
|
result = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2443,12 +2436,11 @@ timetz_part(PG_FUNCTION_ARGS)
|
|||||||
Datum
|
Datum
|
||||||
timetz_zone(PG_FUNCTION_ARGS)
|
timetz_zone(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
text *zone = PG_GETARG_TEXT_P(0);
|
text *zone = PG_GETARG_TEXT_PP(0);
|
||||||
TimeTzADT *t = PG_GETARG_TIMETZADT_P(1);
|
TimeTzADT *t = PG_GETARG_TIMETZADT_P(1);
|
||||||
TimeTzADT *result;
|
TimeTzADT *result;
|
||||||
int tz;
|
int tz;
|
||||||
char tzname[TZ_STRLEN_MAX + 1];
|
char tzname[TZ_STRLEN_MAX + 1];
|
||||||
int len;
|
|
||||||
pg_tz *tzp;
|
pg_tz *tzp;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2456,9 +2448,7 @@ timetz_zone(PG_FUNCTION_ARGS)
|
|||||||
* (to handle cases like "America/New_York"), and if that fails, we look
|
* (to handle cases like "America/New_York"), and if that fails, we look
|
||||||
* in the date token table (to handle cases like "EST").
|
* in the date token table (to handle cases like "EST").
|
||||||
*/
|
*/
|
||||||
len = Min(VARSIZE(zone) - VARHDRSZ, TZ_STRLEN_MAX);
|
text_to_cstring_buffer(zone, tzname, sizeof(tzname));
|
||||||
memcpy(tzname, VARDATA(zone), len);
|
|
||||||
tzname[len] = '\0';
|
|
||||||
tzp = pg_tzset(tzname);
|
tzp = pg_tzset(tzname);
|
||||||
if (tzp)
|
if (tzp)
|
||||||
{
|
{
|
||||||
@ -2475,8 +2465,8 @@ timetz_zone(PG_FUNCTION_ARGS)
|
|||||||
int type,
|
int type,
|
||||||
val;
|
val;
|
||||||
|
|
||||||
lowzone = downcase_truncate_identifier(VARDATA(zone),
|
lowzone = downcase_truncate_identifier(tzname,
|
||||||
VARSIZE(zone) - VARHDRSZ,
|
strlen(tzname),
|
||||||
false);
|
false);
|
||||||
type = DecodeSpecial(0, lowzone, &val);
|
type = DecodeSpecial(0, lowzone, &val);
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.187 2008/02/25 23:36:28 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.188 2008/03/25 22:42:43 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -3910,7 +3910,7 @@ pg_timezone_abbrevs(PG_FUNCTION_ARGS)
|
|||||||
for (p = (unsigned char *) buffer; *p; p++)
|
for (p = (unsigned char *) buffer; *p; p++)
|
||||||
*p = pg_toupper(*p);
|
*p = pg_toupper(*p);
|
||||||
|
|
||||||
values[0] = DirectFunctionCall1(textin, CStringGetDatum(buffer));
|
values[0] = CStringGetTextDatum(buffer);
|
||||||
|
|
||||||
MemSet(&tm, 0, sizeof(struct pg_tm));
|
MemSet(&tm, 0, sizeof(struct pg_tm));
|
||||||
tm.tm_min = (-1) * FROMVAL(&timezonetktbl[*pindex]);
|
tm.tm_min = (-1) * FROMVAL(&timezonetktbl[*pindex]);
|
||||||
@ -4020,11 +4020,8 @@ pg_timezone_names(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
MemSet(nulls, 0, sizeof(nulls));
|
MemSet(nulls, 0, sizeof(nulls));
|
||||||
|
|
||||||
values[0] = DirectFunctionCall1(textin,
|
values[0] = CStringGetTextDatum(pg_get_timezone_name(tz));
|
||||||
CStringGetDatum(pg_get_timezone_name(tz)));
|
values[1] = CStringGetTextDatum(tzn ? tzn : "");
|
||||||
|
|
||||||
values[1] = DirectFunctionCall1(textin,
|
|
||||||
CStringGetDatum(tzn ? tzn : ""));
|
|
||||||
|
|
||||||
MemSet(&itm, 0, sizeof(struct pg_tm));
|
MemSet(&itm, 0, sizeof(struct pg_tm));
|
||||||
itm.tm_sec = -tzoff;
|
itm.tm_sec = -tzoff;
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* Copyright (c) 2002-2008, PostgreSQL Global Development Group
|
* Copyright (c) 2002-2008, PostgreSQL Global Development Group
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/adt/dbsize.c,v 1.16 2008/01/01 19:45:52 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/adt/dbsize.c,v 1.17 2008/03/25 22:42:44 tgl Exp $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -393,41 +393,39 @@ Datum
|
|||||||
pg_size_pretty(PG_FUNCTION_ARGS)
|
pg_size_pretty(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
int64 size = PG_GETARG_INT64(0);
|
int64 size = PG_GETARG_INT64(0);
|
||||||
char *result = palloc(50 + VARHDRSZ);
|
char buf[64];
|
||||||
int64 limit = 10 * 1024;
|
int64 limit = 10 * 1024;
|
||||||
int64 mult = 1;
|
int64 mult = 1;
|
||||||
|
|
||||||
if (size < limit * mult)
|
if (size < limit * mult)
|
||||||
snprintf(VARDATA(result), 50, INT64_FORMAT " bytes", size);
|
snprintf(buf, sizeof(buf), INT64_FORMAT " bytes", size);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mult *= 1024;
|
mult *= 1024;
|
||||||
if (size < limit * mult)
|
if (size < limit * mult)
|
||||||
snprintf(VARDATA(result), 50, INT64_FORMAT " kB",
|
snprintf(buf, sizeof(buf), INT64_FORMAT " kB",
|
||||||
(size + mult / 2) / mult);
|
(size + mult / 2) / mult);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mult *= 1024;
|
mult *= 1024;
|
||||||
if (size < limit * mult)
|
if (size < limit * mult)
|
||||||
snprintf(VARDATA(result), 50, INT64_FORMAT " MB",
|
snprintf(buf, sizeof(buf), INT64_FORMAT " MB",
|
||||||
(size + mult / 2) / mult);
|
(size + mult / 2) / mult);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mult *= 1024;
|
mult *= 1024;
|
||||||
if (size < limit * mult)
|
if (size < limit * mult)
|
||||||
snprintf(VARDATA(result), 50, INT64_FORMAT " GB",
|
snprintf(buf, sizeof(buf), INT64_FORMAT " GB",
|
||||||
(size + mult / 2) / mult);
|
(size + mult / 2) / mult);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mult *= 1024;
|
mult *= 1024;
|
||||||
snprintf(VARDATA(result), 50, INT64_FORMAT " TB",
|
snprintf(buf, sizeof(buf), INT64_FORMAT " TB",
|
||||||
(size + mult / 2) / mult);
|
(size + mult / 2) / mult);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SET_VARSIZE(result, strlen(VARDATA(result)) + VARHDRSZ);
|
PG_RETURN_TEXT_P(cstring_to_text(buf));
|
||||||
|
|
||||||
PG_RETURN_TEXT_P(result);
|
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/adt/encode.c,v 1.21 2008/02/26 02:54:08 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/adt/encode.c,v 1.22 2008/03/25 22:42:44 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -46,7 +46,7 @@ binary_encode(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
datalen = VARSIZE(data) - VARHDRSZ;
|
datalen = VARSIZE(data) - VARHDRSZ;
|
||||||
|
|
||||||
namebuf = DatumGetCString(DirectFunctionCall1(textout, name));
|
namebuf = TextDatumGetCString(name);
|
||||||
|
|
||||||
enc = pg_find_encoding(namebuf);
|
enc = pg_find_encoding(namebuf);
|
||||||
if (enc == NULL)
|
if (enc == NULL)
|
||||||
@ -82,7 +82,7 @@ binary_decode(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
datalen = VARSIZE(data) - VARHDRSZ;
|
datalen = VARSIZE(data) - VARHDRSZ;
|
||||||
|
|
||||||
namebuf = DatumGetCString(DirectFunctionCall1(textout, name));
|
namebuf = TextDatumGetCString(name);
|
||||||
|
|
||||||
enc = pg_find_encoding(namebuf);
|
enc = pg_find_encoding(namebuf);
|
||||||
if (enc == NULL)
|
if (enc == NULL)
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/adt/format_type.c,v 1.49 2008/01/01 19:45:52 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/adt/format_type.c,v 1.50 2008/03/25 22:42:44 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -26,7 +26,6 @@
|
|||||||
#include "mb/pg_wchar.h"
|
#include "mb/pg_wchar.h"
|
||||||
|
|
||||||
#define MAX_INT32_LEN 11
|
#define MAX_INT32_LEN 11
|
||||||
#define _textin(str) DirectFunctionCall1(textin, CStringGetDatum(str))
|
|
||||||
|
|
||||||
static char *format_type_internal(Oid type_oid, int32 typemod,
|
static char *format_type_internal(Oid type_oid, int32 typemod,
|
||||||
bool typemod_given, bool allow_invalid);
|
bool typemod_given, bool allow_invalid);
|
||||||
@ -84,7 +83,7 @@ format_type(PG_FUNCTION_ARGS)
|
|||||||
result = format_type_internal(type_oid, typemod, true, true);
|
result = format_type_internal(type_oid, typemod, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
PG_RETURN_DATUM(_textin(result));
|
PG_RETURN_TEXT_P(cstring_to_text(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -454,7 +453,7 @@ oidvectortypes(PG_FUNCTION_ARGS)
|
|||||||
left -= slen;
|
left -= slen;
|
||||||
}
|
}
|
||||||
|
|
||||||
PG_RETURN_DATUM(_textin(result));
|
PG_RETURN_TEXT_P(cstring_to_text(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/* -----------------------------------------------------------------------
|
/* -----------------------------------------------------------------------
|
||||||
* formatting.c
|
* formatting.c
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.138 2008/03/22 22:32:19 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.139 2008/03/25 22:42:44 tgl Exp $
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* Portions Copyright (c) 1999-2008, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1999-2008, PostgreSQL Global Development Group
|
||||||
@ -924,7 +924,7 @@ static int seq_search(char *name, char **array, int type, int max, int *len);
|
|||||||
static void do_to_timestamp(text *date_txt, text *fmt,
|
static void do_to_timestamp(text *date_txt, text *fmt,
|
||||||
struct pg_tm * tm, fsec_t *fsec);
|
struct pg_tm * tm, fsec_t *fsec);
|
||||||
static char *fill_str(char *str, int c, int max);
|
static char *fill_str(char *str, int c, int max);
|
||||||
static FormatNode *NUM_cache(int len, NUMDesc *Num, char *pars_str, bool *shouldFree);
|
static FormatNode *NUM_cache(int len, NUMDesc *Num, text *pars_str, bool *shouldFree);
|
||||||
static char *int_to_roman(int number);
|
static char *int_to_roman(int number);
|
||||||
static void NUM_prepare_locale(NUMProc *Np);
|
static void NUM_prepare_locale(NUMProc *Np);
|
||||||
static char *get_last_relevant_decnum(char *num);
|
static char *get_last_relevant_decnum(char *num);
|
||||||
@ -2709,16 +2709,14 @@ datetime_to_char_body(TmToChar *tmtc, text *fmt, bool is_interval)
|
|||||||
char *fmt_str,
|
char *fmt_str,
|
||||||
*result;
|
*result;
|
||||||
bool incache;
|
bool incache;
|
||||||
int fmt_len = VARSIZE(fmt) - VARHDRSZ;
|
int fmt_len;
|
||||||
int reslen;
|
|
||||||
text *res;
|
text *res;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Convert fmt to C string
|
* Convert fmt to C string
|
||||||
*/
|
*/
|
||||||
fmt_str = (char *) palloc(fmt_len + 1);
|
fmt_str = text_to_cstring(fmt);
|
||||||
memcpy(fmt_str, VARDATA(fmt), fmt_len);
|
fmt_len = strlen(fmt_str);
|
||||||
*(fmt_str + fmt_len) = '\0';
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Allocate workspace for result as C string
|
* Allocate workspace for result as C string
|
||||||
@ -2779,10 +2777,7 @@ datetime_to_char_body(TmToChar *tmtc, text *fmt, bool is_interval)
|
|||||||
pfree(fmt_str);
|
pfree(fmt_str);
|
||||||
|
|
||||||
/* convert C-string result to TEXT format */
|
/* convert C-string result to TEXT format */
|
||||||
reslen = strlen(result);
|
res = cstring_to_text(result);
|
||||||
res = (text *) palloc(reslen + VARHDRSZ);
|
|
||||||
memcpy(VARDATA(res), result, reslen);
|
|
||||||
SET_VARSIZE(res, reslen + VARHDRSZ);
|
|
||||||
|
|
||||||
pfree(result);
|
pfree(result);
|
||||||
return res;
|
return res;
|
||||||
@ -3135,18 +3130,15 @@ do_to_timestamp(text *date_txt, text *fmt,
|
|||||||
ZERO_tm(tm);
|
ZERO_tm(tm);
|
||||||
*fsec = 0;
|
*fsec = 0;
|
||||||
|
|
||||||
fmt_len = VARSIZE(fmt) - VARHDRSZ;
|
fmt_len = VARSIZE_ANY_EXHDR(fmt);
|
||||||
|
|
||||||
if (fmt_len)
|
if (fmt_len)
|
||||||
{
|
{
|
||||||
int date_len;
|
|
||||||
char *fmt_str;
|
char *fmt_str;
|
||||||
char *date_str;
|
char *date_str;
|
||||||
bool incache;
|
bool incache;
|
||||||
|
|
||||||
fmt_str = (char *) palloc(fmt_len + 1);
|
fmt_str = text_to_cstring(fmt);
|
||||||
memcpy(fmt_str, VARDATA(fmt), fmt_len);
|
|
||||||
*(fmt_str + fmt_len) = '\0';
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Allocate new memory if format picture is bigger than static cache
|
* Allocate new memory if format picture is bigger than static cache
|
||||||
@ -3195,13 +3187,7 @@ do_to_timestamp(text *date_txt, text *fmt,
|
|||||||
/* dump_node(format, fmt_len); */
|
/* dump_node(format, fmt_len); */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
date_str = text_to_cstring(date_txt);
|
||||||
* Convert date to C string
|
|
||||||
*/
|
|
||||||
date_len = VARSIZE(date_txt) - VARHDRSZ;
|
|
||||||
date_str = (char *) palloc(date_len + 1);
|
|
||||||
memcpy(date_str, VARDATA(date_txt), date_len);
|
|
||||||
*(date_str + date_len) = '\0';
|
|
||||||
|
|
||||||
DCH_from_char(format, date_str, &tmfc);
|
DCH_from_char(format, date_str, &tmfc);
|
||||||
|
|
||||||
@ -3548,17 +3534,12 @@ NUM_cache_remove(NUMCacheEntry *ent)
|
|||||||
* ----------
|
* ----------
|
||||||
*/
|
*/
|
||||||
static FormatNode *
|
static FormatNode *
|
||||||
NUM_cache(int len, NUMDesc *Num, char *pars_str, bool *shouldFree)
|
NUM_cache(int len, NUMDesc *Num, text *pars_str, bool *shouldFree)
|
||||||
{
|
{
|
||||||
FormatNode *format = NULL;
|
FormatNode *format = NULL;
|
||||||
char *str;
|
char *str;
|
||||||
|
|
||||||
/*
|
str = text_to_cstring(pars_str);
|
||||||
* Convert VARDATA() to string
|
|
||||||
*/
|
|
||||||
str = (char *) palloc(len + 1);
|
|
||||||
memcpy(str, pars_str, len);
|
|
||||||
*(str + len) = '\0';
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Allocate new memory if format picture is bigger than static cache and
|
* Allocate new memory if format picture is bigger than static cache and
|
||||||
@ -4597,11 +4578,11 @@ NUM_processor(FormatNode *node, NUMDesc *Num, char *inout, char *number,
|
|||||||
*/
|
*/
|
||||||
#define NUM_TOCHAR_prepare \
|
#define NUM_TOCHAR_prepare \
|
||||||
do { \
|
do { \
|
||||||
len = VARSIZE(fmt) - VARHDRSZ; \
|
len = VARSIZE_ANY_EXHDR(fmt); \
|
||||||
if (len <= 0 || len >= (INT_MAX-VARHDRSZ)/NUM_MAX_ITEM_SIZ) \
|
if (len <= 0 || len >= (INT_MAX-VARHDRSZ)/NUM_MAX_ITEM_SIZ) \
|
||||||
return DirectFunctionCall1(textin, CStringGetDatum("")); \
|
PG_RETURN_TEXT_P(cstring_to_text("")); \
|
||||||
result = (text *) palloc0((len * NUM_MAX_ITEM_SIZ) + 1 + VARHDRSZ); \
|
result = (text *) palloc0((len * NUM_MAX_ITEM_SIZ) + 1 + VARHDRSZ); \
|
||||||
format = NUM_cache(len, &Num, VARDATA(fmt), &shouldFree); \
|
format = NUM_cache(len, &Num, fmt, &shouldFree); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
/* ----------
|
/* ----------
|
||||||
@ -4647,7 +4628,7 @@ numeric_to_number(PG_FUNCTION_ARGS)
|
|||||||
if (len <= 0 || len >= INT_MAX / NUM_MAX_ITEM_SIZ)
|
if (len <= 0 || len >= INT_MAX / NUM_MAX_ITEM_SIZ)
|
||||||
PG_RETURN_NULL();
|
PG_RETURN_NULL();
|
||||||
|
|
||||||
format = NUM_cache(len, &Num, VARDATA(fmt), &shouldFree);
|
format = NUM_cache(len, &Num, fmt, &shouldFree);
|
||||||
|
|
||||||
numstr = (char *) palloc((len * NUM_MAX_ITEM_SIZ) + 1);
|
numstr = (char *) palloc((len * NUM_MAX_ITEM_SIZ) + 1);
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
* Author: Andreas Pflug <pgadmin@pse-consulting.de>
|
* Author: Andreas Pflug <pgadmin@pse-consulting.de>
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/adt/genfile.c,v 1.17 2008/01/01 19:45:52 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/adt/genfile.c,v 1.18 2008/03/25 22:42:44 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -46,12 +46,9 @@ typedef struct
|
|||||||
static char *
|
static char *
|
||||||
convert_and_check_filename(text *arg)
|
convert_and_check_filename(text *arg)
|
||||||
{
|
{
|
||||||
int input_len = VARSIZE(arg) - VARHDRSZ;
|
char *filename;
|
||||||
char *filename = palloc(input_len + 1);
|
|
||||||
|
|
||||||
memcpy(filename, VARDATA(arg), input_len);
|
|
||||||
filename[input_len] = '\0';
|
|
||||||
|
|
||||||
|
filename = text_to_cstring(arg);
|
||||||
canonicalize_path(filename); /* filename can change length here */
|
canonicalize_path(filename); /* filename can change length here */
|
||||||
|
|
||||||
/* Disallow ".." in the path */
|
/* Disallow ".." in the path */
|
||||||
@ -253,18 +250,11 @@ pg_ls_dir(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
while ((de = ReadDir(fctx->dirdesc, fctx->location)) != NULL)
|
while ((de = ReadDir(fctx->dirdesc, fctx->location)) != NULL)
|
||||||
{
|
{
|
||||||
int len = strlen(de->d_name);
|
|
||||||
text *result;
|
|
||||||
|
|
||||||
if (strcmp(de->d_name, ".") == 0 ||
|
if (strcmp(de->d_name, ".") == 0 ||
|
||||||
strcmp(de->d_name, "..") == 0)
|
strcmp(de->d_name, "..") == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
result = palloc(len + VARHDRSZ);
|
SRF_RETURN_NEXT(funcctx, CStringGetTextDatum(de->d_name));
|
||||||
SET_VARSIZE(result, len + VARHDRSZ);
|
|
||||||
memcpy(VARDATA(result), de->d_name, len);
|
|
||||||
|
|
||||||
SRF_RETURN_NEXT(funcctx, PointerGetDatum(result));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FreeDir(fctx->dirdesc);
|
FreeDir(fctx->dirdesc);
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* Copyright (c) 2002-2008, PostgreSQL Global Development Group
|
* Copyright (c) 2002-2008, PostgreSQL Global Development Group
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/adt/lockfuncs.c,v 1.32 2008/01/08 23:18:51 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/adt/lockfuncs.c,v 1.33 2008/03/25 22:42:44 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -57,7 +57,7 @@ VXIDGetDatum(BackendId bid, LocalTransactionId lxid)
|
|||||||
|
|
||||||
snprintf(vxidstr, sizeof(vxidstr), "%d/%u", bid, lxid);
|
snprintf(vxidstr, sizeof(vxidstr), "%d/%u", bid, lxid);
|
||||||
|
|
||||||
return DirectFunctionCall1(textin, CStringGetDatum(vxidstr));
|
return CStringGetTextDatum(vxidstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -214,8 +214,7 @@ pg_lock_status(PG_FUNCTION_ARGS)
|
|||||||
(int) lock->tag.locktag_type);
|
(int) lock->tag.locktag_type);
|
||||||
locktypename = tnbuf;
|
locktypename = tnbuf;
|
||||||
}
|
}
|
||||||
values[0] = DirectFunctionCall1(textin,
|
values[0] = CStringGetTextDatum(locktypename);
|
||||||
CStringGetDatum(locktypename));
|
|
||||||
|
|
||||||
switch ((LockTagType) lock->tag.locktag_type)
|
switch ((LockTagType) lock->tag.locktag_type)
|
||||||
{
|
{
|
||||||
@ -297,9 +296,7 @@ pg_lock_status(PG_FUNCTION_ARGS)
|
|||||||
values[11] = Int32GetDatum(proc->pid);
|
values[11] = Int32GetDatum(proc->pid);
|
||||||
else
|
else
|
||||||
nulls[11] = 'n';
|
nulls[11] = 'n';
|
||||||
values[12] = DirectFunctionCall1(textin,
|
values[12] = CStringGetTextDatum(GetLockmodeName(LOCK_LOCKMETHOD(*lock), mode));
|
||||||
CStringGetDatum(GetLockmodeName(LOCK_LOCKMETHOD(*lock),
|
|
||||||
mode)));
|
|
||||||
values[13] = BoolGetDatum(granted);
|
values[13] = BoolGetDatum(granted);
|
||||||
|
|
||||||
tuple = heap_formtuple(funcctx->tuple_desc, values, nulls);
|
tuple = heap_formtuple(funcctx->tuple_desc, values, nulls);
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/adt/nabstime.c,v 1.154 2008/03/21 01:31:42 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/adt/nabstime.c,v 1.155 2008/03/25 22:42:44 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -1576,8 +1576,6 @@ timeofday(PG_FUNCTION_ARGS)
|
|||||||
struct timeval tp;
|
struct timeval tp;
|
||||||
char templ[128];
|
char templ[128];
|
||||||
char buf[128];
|
char buf[128];
|
||||||
text *result;
|
|
||||||
int len;
|
|
||||||
pg_time_t tt;
|
pg_time_t tt;
|
||||||
|
|
||||||
gettimeofday(&tp, NULL);
|
gettimeofday(&tp, NULL);
|
||||||
@ -1586,9 +1584,5 @@ timeofday(PG_FUNCTION_ARGS)
|
|||||||
pg_localtime(&tt, session_timezone));
|
pg_localtime(&tt, session_timezone));
|
||||||
snprintf(buf, sizeof(buf), templ, tp.tv_usec);
|
snprintf(buf, sizeof(buf), templ, tp.tv_usec);
|
||||||
|
|
||||||
len = VARHDRSZ + strlen(buf);
|
PG_RETURN_TEXT_P(cstring_to_text(buf));
|
||||||
result = (text *) palloc(len);
|
|
||||||
SET_VARSIZE(result, len);
|
|
||||||
memcpy(VARDATA(result), buf, len - VARHDRSZ);
|
|
||||||
PG_RETURN_TEXT_P(result);
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* PostgreSQL type definitions for the INET and CIDR types.
|
* PostgreSQL type definitions for the INET and CIDR types.
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/adt/network.c,v 1.72 2007/11/15 21:14:39 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/adt/network.c,v 1.73 2008/03/25 22:42:44 tgl Exp $
|
||||||
*
|
*
|
||||||
* Jon Postel RIP 16 Oct 1998
|
* Jon Postel RIP 16 Oct 1998
|
||||||
*/
|
*/
|
||||||
@ -601,8 +601,6 @@ Datum
|
|||||||
network_host(PG_FUNCTION_ARGS)
|
network_host(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
inet *ip = PG_GETARG_INET_P(0);
|
inet *ip = PG_GETARG_INET_P(0);
|
||||||
text *ret;
|
|
||||||
int len;
|
|
||||||
char *ptr;
|
char *ptr;
|
||||||
char tmp[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:255.255.255.255/128")];
|
char tmp[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:255.255.255.255/128")];
|
||||||
|
|
||||||
@ -617,12 +615,7 @@ network_host(PG_FUNCTION_ARGS)
|
|||||||
if ((ptr = strchr(tmp, '/')) != NULL)
|
if ((ptr = strchr(tmp, '/')) != NULL)
|
||||||
*ptr = '\0';
|
*ptr = '\0';
|
||||||
|
|
||||||
/* Return string as a text datum */
|
PG_RETURN_TEXT_P(cstring_to_text(tmp));
|
||||||
len = strlen(tmp);
|
|
||||||
ret = (text *) palloc(len + VARHDRSZ);
|
|
||||||
SET_VARSIZE(ret, len + VARHDRSZ);
|
|
||||||
memcpy(VARDATA(ret), tmp, len);
|
|
||||||
PG_RETURN_TEXT_P(ret);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -634,7 +627,6 @@ Datum
|
|||||||
network_show(PG_FUNCTION_ARGS)
|
network_show(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
inet *ip = PG_GETARG_INET_P(0);
|
inet *ip = PG_GETARG_INET_P(0);
|
||||||
text *ret;
|
|
||||||
int len;
|
int len;
|
||||||
char tmp[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:255.255.255.255/128")];
|
char tmp[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:255.255.255.255/128")];
|
||||||
|
|
||||||
@ -651,21 +643,14 @@ network_show(PG_FUNCTION_ARGS)
|
|||||||
snprintf(tmp + len, sizeof(tmp) - len, "/%u", ip_bits(ip));
|
snprintf(tmp + len, sizeof(tmp) - len, "/%u", ip_bits(ip));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return string as a text datum */
|
PG_RETURN_TEXT_P(cstring_to_text(tmp));
|
||||||
len = strlen(tmp);
|
|
||||||
ret = (text *) palloc(len + VARHDRSZ);
|
|
||||||
SET_VARSIZE(ret, len + VARHDRSZ);
|
|
||||||
memcpy(VARDATA(ret), tmp, len);
|
|
||||||
PG_RETURN_TEXT_P(ret);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Datum
|
Datum
|
||||||
inet_abbrev(PG_FUNCTION_ARGS)
|
inet_abbrev(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
inet *ip = PG_GETARG_INET_P(0);
|
inet *ip = PG_GETARG_INET_P(0);
|
||||||
text *ret;
|
|
||||||
char *dst;
|
char *dst;
|
||||||
int len;
|
|
||||||
char tmp[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:255.255.255.255/128")];
|
char tmp[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:255.255.255.255/128")];
|
||||||
|
|
||||||
dst = inet_net_ntop(ip_family(ip), ip_addr(ip),
|
dst = inet_net_ntop(ip_family(ip), ip_addr(ip),
|
||||||
@ -676,21 +661,14 @@ inet_abbrev(PG_FUNCTION_ARGS)
|
|||||||
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
|
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
|
||||||
errmsg("could not format inet value: %m")));
|
errmsg("could not format inet value: %m")));
|
||||||
|
|
||||||
/* Return string as a text datum */
|
PG_RETURN_TEXT_P(cstring_to_text(tmp));
|
||||||
len = strlen(tmp);
|
|
||||||
ret = (text *) palloc(len + VARHDRSZ);
|
|
||||||
SET_VARSIZE(ret, len + VARHDRSZ);
|
|
||||||
memcpy(VARDATA(ret), tmp, len);
|
|
||||||
PG_RETURN_TEXT_P(ret);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Datum
|
Datum
|
||||||
cidr_abbrev(PG_FUNCTION_ARGS)
|
cidr_abbrev(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
inet *ip = PG_GETARG_INET_P(0);
|
inet *ip = PG_GETARG_INET_P(0);
|
||||||
text *ret;
|
|
||||||
char *dst;
|
char *dst;
|
||||||
int len;
|
|
||||||
char tmp[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:255.255.255.255/128")];
|
char tmp[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:255.255.255.255/128")];
|
||||||
|
|
||||||
dst = inet_cidr_ntop(ip_family(ip), ip_addr(ip),
|
dst = inet_cidr_ntop(ip_family(ip), ip_addr(ip),
|
||||||
@ -701,12 +679,7 @@ cidr_abbrev(PG_FUNCTION_ARGS)
|
|||||||
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
|
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
|
||||||
errmsg("could not format cidr value: %m")));
|
errmsg("could not format cidr value: %m")));
|
||||||
|
|
||||||
/* Return string as a text datum */
|
PG_RETURN_TEXT_P(cstring_to_text(tmp));
|
||||||
len = strlen(tmp);
|
|
||||||
ret = (text *) palloc(len + VARHDRSZ);
|
|
||||||
SET_VARSIZE(ret, len + VARHDRSZ);
|
|
||||||
memcpy(VARDATA(ret), tmp, len);
|
|
||||||
PG_RETURN_TEXT_P(ret);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Datum
|
Datum
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/adt/oracle_compat.c,v 1.77 2008/01/01 19:45:52 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/adt/oracle_compat.c,v 1.78 2008/03/25 22:42:44 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -76,9 +76,7 @@ texttowcs(const text *txt)
|
|||||||
errmsg("out of memory")));
|
errmsg("out of memory")));
|
||||||
|
|
||||||
/* Need a null-terminated version of the input */
|
/* Need a null-terminated version of the input */
|
||||||
workstr = (char *) palloc(nbytes + 1);
|
workstr = text_to_cstring(txt);
|
||||||
memcpy(workstr, VARDATA_ANY(txt), nbytes);
|
|
||||||
workstr[nbytes] = '\0';
|
|
||||||
|
|
||||||
/* Output workspace cannot have more codes than input bytes */
|
/* Output workspace cannot have more codes than input bytes */
|
||||||
result = (wchar_t *) palloc((nbytes + 1) * sizeof(wchar_t));
|
result = (wchar_t *) palloc((nbytes + 1) * sizeof(wchar_t));
|
||||||
@ -275,25 +273,16 @@ wstring_upper(char *str)
|
|||||||
text *in_text;
|
text *in_text;
|
||||||
text *out_text;
|
text *out_text;
|
||||||
char *result;
|
char *result;
|
||||||
int nbytes = strlen(str);
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
in_text = palloc(nbytes + VARHDRSZ);
|
in_text = cstring_to_text(str);
|
||||||
memcpy(VARDATA(in_text), str, nbytes);
|
|
||||||
SET_VARSIZE(in_text, nbytes + VARHDRSZ);
|
|
||||||
|
|
||||||
workspace = texttowcs(in_text);
|
workspace = texttowcs(in_text);
|
||||||
|
|
||||||
for (i = 0; workspace[i] != 0; i++)
|
for (i = 0; workspace[i] != 0; i++)
|
||||||
workspace[i] = towupper(workspace[i]);
|
workspace[i] = towupper(workspace[i]);
|
||||||
|
|
||||||
out_text = wcstotext(workspace, i);
|
out_text = wcstotext(workspace, i);
|
||||||
|
result = text_to_cstring(out_text);
|
||||||
nbytes = VARSIZE(out_text) - VARHDRSZ;
|
|
||||||
result = palloc(nbytes + 1);
|
|
||||||
memcpy(result, VARDATA(out_text), nbytes);
|
|
||||||
|
|
||||||
result[nbytes] = '\0';
|
|
||||||
|
|
||||||
pfree(workspace);
|
pfree(workspace);
|
||||||
pfree(in_text);
|
pfree(in_text);
|
||||||
@ -309,25 +298,16 @@ wstring_lower(char *str)
|
|||||||
text *in_text;
|
text *in_text;
|
||||||
text *out_text;
|
text *out_text;
|
||||||
char *result;
|
char *result;
|
||||||
int nbytes = strlen(str);
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
in_text = palloc(nbytes + VARHDRSZ);
|
in_text = cstring_to_text(str);
|
||||||
memcpy(VARDATA(in_text), str, nbytes);
|
|
||||||
SET_VARSIZE(in_text, nbytes + VARHDRSZ);
|
|
||||||
|
|
||||||
workspace = texttowcs(in_text);
|
workspace = texttowcs(in_text);
|
||||||
|
|
||||||
for (i = 0; workspace[i] != 0; i++)
|
for (i = 0; workspace[i] != 0; i++)
|
||||||
workspace[i] = towlower(workspace[i]);
|
workspace[i] = towlower(workspace[i]);
|
||||||
|
|
||||||
out_text = wcstotext(workspace, i);
|
out_text = wcstotext(workspace, i);
|
||||||
|
result = text_to_cstring(out_text);
|
||||||
nbytes = VARSIZE(out_text) - VARHDRSZ;
|
|
||||||
result = palloc(nbytes + 1);
|
|
||||||
memcpy(result, VARDATA(out_text), nbytes);
|
|
||||||
|
|
||||||
result[nbytes] = '\0';
|
|
||||||
|
|
||||||
pfree(workspace);
|
pfree(workspace);
|
||||||
pfree(in_text);
|
pfree(in_text);
|
||||||
@ -801,7 +781,6 @@ dotrim(const char *string, int stringlen,
|
|||||||
const char *set, int setlen,
|
const char *set, int setlen,
|
||||||
bool doltrim, bool dortrim)
|
bool doltrim, bool dortrim)
|
||||||
{
|
{
|
||||||
text *result;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* Nothing to do if either string or set is empty */
|
/* Nothing to do if either string or set is empty */
|
||||||
@ -947,11 +926,7 @@ dotrim(const char *string, int stringlen,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Return selected portion of string */
|
/* Return selected portion of string */
|
||||||
result = (text *) palloc(VARHDRSZ + stringlen);
|
return cstring_to_text_with_len(string, stringlen);
|
||||||
SET_VARSIZE(result, VARHDRSZ + stringlen);
|
|
||||||
memcpy(VARDATA(result), string, stringlen);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************************
|
/********************************************************************
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/adt/pgstatfuncs.c,v 1.48 2008/01/01 19:45:52 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/adt/pgstatfuncs.c,v 1.49 2008/03/25 22:42:44 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -414,9 +414,7 @@ Datum
|
|||||||
pg_stat_get_backend_activity(PG_FUNCTION_ARGS)
|
pg_stat_get_backend_activity(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
int32 beid = PG_GETARG_INT32(0);
|
int32 beid = PG_GETARG_INT32(0);
|
||||||
text *result;
|
|
||||||
PgBackendStatus *beentry;
|
PgBackendStatus *beentry;
|
||||||
int len;
|
|
||||||
const char *activity;
|
const char *activity;
|
||||||
|
|
||||||
if ((beentry = pgstat_fetch_stat_beentry(beid)) == NULL)
|
if ((beentry = pgstat_fetch_stat_beentry(beid)) == NULL)
|
||||||
@ -428,12 +426,7 @@ pg_stat_get_backend_activity(PG_FUNCTION_ARGS)
|
|||||||
else
|
else
|
||||||
activity = beentry->st_activity;
|
activity = beentry->st_activity;
|
||||||
|
|
||||||
len = strlen(activity);
|
PG_RETURN_TEXT_P(cstring_to_text(activity));
|
||||||
result = palloc(VARHDRSZ + len);
|
|
||||||
SET_VARSIZE(result, VARHDRSZ + len);
|
|
||||||
memcpy(VARDATA(result), activity, len);
|
|
||||||
|
|
||||||
PG_RETURN_TEXT_P(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/adt/quote.c,v 1.24 2008/03/23 00:24:19 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/adt/quote.c,v 1.25 2008/03/25 22:42:44 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -23,26 +23,13 @@
|
|||||||
Datum
|
Datum
|
||||||
quote_ident(PG_FUNCTION_ARGS)
|
quote_ident(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
text *t = PG_GETARG_TEXT_P(0);
|
text *t = PG_GETARG_TEXT_PP(0);
|
||||||
text *result;
|
|
||||||
const char *qstr;
|
const char *qstr;
|
||||||
char *str;
|
char *str;
|
||||||
int len;
|
|
||||||
|
|
||||||
/* We have to convert to a C string to use quote_identifier */
|
|
||||||
len = VARSIZE(t) - VARHDRSZ;
|
|
||||||
str = (char *) palloc(len + 1);
|
|
||||||
memcpy(str, VARDATA(t), len);
|
|
||||||
str[len] = '\0';
|
|
||||||
|
|
||||||
|
str = text_to_cstring(t);
|
||||||
qstr = quote_identifier(str);
|
qstr = quote_identifier(str);
|
||||||
|
PG_RETURN_TEXT_P(cstring_to_text(qstr));
|
||||||
len = strlen(qstr);
|
|
||||||
result = (text *) palloc(len + VARHDRSZ);
|
|
||||||
SET_VARSIZE(result, len + VARHDRSZ);
|
|
||||||
memcpy(VARDATA(result), qstr, len);
|
|
||||||
|
|
||||||
PG_RETURN_TEXT_P(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -106,8 +93,7 @@ Datum
|
|||||||
quote_nullable(PG_FUNCTION_ARGS)
|
quote_nullable(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
if (PG_ARGISNULL(0))
|
if (PG_ARGISNULL(0))
|
||||||
PG_RETURN_DATUM(DirectFunctionCall1(textin,
|
PG_RETURN_TEXT_P(cstring_to_text("NULL"));
|
||||||
CStringGetDatum("NULL")));
|
|
||||||
else
|
else
|
||||||
PG_RETURN_DATUM(DirectFunctionCall1(quote_literal,
|
PG_RETURN_DATUM(DirectFunctionCall1(quote_literal,
|
||||||
PG_GETARG_DATUM(0)));
|
PG_GETARG_DATUM(0)));
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.269 2008/01/06 01:03:16 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.270 2008/03/25 22:42:44 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -697,8 +697,7 @@ pg_get_indexdef_worker(Oid indexrelid, int colno, bool showTblSpc,
|
|||||||
exprsDatum = SysCacheGetAttr(INDEXRELID, ht_idx,
|
exprsDatum = SysCacheGetAttr(INDEXRELID, ht_idx,
|
||||||
Anum_pg_index_indexprs, &isnull);
|
Anum_pg_index_indexprs, &isnull);
|
||||||
Assert(!isnull);
|
Assert(!isnull);
|
||||||
exprsString = DatumGetCString(DirectFunctionCall1(textout,
|
exprsString = TextDatumGetCString(exprsDatum);
|
||||||
exprsDatum));
|
|
||||||
indexprs = (List *) stringToNode(exprsString);
|
indexprs = (List *) stringToNode(exprsString);
|
||||||
pfree(exprsString);
|
pfree(exprsString);
|
||||||
}
|
}
|
||||||
@ -836,8 +835,7 @@ pg_get_indexdef_worker(Oid indexrelid, int colno, bool showTblSpc,
|
|||||||
predDatum = SysCacheGetAttr(INDEXRELID, ht_idx,
|
predDatum = SysCacheGetAttr(INDEXRELID, ht_idx,
|
||||||
Anum_pg_index_indpred, &isnull);
|
Anum_pg_index_indpred, &isnull);
|
||||||
Assert(!isnull);
|
Assert(!isnull);
|
||||||
predString = DatumGetCString(DirectFunctionCall1(textout,
|
predString = TextDatumGetCString(predDatum);
|
||||||
predDatum));
|
|
||||||
node = (Node *) stringToNode(predString);
|
node = (Node *) stringToNode(predString);
|
||||||
pfree(predString);
|
pfree(predString);
|
||||||
|
|
||||||
@ -1092,7 +1090,7 @@ pg_get_constraintdef_worker(Oid constraintId, bool fullCommand,
|
|||||||
elog(ERROR, "null conbin for constraint %u",
|
elog(ERROR, "null conbin for constraint %u",
|
||||||
constraintId);
|
constraintId);
|
||||||
|
|
||||||
conbin = DatumGetCString(DirectFunctionCall1(textout, val));
|
conbin = TextDatumGetCString(val);
|
||||||
expr = stringToNode(conbin);
|
expr = stringToNode(conbin);
|
||||||
|
|
||||||
/* Set up deparsing context for Var nodes in constraint */
|
/* Set up deparsing context for Var nodes in constraint */
|
||||||
@ -1222,8 +1220,7 @@ pg_get_expr_worker(text *expr, Oid relid, char *relname, int prettyFlags)
|
|||||||
char *str;
|
char *str;
|
||||||
|
|
||||||
/* Convert input TEXT object to C string */
|
/* Convert input TEXT object to C string */
|
||||||
exprstr = DatumGetCString(DirectFunctionCall1(textout,
|
exprstr = text_to_cstring(expr);
|
||||||
PointerGetDatum(expr)));
|
|
||||||
|
|
||||||
/* Convert expression to node tree */
|
/* Convert expression to node tree */
|
||||||
node = (Node *) stringToNode(exprstr);
|
node = (Node *) stringToNode(exprstr);
|
||||||
@ -1233,6 +1230,8 @@ pg_get_expr_worker(text *expr, Oid relid, char *relname, int prettyFlags)
|
|||||||
str = deparse_expression_pretty(node, context, false, false,
|
str = deparse_expression_pretty(node, context, false, false,
|
||||||
prettyFlags, 0);
|
prettyFlags, 0);
|
||||||
|
|
||||||
|
pfree(exprstr);
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1286,7 +1285,7 @@ Datum
|
|||||||
pg_get_serial_sequence(PG_FUNCTION_ARGS)
|
pg_get_serial_sequence(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
text *tablename = PG_GETARG_TEXT_P(0);
|
text *tablename = PG_GETARG_TEXT_P(0);
|
||||||
text *columnname = PG_GETARG_TEXT_P(1);
|
text *columnname = PG_GETARG_TEXT_PP(1);
|
||||||
RangeVar *tablerv;
|
RangeVar *tablerv;
|
||||||
Oid tableOid;
|
Oid tableOid;
|
||||||
char *column;
|
char *column;
|
||||||
@ -1302,8 +1301,7 @@ pg_get_serial_sequence(PG_FUNCTION_ARGS)
|
|||||||
tableOid = RangeVarGetRelid(tablerv, false);
|
tableOid = RangeVarGetRelid(tablerv, false);
|
||||||
|
|
||||||
/* Get the number of the column */
|
/* Get the number of the column */
|
||||||
column = DatumGetCString(DirectFunctionCall1(textout,
|
column = text_to_cstring(columnname);
|
||||||
PointerGetDatum(columnname)));
|
|
||||||
|
|
||||||
attnum = get_attnum(tableOid, column);
|
attnum = get_attnum(tableOid, column);
|
||||||
if (attnum == InvalidAttrNumber)
|
if (attnum == InvalidAttrNumber)
|
||||||
@ -5439,16 +5437,9 @@ static text *
|
|||||||
string_to_text(char *str)
|
string_to_text(char *str)
|
||||||
{
|
{
|
||||||
text *result;
|
text *result;
|
||||||
int slen = strlen(str);
|
|
||||||
int tlen;
|
|
||||||
|
|
||||||
tlen = slen + VARHDRSZ;
|
|
||||||
result = (text *) palloc(tlen);
|
|
||||||
SET_VARSIZE(result, tlen);
|
|
||||||
memcpy(VARDATA(result), str, slen);
|
|
||||||
|
|
||||||
|
result = cstring_to_text(str);
|
||||||
pfree(str);
|
pfree(str);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5482,9 +5473,9 @@ flatten_reloptions(Oid relid)
|
|||||||
* array_to_text() relies on flinfo to be valid. So use
|
* array_to_text() relies on flinfo to be valid. So use
|
||||||
* OidFunctionCall2.
|
* OidFunctionCall2.
|
||||||
*/
|
*/
|
||||||
sep = DirectFunctionCall1(textin, CStringGetDatum(", "));
|
sep = CStringGetTextDatum(", ");
|
||||||
txt = OidFunctionCall2(F_ARRAY_TO_TEXT, reloptions, sep);
|
txt = OidFunctionCall2(F_ARRAY_TO_TEXT, reloptions, sep);
|
||||||
result = DatumGetCString(DirectFunctionCall1(textout, txt));
|
result = TextDatumGetCString(txt);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReleaseSysCache(tuple);
|
ReleaseSysCache(tuple);
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.246 2008/03/17 17:13:54 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.247 2008/03/25 22:42:44 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -1089,8 +1089,7 @@ patternsel(PG_FUNCTION_ARGS, Pattern_Type ptype, bool negate)
|
|||||||
switch (prefix->consttype)
|
switch (prefix->consttype)
|
||||||
{
|
{
|
||||||
case TEXTOID:
|
case TEXTOID:
|
||||||
prefixstr = DatumGetCString(DirectFunctionCall1(textout,
|
prefixstr = TextDatumGetCString(prefix->constvalue);
|
||||||
prefix->constvalue));
|
|
||||||
break;
|
break;
|
||||||
case BYTEAOID:
|
case BYTEAOID:
|
||||||
prefixstr = DatumGetCString(DirectFunctionCall1(byteaout,
|
prefixstr = DatumGetCString(DirectFunctionCall1(byteaout,
|
||||||
@ -3339,15 +3338,8 @@ convert_string_datum(Datum value, Oid typid)
|
|||||||
case BPCHAROID:
|
case BPCHAROID:
|
||||||
case VARCHAROID:
|
case VARCHAROID:
|
||||||
case TEXTOID:
|
case TEXTOID:
|
||||||
{
|
val = TextDatumGetCString(value);
|
||||||
char *str = (char *) VARDATA(DatumGetPointer(value));
|
break;
|
||||||
int strlength = VARSIZE(DatumGetPointer(value)) - VARHDRSZ;
|
|
||||||
|
|
||||||
val = (char *) palloc(strlength + 1);
|
|
||||||
memcpy(val, str, strlength);
|
|
||||||
val[strlength] = '\0';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case NAMEOID:
|
case NAMEOID:
|
||||||
{
|
{
|
||||||
NameData *nm = (NameData *) DatumGetPointer(value);
|
NameData *nm = (NameData *) DatumGetPointer(value);
|
||||||
@ -4177,7 +4169,7 @@ like_fixed_prefix(Const *patt_const, bool case_insensitive,
|
|||||||
|
|
||||||
if (typeid != BYTEAOID)
|
if (typeid != BYTEAOID)
|
||||||
{
|
{
|
||||||
patt = DatumGetCString(DirectFunctionCall1(textout, patt_const->constvalue));
|
patt = TextDatumGetCString(patt_const->constvalue);
|
||||||
pattlen = strlen(patt);
|
pattlen = strlen(patt);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -4282,7 +4274,7 @@ regex_fixed_prefix(Const *patt_const, bool case_insensitive,
|
|||||||
errmsg("regular-expression matching not supported on type bytea")));
|
errmsg("regular-expression matching not supported on type bytea")));
|
||||||
|
|
||||||
/* the right-hand const is type text for all of these */
|
/* the right-hand const is type text for all of these */
|
||||||
patt = DatumGetCString(DirectFunctionCall1(textout, patt_const->constvalue));
|
patt = TextDatumGetCString(patt_const->constvalue);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check for ARE director prefix. It's worth our trouble to recognize
|
* Check for ARE director prefix. It's worth our trouble to recognize
|
||||||
@ -4618,7 +4610,7 @@ like_selectivity(Const *patt_const, bool case_insensitive)
|
|||||||
|
|
||||||
if (typeid != BYTEAOID)
|
if (typeid != BYTEAOID)
|
||||||
{
|
{
|
||||||
patt = DatumGetCString(DirectFunctionCall1(textout, patt_const->constvalue));
|
patt = TextDatumGetCString(patt_const->constvalue);
|
||||||
pattlen = strlen(patt);
|
pattlen = strlen(patt);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -4777,7 +4769,7 @@ regex_selectivity(Const *patt_const, bool case_insensitive)
|
|||||||
errmsg("regular-expression matching not supported on type bytea")));
|
errmsg("regular-expression matching not supported on type bytea")));
|
||||||
|
|
||||||
/* the right-hand const is type text for all of these */
|
/* the right-hand const is type text for all of these */
|
||||||
patt = DatumGetCString(DirectFunctionCall1(textout, patt_const->constvalue));
|
patt = TextDatumGetCString(patt_const->constvalue);
|
||||||
pattlen = strlen(patt);
|
pattlen = strlen(patt);
|
||||||
|
|
||||||
/* If patt doesn't end with $, consider it to have a trailing wildcard */
|
/* If patt doesn't end with $, consider it to have a trailing wildcard */
|
||||||
@ -4892,8 +4884,7 @@ make_greater_string(const Const *str_const, FmgrInfo *ltproc)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
workstr = DatumGetCString(DirectFunctionCall1(textout,
|
workstr = TextDatumGetCString(str_const->constvalue);
|
||||||
str_const->constvalue));
|
|
||||||
len = strlen(workstr);
|
len = strlen(workstr);
|
||||||
if (lc_collate_is_c() || len == 0)
|
if (lc_collate_is_c() || len == 0)
|
||||||
cmpstr = str_const->constvalue;
|
cmpstr = str_const->constvalue;
|
||||||
@ -5000,15 +4991,15 @@ string_to_datum(const char *str, Oid datatype)
|
|||||||
Assert(str != NULL);
|
Assert(str != NULL);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We cheat a little by assuming that textin() will do for bpchar and
|
* We cheat a little by assuming that CStringGetTextDatum() will do for
|
||||||
* varchar constants too...
|
* bpchar and varchar constants too...
|
||||||
*/
|
*/
|
||||||
if (datatype == NAMEOID)
|
if (datatype == NAMEOID)
|
||||||
return DirectFunctionCall1(namein, CStringGetDatum(str));
|
return DirectFunctionCall1(namein, CStringGetDatum(str));
|
||||||
else if (datatype == BYTEAOID)
|
else if (datatype == BYTEAOID)
|
||||||
return DirectFunctionCall1(byteain, CStringGetDatum(str));
|
return DirectFunctionCall1(byteain, CStringGetDatum(str));
|
||||||
else
|
else
|
||||||
return DirectFunctionCall1(textin, CStringGetDatum(str));
|
return CStringGetTextDatum(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.186 2008/03/21 01:31:42 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.187 2008/03/25 22:42:44 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -3242,7 +3242,7 @@ timestamptz_age(PG_FUNCTION_ARGS)
|
|||||||
Datum
|
Datum
|
||||||
timestamp_trunc(PG_FUNCTION_ARGS)
|
timestamp_trunc(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
text *units = PG_GETARG_TEXT_P(0);
|
text *units = PG_GETARG_TEXT_PP(0);
|
||||||
Timestamp timestamp = PG_GETARG_TIMESTAMP(1);
|
Timestamp timestamp = PG_GETARG_TIMESTAMP(1);
|
||||||
Timestamp result;
|
Timestamp result;
|
||||||
int type,
|
int type,
|
||||||
@ -3255,8 +3255,8 @@ timestamp_trunc(PG_FUNCTION_ARGS)
|
|||||||
if (TIMESTAMP_NOT_FINITE(timestamp))
|
if (TIMESTAMP_NOT_FINITE(timestamp))
|
||||||
PG_RETURN_TIMESTAMP(timestamp);
|
PG_RETURN_TIMESTAMP(timestamp);
|
||||||
|
|
||||||
lowunits = downcase_truncate_identifier(VARDATA(units),
|
lowunits = downcase_truncate_identifier(VARDATA_ANY(units),
|
||||||
VARSIZE(units) - VARHDRSZ,
|
VARSIZE_ANY_EXHDR(units),
|
||||||
false);
|
false);
|
||||||
|
|
||||||
type = DecodeUnits(0, lowunits, &val);
|
type = DecodeUnits(0, lowunits, &val);
|
||||||
@ -3374,7 +3374,7 @@ timestamp_trunc(PG_FUNCTION_ARGS)
|
|||||||
Datum
|
Datum
|
||||||
timestamptz_trunc(PG_FUNCTION_ARGS)
|
timestamptz_trunc(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
text *units = PG_GETARG_TEXT_P(0);
|
text *units = PG_GETARG_TEXT_PP(0);
|
||||||
TimestampTz timestamp = PG_GETARG_TIMESTAMPTZ(1);
|
TimestampTz timestamp = PG_GETARG_TIMESTAMPTZ(1);
|
||||||
TimestampTz result;
|
TimestampTz result;
|
||||||
int tz;
|
int tz;
|
||||||
@ -3390,8 +3390,8 @@ timestamptz_trunc(PG_FUNCTION_ARGS)
|
|||||||
if (TIMESTAMP_NOT_FINITE(timestamp))
|
if (TIMESTAMP_NOT_FINITE(timestamp))
|
||||||
PG_RETURN_TIMESTAMPTZ(timestamp);
|
PG_RETURN_TIMESTAMPTZ(timestamp);
|
||||||
|
|
||||||
lowunits = downcase_truncate_identifier(VARDATA(units),
|
lowunits = downcase_truncate_identifier(VARDATA_ANY(units),
|
||||||
VARSIZE(units) - VARHDRSZ,
|
VARSIZE_ANY_EXHDR(units),
|
||||||
false);
|
false);
|
||||||
|
|
||||||
type = DecodeUnits(0, lowunits, &val);
|
type = DecodeUnits(0, lowunits, &val);
|
||||||
@ -3532,7 +3532,7 @@ timestamptz_trunc(PG_FUNCTION_ARGS)
|
|||||||
Datum
|
Datum
|
||||||
interval_trunc(PG_FUNCTION_ARGS)
|
interval_trunc(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
text *units = PG_GETARG_TEXT_P(0);
|
text *units = PG_GETARG_TEXT_PP(0);
|
||||||
Interval *interval = PG_GETARG_INTERVAL_P(1);
|
Interval *interval = PG_GETARG_INTERVAL_P(1);
|
||||||
Interval *result;
|
Interval *result;
|
||||||
int type,
|
int type,
|
||||||
@ -3544,8 +3544,8 @@ interval_trunc(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
result = (Interval *) palloc(sizeof(Interval));
|
result = (Interval *) palloc(sizeof(Interval));
|
||||||
|
|
||||||
lowunits = downcase_truncate_identifier(VARDATA(units),
|
lowunits = downcase_truncate_identifier(VARDATA_ANY(units),
|
||||||
VARSIZE(units) - VARHDRSZ,
|
VARSIZE_ANY_EXHDR(units),
|
||||||
false);
|
false);
|
||||||
|
|
||||||
type = DecodeUnits(0, lowunits, &val);
|
type = DecodeUnits(0, lowunits, &val);
|
||||||
@ -3615,9 +3615,7 @@ interval_trunc(PG_FUNCTION_ARGS)
|
|||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||||
errmsg("interval units \"%s\" not recognized",
|
errmsg("interval units \"%s\" not recognized",
|
||||||
DatumGetCString(DirectFunctionCall1(textout,
|
lowunits)));
|
||||||
PointerGetDatum(units))))));
|
|
||||||
*result = *interval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PG_RETURN_INTERVAL_P(result);
|
PG_RETURN_INTERVAL_P(result);
|
||||||
@ -3803,7 +3801,7 @@ date2isoyearday(int year, int mon, int mday)
|
|||||||
Datum
|
Datum
|
||||||
timestamp_part(PG_FUNCTION_ARGS)
|
timestamp_part(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
text *units = PG_GETARG_TEXT_P(0);
|
text *units = PG_GETARG_TEXT_PP(0);
|
||||||
Timestamp timestamp = PG_GETARG_TIMESTAMP(1);
|
Timestamp timestamp = PG_GETARG_TIMESTAMP(1);
|
||||||
float8 result;
|
float8 result;
|
||||||
int type,
|
int type,
|
||||||
@ -3819,8 +3817,8 @@ timestamp_part(PG_FUNCTION_ARGS)
|
|||||||
PG_RETURN_FLOAT8(result);
|
PG_RETURN_FLOAT8(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
lowunits = downcase_truncate_identifier(VARDATA(units),
|
lowunits = downcase_truncate_identifier(VARDATA_ANY(units),
|
||||||
VARSIZE(units) - VARHDRSZ,
|
VARSIZE_ANY_EXHDR(units),
|
||||||
false);
|
false);
|
||||||
|
|
||||||
type = DecodeUnits(0, lowunits, &val);
|
type = DecodeUnits(0, lowunits, &val);
|
||||||
@ -4031,7 +4029,7 @@ timestamp_part(PG_FUNCTION_ARGS)
|
|||||||
Datum
|
Datum
|
||||||
timestamptz_part(PG_FUNCTION_ARGS)
|
timestamptz_part(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
text *units = PG_GETARG_TEXT_P(0);
|
text *units = PG_GETARG_TEXT_PP(0);
|
||||||
TimestampTz timestamp = PG_GETARG_TIMESTAMPTZ(1);
|
TimestampTz timestamp = PG_GETARG_TIMESTAMPTZ(1);
|
||||||
float8 result;
|
float8 result;
|
||||||
int tz;
|
int tz;
|
||||||
@ -4050,8 +4048,8 @@ timestamptz_part(PG_FUNCTION_ARGS)
|
|||||||
PG_RETURN_FLOAT8(result);
|
PG_RETURN_FLOAT8(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
lowunits = downcase_truncate_identifier(VARDATA(units),
|
lowunits = downcase_truncate_identifier(VARDATA_ANY(units),
|
||||||
VARSIZE(units) - VARHDRSZ,
|
VARSIZE_ANY_EXHDR(units),
|
||||||
false);
|
false);
|
||||||
|
|
||||||
type = DecodeUnits(0, lowunits, &val);
|
type = DecodeUnits(0, lowunits, &val);
|
||||||
@ -4246,7 +4244,7 @@ timestamptz_part(PG_FUNCTION_ARGS)
|
|||||||
Datum
|
Datum
|
||||||
interval_part(PG_FUNCTION_ARGS)
|
interval_part(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
text *units = PG_GETARG_TEXT_P(0);
|
text *units = PG_GETARG_TEXT_PP(0);
|
||||||
Interval *interval = PG_GETARG_INTERVAL_P(1);
|
Interval *interval = PG_GETARG_INTERVAL_P(1);
|
||||||
float8 result;
|
float8 result;
|
||||||
int type,
|
int type,
|
||||||
@ -4256,8 +4254,8 @@ interval_part(PG_FUNCTION_ARGS)
|
|||||||
struct pg_tm tt,
|
struct pg_tm tt,
|
||||||
*tm = &tt;
|
*tm = &tt;
|
||||||
|
|
||||||
lowunits = downcase_truncate_identifier(VARDATA(units),
|
lowunits = downcase_truncate_identifier(VARDATA_ANY(units),
|
||||||
VARSIZE(units) - VARHDRSZ,
|
VARSIZE_ANY_EXHDR(units),
|
||||||
false);
|
false);
|
||||||
|
|
||||||
type = DecodeUnits(0, lowunits, &val);
|
type = DecodeUnits(0, lowunits, &val);
|
||||||
@ -4337,8 +4335,7 @@ interval_part(PG_FUNCTION_ARGS)
|
|||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||||
errmsg("interval units \"%s\" not supported",
|
errmsg("interval units \"%s\" not supported",
|
||||||
DatumGetCString(DirectFunctionCall1(textout,
|
lowunits)));
|
||||||
PointerGetDatum(units))))));
|
|
||||||
result = 0;
|
result = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4365,8 +4362,7 @@ interval_part(PG_FUNCTION_ARGS)
|
|||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||||
errmsg("interval units \"%s\" not recognized",
|
errmsg("interval units \"%s\" not recognized",
|
||||||
DatumGetCString(DirectFunctionCall1(textout,
|
lowunits)));
|
||||||
PointerGetDatum(units))))));
|
|
||||||
result = 0;
|
result = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4385,13 +4381,12 @@ interval_part(PG_FUNCTION_ARGS)
|
|||||||
Datum
|
Datum
|
||||||
timestamp_zone(PG_FUNCTION_ARGS)
|
timestamp_zone(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
text *zone = PG_GETARG_TEXT_P(0);
|
text *zone = PG_GETARG_TEXT_PP(0);
|
||||||
Timestamp timestamp = PG_GETARG_TIMESTAMP(1);
|
Timestamp timestamp = PG_GETARG_TIMESTAMP(1);
|
||||||
TimestampTz result;
|
TimestampTz result;
|
||||||
int tz;
|
int tz;
|
||||||
pg_tz *tzp;
|
pg_tz *tzp;
|
||||||
char tzname[TZ_STRLEN_MAX + 1];
|
char tzname[TZ_STRLEN_MAX + 1];
|
||||||
int len;
|
|
||||||
|
|
||||||
if (TIMESTAMP_NOT_FINITE(timestamp))
|
if (TIMESTAMP_NOT_FINITE(timestamp))
|
||||||
PG_RETURN_TIMESTAMPTZ(timestamp);
|
PG_RETURN_TIMESTAMPTZ(timestamp);
|
||||||
@ -4401,9 +4396,7 @@ timestamp_zone(PG_FUNCTION_ARGS)
|
|||||||
* (to handle cases like "America/New_York"), and if that fails, we look
|
* (to handle cases like "America/New_York"), and if that fails, we look
|
||||||
* in the date token table (to handle cases like "EST").
|
* in the date token table (to handle cases like "EST").
|
||||||
*/
|
*/
|
||||||
len = Min(VARSIZE(zone) - VARHDRSZ, TZ_STRLEN_MAX);
|
text_to_cstring_buffer(zone, tzname, sizeof(tzname));
|
||||||
memcpy(tzname, VARDATA(zone), len);
|
|
||||||
tzname[len] = '\0';
|
|
||||||
tzp = pg_tzset(tzname);
|
tzp = pg_tzset(tzname);
|
||||||
if (tzp)
|
if (tzp)
|
||||||
{
|
{
|
||||||
@ -4428,8 +4421,8 @@ timestamp_zone(PG_FUNCTION_ARGS)
|
|||||||
int type,
|
int type,
|
||||||
val;
|
val;
|
||||||
|
|
||||||
lowzone = downcase_truncate_identifier(VARDATA(zone),
|
lowzone = downcase_truncate_identifier(tzname,
|
||||||
VARSIZE(zone) - VARHDRSZ,
|
strlen(tzname),
|
||||||
false);
|
false);
|
||||||
type = DecodeSpecial(0, lowzone, &val);
|
type = DecodeSpecial(0, lowzone, &val);
|
||||||
|
|
||||||
@ -4558,13 +4551,12 @@ timestamptz_timestamp(PG_FUNCTION_ARGS)
|
|||||||
Datum
|
Datum
|
||||||
timestamptz_zone(PG_FUNCTION_ARGS)
|
timestamptz_zone(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
text *zone = PG_GETARG_TEXT_P(0);
|
text *zone = PG_GETARG_TEXT_PP(0);
|
||||||
TimestampTz timestamp = PG_GETARG_TIMESTAMPTZ(1);
|
TimestampTz timestamp = PG_GETARG_TIMESTAMPTZ(1);
|
||||||
Timestamp result;
|
Timestamp result;
|
||||||
int tz;
|
int tz;
|
||||||
pg_tz *tzp;
|
pg_tz *tzp;
|
||||||
char tzname[TZ_STRLEN_MAX + 1];
|
char tzname[TZ_STRLEN_MAX + 1];
|
||||||
int len;
|
|
||||||
|
|
||||||
if (TIMESTAMP_NOT_FINITE(timestamp))
|
if (TIMESTAMP_NOT_FINITE(timestamp))
|
||||||
PG_RETURN_TIMESTAMP(timestamp);
|
PG_RETURN_TIMESTAMP(timestamp);
|
||||||
@ -4574,9 +4566,7 @@ timestamptz_zone(PG_FUNCTION_ARGS)
|
|||||||
* (to handle cases like "America/New_York"), and if that fails, we look
|
* (to handle cases like "America/New_York"), and if that fails, we look
|
||||||
* in the date token table (to handle cases like "EST").
|
* in the date token table (to handle cases like "EST").
|
||||||
*/
|
*/
|
||||||
len = Min(VARSIZE(zone) - VARHDRSZ, TZ_STRLEN_MAX);
|
text_to_cstring_buffer(zone, tzname, sizeof(tzname));
|
||||||
memcpy(tzname, VARDATA(zone), len);
|
|
||||||
tzname[len] = '\0';
|
|
||||||
tzp = pg_tzset(tzname);
|
tzp = pg_tzset(tzname);
|
||||||
if (tzp)
|
if (tzp)
|
||||||
{
|
{
|
||||||
@ -4600,8 +4590,8 @@ timestamptz_zone(PG_FUNCTION_ARGS)
|
|||||||
int type,
|
int type,
|
||||||
val;
|
val;
|
||||||
|
|
||||||
lowzone = downcase_truncate_identifier(VARDATA(zone),
|
lowzone = downcase_truncate_identifier(tzname,
|
||||||
VARSIZE(zone) - VARHDRSZ,
|
strlen(tzname),
|
||||||
false);
|
false);
|
||||||
type = DecodeSpecial(0, lowzone, &val);
|
type = DecodeSpecial(0, lowzone, &val);
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/adt/tsginidx.c,v 1.9 2008/01/01 19:45:52 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/adt/tsginidx.c,v 1.10 2008/03/25 22:42:44 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -16,6 +16,7 @@
|
|||||||
#include "access/skey.h"
|
#include "access/skey.h"
|
||||||
#include "tsearch/ts_type.h"
|
#include "tsearch/ts_type.h"
|
||||||
#include "tsearch/ts_utils.h"
|
#include "tsearch/ts_utils.h"
|
||||||
|
#include "utils/builtins.h"
|
||||||
|
|
||||||
|
|
||||||
Datum
|
Datum
|
||||||
@ -35,11 +36,9 @@ gin_extract_tsvector(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
for (i = 0; i < vector->size; i++)
|
for (i = 0; i < vector->size; i++)
|
||||||
{
|
{
|
||||||
text *txt = (text *) palloc(VARHDRSZ + we->len);
|
text *txt;
|
||||||
|
|
||||||
SET_VARSIZE(txt, VARHDRSZ + we->len);
|
|
||||||
memcpy(VARDATA(txt), STRPTR(vector) + we->pos, we->len);
|
|
||||||
|
|
||||||
|
txt = cstring_to_text_with_len(STRPTR(vector) + we->pos, we->len);
|
||||||
entries[i] = PointerGetDatum(txt);
|
entries[i] = PointerGetDatum(txt);
|
||||||
|
|
||||||
we++;
|
we++;
|
||||||
@ -87,11 +86,8 @@ gin_extract_tsquery(PG_FUNCTION_ARGS)
|
|||||||
text *txt;
|
text *txt;
|
||||||
QueryOperand *val = &item[i].operand;
|
QueryOperand *val = &item[i].operand;
|
||||||
|
|
||||||
txt = (text *) palloc(VARHDRSZ + val->length);
|
txt = cstring_to_text_with_len(GETOPERAND(query) + val->distance,
|
||||||
|
val->length);
|
||||||
SET_VARSIZE(txt, VARHDRSZ + val->length);
|
|
||||||
memcpy(VARDATA(txt), GETOPERAND(query) + val->distance, val->length);
|
|
||||||
|
|
||||||
entries[j++] = PointerGetDatum(txt);
|
entries[j++] = PointerGetDatum(txt);
|
||||||
|
|
||||||
if (strategy != TSearchWithClassStrategyNumber && val->weight != 0)
|
if (strategy != TSearchWithClassStrategyNumber && val->weight != 0)
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/adt/tsquery.c,v 1.15 2008/01/08 01:04:08 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/adt/tsquery.c,v 1.16 2008/03/25 22:42:44 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -19,6 +19,7 @@
|
|||||||
#include "tsearch/ts_locale.h"
|
#include "tsearch/ts_locale.h"
|
||||||
#include "tsearch/ts_type.h"
|
#include "tsearch/ts_type.h"
|
||||||
#include "tsearch/ts_utils.h"
|
#include "tsearch/ts_utils.h"
|
||||||
|
#include "utils/builtins.h"
|
||||||
#include "utils/memutils.h"
|
#include "utils/memutils.h"
|
||||||
#include "utils/pg_crc.h"
|
#include "utils/pg_crc.h"
|
||||||
|
|
||||||
@ -954,9 +955,7 @@ tsquerytree(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
if (!q)
|
if (!q)
|
||||||
{
|
{
|
||||||
res = (text *) palloc(1 + VARHDRSZ);
|
res = cstring_to_text("T");
|
||||||
SET_VARSIZE(res, 1 + VARHDRSZ);
|
|
||||||
*((char *) VARDATA(res)) = 'T';
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -966,14 +965,11 @@ tsquerytree(PG_FUNCTION_ARGS)
|
|||||||
*(nrm.cur) = '\0';
|
*(nrm.cur) = '\0';
|
||||||
nrm.op = GETOPERAND(query);
|
nrm.op = GETOPERAND(query);
|
||||||
infix(&nrm, true);
|
infix(&nrm, true);
|
||||||
|
res = cstring_to_text_with_len(nrm.buf, nrm.cur - nrm.buf);
|
||||||
res = (text *) palloc(nrm.cur - nrm.buf + VARHDRSZ);
|
|
||||||
SET_VARSIZE(res, nrm.cur - nrm.buf + VARHDRSZ);
|
|
||||||
strncpy(VARDATA(res), nrm.buf, nrm.cur - nrm.buf);
|
|
||||||
pfree(q);
|
pfree(q);
|
||||||
}
|
}
|
||||||
|
|
||||||
PG_FREE_IF_COPY(query, 0);
|
PG_FREE_IF_COPY(query, 0);
|
||||||
|
|
||||||
PG_RETURN_POINTER(res);
|
PG_RETURN_TEXT_P(res);
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/adt/tsquery_rewrite.c,v 1.11 2008/01/01 19:45:53 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/adt/tsquery_rewrite.c,v 1.12 2008/03/25 22:42:44 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -273,7 +273,7 @@ tsquery_rewrite_query(PG_FUNCTION_ARGS)
|
|||||||
QTNTernary(tree);
|
QTNTernary(tree);
|
||||||
QTNSort(tree);
|
QTNSort(tree);
|
||||||
|
|
||||||
buf = TextPGetCString(in);
|
buf = text_to_cstring(in);
|
||||||
|
|
||||||
SPI_connect();
|
SPI_connect();
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/adt/tsvector_op.c,v 1.13 2008/03/05 15:50:37 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/adt/tsvector_op.c,v 1.14 2008/03/25 22:42:44 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -1082,7 +1082,7 @@ ts_process_call(FuncCallContext *funcctx)
|
|||||||
static tsstat *
|
static tsstat *
|
||||||
ts_stat_sql(text *txt, text *ws)
|
ts_stat_sql(text *txt, text *ws)
|
||||||
{
|
{
|
||||||
char *query = TextPGetCString(txt);
|
char *query = text_to_cstring(txt);
|
||||||
int i;
|
int i;
|
||||||
tsstat *newstat,
|
tsstat *newstat,
|
||||||
*stat;
|
*stat;
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/adt/varchar.c,v 1.126 2008/01/01 19:45:53 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/adt/varchar.c,v 1.127 2008/03/25 22:42:44 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -203,21 +203,16 @@ bpcharin(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Convert a CHARACTER value to a C string.
|
* Convert a CHARACTER value to a C string.
|
||||||
|
*
|
||||||
|
* Uses the text conversion functions, which is only appropriate if BpChar
|
||||||
|
* and text are equivalent types.
|
||||||
*/
|
*/
|
||||||
Datum
|
Datum
|
||||||
bpcharout(PG_FUNCTION_ARGS)
|
bpcharout(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
BpChar *s = PG_GETARG_BPCHAR_PP(0);
|
Datum txt = PG_GETARG_DATUM(0);
|
||||||
char *result;
|
|
||||||
int len;
|
|
||||||
|
|
||||||
/* copy and add null term */
|
PG_RETURN_CSTRING(TextDatumGetCString(txt));
|
||||||
len = VARSIZE_ANY_EXHDR(s);
|
|
||||||
result = (char *) palloc(len + 1);
|
|
||||||
memcpy(result, VARDATA_ANY(s), len);
|
|
||||||
result[len] = '\0';
|
|
||||||
|
|
||||||
PG_RETURN_CSTRING(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -403,19 +398,17 @@ bpchar_name(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
/* name_bpchar()
|
/* name_bpchar()
|
||||||
* Converts a NameData type to a bpchar type.
|
* Converts a NameData type to a bpchar type.
|
||||||
|
*
|
||||||
|
* Uses the text conversion functions, which is only appropriate if BpChar
|
||||||
|
* and text are equivalent types.
|
||||||
*/
|
*/
|
||||||
Datum
|
Datum
|
||||||
name_bpchar(PG_FUNCTION_ARGS)
|
name_bpchar(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
Name s = PG_GETARG_NAME(0);
|
Name s = PG_GETARG_NAME(0);
|
||||||
BpChar *result;
|
BpChar *result;
|
||||||
int len;
|
|
||||||
|
|
||||||
len = strlen(NameStr(*s));
|
|
||||||
result = (BpChar *) palloc(VARHDRSZ + len);
|
|
||||||
memcpy(VARDATA(result), NameStr(*s), len);
|
|
||||||
SET_VARSIZE(result, VARHDRSZ + len);
|
|
||||||
|
|
||||||
|
result = (BpChar *) cstring_to_text(NameStr(*s));
|
||||||
PG_RETURN_BPCHAR_P(result);
|
PG_RETURN_BPCHAR_P(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -454,6 +447,9 @@ bpchartypmodout(PG_FUNCTION_ARGS)
|
|||||||
*
|
*
|
||||||
* If the input string is too long, raise an error, unless the extra
|
* If the input string is too long, raise an error, unless the extra
|
||||||
* characters are spaces, in which case they're truncated. (per SQL)
|
* characters are spaces, in which case they're truncated. (per SQL)
|
||||||
|
*
|
||||||
|
* Uses the C string to text conversion function, which is only appropriate
|
||||||
|
* if VarChar and text are equivalent types.
|
||||||
*/
|
*/
|
||||||
static VarChar *
|
static VarChar *
|
||||||
varchar_input(const char *s, size_t len, int32 atttypmod)
|
varchar_input(const char *s, size_t len, int32 atttypmod)
|
||||||
@ -481,10 +477,7 @@ varchar_input(const char *s, size_t len, int32 atttypmod)
|
|||||||
len = mbmaxlen;
|
len = mbmaxlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = (VarChar *) palloc(len + VARHDRSZ);
|
result = (VarChar *) cstring_to_text_with_len(s, len);
|
||||||
SET_VARSIZE(result, len + VARHDRSZ);
|
|
||||||
memcpy(VARDATA(result), s, len);
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -510,21 +503,16 @@ varcharin(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Convert a VARCHAR value to a C string.
|
* Convert a VARCHAR value to a C string.
|
||||||
|
*
|
||||||
|
* Uses the text to C string conversion function, which is only appropriate
|
||||||
|
* if VarChar and text are equivalent types.
|
||||||
*/
|
*/
|
||||||
Datum
|
Datum
|
||||||
varcharout(PG_FUNCTION_ARGS)
|
varcharout(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
VarChar *s = PG_GETARG_VARCHAR_PP(0);
|
Datum txt = PG_GETARG_DATUM(0);
|
||||||
char *result;
|
|
||||||
int32 len;
|
|
||||||
|
|
||||||
/* copy and add null term */
|
PG_RETURN_CSTRING(TextDatumGetCString(txt));
|
||||||
len = VARSIZE_ANY_EXHDR(s);
|
|
||||||
result = palloc(len + 1);
|
|
||||||
memcpy(result, VARDATA_ANY(s), len);
|
|
||||||
result[len] = '\0';
|
|
||||||
|
|
||||||
PG_RETURN_CSTRING(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/adt/varlena.c,v 1.163 2008/03/13 18:31:56 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/adt/varlena.c,v 1.164 2008/03/25 22:42:44 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -48,15 +48,6 @@ typedef struct
|
|||||||
#define PG_GETARG_UNKNOWN_P_COPY(n) DatumGetUnknownPCopy(PG_GETARG_DATUM(n))
|
#define PG_GETARG_UNKNOWN_P_COPY(n) DatumGetUnknownPCopy(PG_GETARG_DATUM(n))
|
||||||
#define PG_RETURN_UNKNOWN_P(x) PG_RETURN_POINTER(x)
|
#define PG_RETURN_UNKNOWN_P(x) PG_RETURN_POINTER(x)
|
||||||
|
|
||||||
#define PG_TEXTARG_GET_STR(arg_) \
|
|
||||||
DatumGetCString(DirectFunctionCall1(textout, PG_GETARG_DATUM(arg_)))
|
|
||||||
#define PG_TEXT_GET_STR(textp_) \
|
|
||||||
DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(textp_)))
|
|
||||||
#define PG_STR_GET_TEXT(str_) \
|
|
||||||
DatumGetTextP(DirectFunctionCall1(textin, CStringGetDatum(str_)))
|
|
||||||
#define TEXTLEN(textp) \
|
|
||||||
text_length(PointerGetDatum(textp))
|
|
||||||
|
|
||||||
static int text_cmp(text *arg1, text *arg2);
|
static int text_cmp(text *arg1, text *arg2);
|
||||||
static int32 text_length(Datum str);
|
static int32 text_length(Datum str);
|
||||||
static int text_position(text *t1, text *t2);
|
static int text_position(text *t1, text *t2);
|
||||||
@ -67,10 +58,107 @@ static text *text_substring(Datum str,
|
|||||||
int32 start,
|
int32 start,
|
||||||
int32 length,
|
int32 length,
|
||||||
bool length_not_specified);
|
bool length_not_specified);
|
||||||
|
|
||||||
static void appendStringInfoText(StringInfo str, const text *t);
|
static void appendStringInfoText(StringInfo str, const text *t);
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************
|
||||||
|
* CONVERSION ROUTINES EXPORTED FOR USE BY C CODE *
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* cstring_to_text
|
||||||
|
*
|
||||||
|
* Create a text value from a null-terminated C string.
|
||||||
|
*
|
||||||
|
* The new text value is freshly palloc'd with a full-size VARHDR.
|
||||||
|
*/
|
||||||
|
text *
|
||||||
|
cstring_to_text(const char *s)
|
||||||
|
{
|
||||||
|
return cstring_to_text_with_len(s, strlen(s));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* cstring_to_text_with_len
|
||||||
|
*
|
||||||
|
* Same as cstring_to_text except the caller specifies the string length;
|
||||||
|
* the string need not be null_terminated.
|
||||||
|
*/
|
||||||
|
text *
|
||||||
|
cstring_to_text_with_len(const char *s, int len)
|
||||||
|
{
|
||||||
|
text *result = (text *) palloc(len + VARHDRSZ);
|
||||||
|
|
||||||
|
SET_VARSIZE(result, len + VARHDRSZ);
|
||||||
|
memcpy(VARDATA(result), s, len);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* text_to_cstring
|
||||||
|
*
|
||||||
|
* Create a palloc'd, null-terminated C string from a text value.
|
||||||
|
*
|
||||||
|
* We support being passed a compressed or toasted text value.
|
||||||
|
* This is a bit bogus since such values shouldn't really be referred to as
|
||||||
|
* "text *", but it seems useful for robustness. If we didn't handle that
|
||||||
|
* case here, we'd need another routine that did, anyway.
|
||||||
|
*/
|
||||||
|
char *
|
||||||
|
text_to_cstring(const text *t)
|
||||||
|
{
|
||||||
|
/* must cast away the const, unfortunately */
|
||||||
|
text *tunpacked = pg_detoast_datum_packed((struct varlena *) t);
|
||||||
|
int len = VARSIZE_ANY_EXHDR(tunpacked);
|
||||||
|
char *result;
|
||||||
|
|
||||||
|
result = (char *) palloc(len + 1);
|
||||||
|
memcpy(result, VARDATA_ANY(tunpacked), len);
|
||||||
|
result[len] = '\0';
|
||||||
|
|
||||||
|
if (tunpacked != t)
|
||||||
|
pfree(tunpacked);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* text_to_cstring_buffer
|
||||||
|
*
|
||||||
|
* Copy a text value into a caller-supplied buffer of size dst_len.
|
||||||
|
*
|
||||||
|
* The text string is truncated if necessary to fit. The result is
|
||||||
|
* guaranteed null-terminated (unless dst_len == 0).
|
||||||
|
*
|
||||||
|
* We support being passed a compressed or toasted text value.
|
||||||
|
* This is a bit bogus since such values shouldn't really be referred to as
|
||||||
|
* "text *", but it seems useful for robustness. If we didn't handle that
|
||||||
|
* case here, we'd need another routine that did, anyway.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
text_to_cstring_buffer(const text *src, char *dst, size_t dst_len)
|
||||||
|
{
|
||||||
|
/* must cast away the const, unfortunately */
|
||||||
|
text *srcunpacked = pg_detoast_datum_packed((struct varlena *) src);
|
||||||
|
size_t src_len = VARSIZE_ANY_EXHDR(srcunpacked);
|
||||||
|
|
||||||
|
if (dst_len > 0)
|
||||||
|
{
|
||||||
|
dst_len--;
|
||||||
|
if (dst_len >= src_len)
|
||||||
|
dst_len = src_len;
|
||||||
|
else /* ensure truncation is encoding-safe */
|
||||||
|
dst_len = pg_mbcliplen(VARDATA_ANY(srcunpacked), src_len, dst_len);
|
||||||
|
memcpy(dst, VARDATA_ANY(srcunpacked), dst_len);
|
||||||
|
dst[dst_len] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (srcunpacked != src)
|
||||||
|
pfree(srcunpacked);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* USER I/O ROUTINES *
|
* USER I/O ROUTINES *
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
@ -259,16 +347,8 @@ Datum
|
|||||||
textin(PG_FUNCTION_ARGS)
|
textin(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
char *inputText = PG_GETARG_CSTRING(0);
|
char *inputText = PG_GETARG_CSTRING(0);
|
||||||
text *result;
|
|
||||||
int len;
|
|
||||||
|
|
||||||
len = strlen(inputText);
|
PG_RETURN_TEXT_P(cstring_to_text(inputText));
|
||||||
result = (text *) palloc(len + VARHDRSZ);
|
|
||||||
SET_VARSIZE(result, len + VARHDRSZ);
|
|
||||||
|
|
||||||
memcpy(VARDATA(result), inputText, len);
|
|
||||||
|
|
||||||
PG_RETURN_TEXT_P(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -277,16 +357,9 @@ textin(PG_FUNCTION_ARGS)
|
|||||||
Datum
|
Datum
|
||||||
textout(PG_FUNCTION_ARGS)
|
textout(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
text *t = PG_GETARG_TEXT_PP(0);
|
Datum txt = PG_GETARG_DATUM(0);
|
||||||
int len;
|
|
||||||
char *result;
|
|
||||||
|
|
||||||
len = VARSIZE_ANY_EXHDR(t);
|
PG_RETURN_CSTRING(TextDatumGetCString(txt));
|
||||||
result = (char *) palloc(len + 1);
|
|
||||||
memcpy(result, VARDATA_ANY(t), len);
|
|
||||||
result[len] = '\0';
|
|
||||||
|
|
||||||
PG_RETURN_CSTRING(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -302,9 +375,7 @@ textrecv(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
str = pq_getmsgtext(buf, buf->len - buf->cursor, &nbytes);
|
str = pq_getmsgtext(buf, buf->len - buf->cursor, &nbytes);
|
||||||
|
|
||||||
result = (text *) palloc(nbytes + VARHDRSZ);
|
result = cstring_to_text_with_len(str, nbytes);
|
||||||
SET_VARSIZE(result, nbytes + VARHDRSZ);
|
|
||||||
memcpy(VARDATA(result), str, nbytes);
|
|
||||||
pfree(str);
|
pfree(str);
|
||||||
PG_RETURN_TEXT_P(result);
|
PG_RETURN_TEXT_P(result);
|
||||||
}
|
}
|
||||||
@ -600,7 +671,7 @@ text_substring(Datum str, int32 start, int32 length, bool length_not_specified)
|
|||||||
* string.
|
* string.
|
||||||
*/
|
*/
|
||||||
if (E < 1)
|
if (E < 1)
|
||||||
return PG_STR_GET_TEXT("");
|
return cstring_to_text("");
|
||||||
|
|
||||||
L1 = E - S1;
|
L1 = E - S1;
|
||||||
}
|
}
|
||||||
@ -664,7 +735,7 @@ text_substring(Datum str, int32 start, int32 length, bool length_not_specified)
|
|||||||
* string.
|
* string.
|
||||||
*/
|
*/
|
||||||
if (E < 1)
|
if (E < 1)
|
||||||
return PG_STR_GET_TEXT("");
|
return cstring_to_text("");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* if E is past the end of the string, the tuple toaster will
|
* if E is past the end of the string, the tuple toaster will
|
||||||
@ -693,7 +764,7 @@ text_substring(Datum str, int32 start, int32 length, bool length_not_specified)
|
|||||||
{
|
{
|
||||||
if (slice != (text *) DatumGetPointer(str))
|
if (slice != (text *) DatumGetPointer(str))
|
||||||
pfree(slice);
|
pfree(slice);
|
||||||
return PG_STR_GET_TEXT("");
|
return cstring_to_text("");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now we can get the actual length of the slice in MB characters */
|
/* Now we can get the actual length of the slice in MB characters */
|
||||||
@ -708,7 +779,7 @@ text_substring(Datum str, int32 start, int32 length, bool length_not_specified)
|
|||||||
{
|
{
|
||||||
if (slice != (text *) DatumGetPointer(str))
|
if (slice != (text *) DatumGetPointer(str))
|
||||||
pfree(slice);
|
pfree(slice);
|
||||||
return PG_STR_GET_TEXT("");
|
return cstring_to_text("");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1759,16 +1830,8 @@ Datum
|
|||||||
name_text(PG_FUNCTION_ARGS)
|
name_text(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
Name s = PG_GETARG_NAME(0);
|
Name s = PG_GETARG_NAME(0);
|
||||||
text *result;
|
|
||||||
int len;
|
|
||||||
|
|
||||||
len = strlen(NameStr(*s));
|
PG_RETURN_TEXT_P(cstring_to_text(NameStr(*s)));
|
||||||
|
|
||||||
result = palloc(VARHDRSZ + len);
|
|
||||||
SET_VARSIZE(result, VARHDRSZ + len);
|
|
||||||
memcpy(VARDATA(result), NameStr(*s), len);
|
|
||||||
|
|
||||||
PG_RETURN_TEXT_P(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1790,8 +1853,7 @@ textToQualifiedNameList(text *textval)
|
|||||||
|
|
||||||
/* Convert to C string (handles possible detoasting). */
|
/* Convert to C string (handles possible detoasting). */
|
||||||
/* Note we rely on being able to modify rawname below. */
|
/* Note we rely on being able to modify rawname below. */
|
||||||
rawname = DatumGetCString(DirectFunctionCall1(textout,
|
rawname = text_to_cstring(textval);
|
||||||
PointerGetDatum(textval)));
|
|
||||||
|
|
||||||
if (!SplitIdentifierString(rawname, '.', &namelist))
|
if (!SplitIdentifierString(rawname, '.', &namelist))
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
@ -2103,7 +2165,7 @@ byteacmp(PG_FUNCTION_ARGS)
|
|||||||
* appendStringInfoText
|
* appendStringInfoText
|
||||||
*
|
*
|
||||||
* Append a text to str.
|
* Append a text to str.
|
||||||
* Like appendStringInfoString(str, PG_TEXT_GET_STR(s)) but faster.
|
* Like appendStringInfoString(str, text_to_cstring(t)) but faster.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
appendStringInfoText(StringInfo str, const text *t)
|
appendStringInfoText(StringInfo str, const text *t)
|
||||||
@ -2191,7 +2253,7 @@ replace_text(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
text_position_cleanup(&state);
|
text_position_cleanup(&state);
|
||||||
|
|
||||||
ret_text = PG_STR_GET_TEXT(str.data);
|
ret_text = cstring_to_text_with_len(str.data, str.len);
|
||||||
pfree(str.data);
|
pfree(str.data);
|
||||||
|
|
||||||
PG_RETURN_TEXT_P(ret_text);
|
PG_RETURN_TEXT_P(ret_text);
|
||||||
@ -2458,7 +2520,7 @@ replace_text_regexp(text *src_text, void *regexp,
|
|||||||
appendBinaryStringInfo(&buf, start_ptr, chunk_len);
|
appendBinaryStringInfo(&buf, start_ptr, chunk_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret_text = PG_STR_GET_TEXT(buf.data);
|
ret_text = cstring_to_text_with_len(buf.data, buf.len);
|
||||||
pfree(buf.data);
|
pfree(buf.data);
|
||||||
pfree(data);
|
pfree(data);
|
||||||
|
|
||||||
@ -2503,7 +2565,7 @@ split_text(PG_FUNCTION_ARGS)
|
|||||||
if (inputstring_len < 1)
|
if (inputstring_len < 1)
|
||||||
{
|
{
|
||||||
text_position_cleanup(&state);
|
text_position_cleanup(&state);
|
||||||
PG_RETURN_TEXT_P(PG_STR_GET_TEXT(""));
|
PG_RETURN_TEXT_P(cstring_to_text(""));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* empty field separator */
|
/* empty field separator */
|
||||||
@ -2514,7 +2576,7 @@ split_text(PG_FUNCTION_ARGS)
|
|||||||
if (fldnum == 1)
|
if (fldnum == 1)
|
||||||
PG_RETURN_TEXT_P(inputstring);
|
PG_RETURN_TEXT_P(inputstring);
|
||||||
else
|
else
|
||||||
PG_RETURN_TEXT_P(PG_STR_GET_TEXT(""));
|
PG_RETURN_TEXT_P(cstring_to_text(""));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* identify bounds of first field */
|
/* identify bounds of first field */
|
||||||
@ -2529,7 +2591,7 @@ split_text(PG_FUNCTION_ARGS)
|
|||||||
if (fldnum == 1)
|
if (fldnum == 1)
|
||||||
PG_RETURN_TEXT_P(inputstring);
|
PG_RETURN_TEXT_P(inputstring);
|
||||||
else
|
else
|
||||||
PG_RETURN_TEXT_P(PG_STR_GET_TEXT(""));
|
PG_RETURN_TEXT_P(cstring_to_text(""));
|
||||||
}
|
}
|
||||||
|
|
||||||
while (end_posn > 0 && --fldnum > 0)
|
while (end_posn > 0 && --fldnum > 0)
|
||||||
@ -2551,7 +2613,7 @@ split_text(PG_FUNCTION_ARGS)
|
|||||||
-1,
|
-1,
|
||||||
true);
|
true);
|
||||||
else
|
else
|
||||||
result_text = PG_STR_GET_TEXT("");
|
result_text = cstring_to_text("");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -2636,9 +2698,7 @@ text_to_array(PG_FUNCTION_ARGS)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* must build a temp text datum to pass to accumArrayResult */
|
/* must build a temp text datum to pass to accumArrayResult */
|
||||||
result_text = (text *) palloc(VARHDRSZ + chunk_len);
|
result_text = cstring_to_text_with_len(start_ptr, chunk_len);
|
||||||
SET_VARSIZE(result_text, VARHDRSZ + chunk_len);
|
|
||||||
memcpy(VARDATA(result_text), start_ptr, chunk_len);
|
|
||||||
|
|
||||||
/* stash away this field */
|
/* stash away this field */
|
||||||
astate = accumArrayResult(astate,
|
astate = accumArrayResult(astate,
|
||||||
@ -2673,7 +2733,7 @@ Datum
|
|||||||
array_to_text(PG_FUNCTION_ARGS)
|
array_to_text(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
ArrayType *v = PG_GETARG_ARRAYTYPE_P(0);
|
ArrayType *v = PG_GETARG_ARRAYTYPE_P(0);
|
||||||
char *fldsep = PG_TEXTARG_GET_STR(1);
|
char *fldsep = text_to_cstring(PG_GETARG_TEXT_PP(1));
|
||||||
int nitems,
|
int nitems,
|
||||||
*dims,
|
*dims,
|
||||||
ndims;
|
ndims;
|
||||||
@ -2695,7 +2755,7 @@ array_to_text(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
/* if there are no elements, return an empty string */
|
/* if there are no elements, return an empty string */
|
||||||
if (nitems == 0)
|
if (nitems == 0)
|
||||||
PG_RETURN_TEXT_P(PG_STR_GET_TEXT(""));
|
PG_RETURN_TEXT_P(cstring_to_text(""));
|
||||||
|
|
||||||
element_type = ARR_ELEMTYPE(v);
|
element_type = ARR_ELEMTYPE(v);
|
||||||
initStringInfo(&buf);
|
initStringInfo(&buf);
|
||||||
@ -2773,7 +2833,7 @@ array_to_text(PG_FUNCTION_ARGS)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PG_RETURN_TEXT_P(PG_STR_GET_TEXT(buf.data));
|
PG_RETURN_TEXT_P(cstring_to_text_with_len(buf.data, buf.len));
|
||||||
}
|
}
|
||||||
|
|
||||||
#define HEXBASE 16
|
#define HEXBASE 16
|
||||||
@ -2785,7 +2845,6 @@ Datum
|
|||||||
to_hex32(PG_FUNCTION_ARGS)
|
to_hex32(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
uint32 value = (uint32) PG_GETARG_INT32(0);
|
uint32 value = (uint32) PG_GETARG_INT32(0);
|
||||||
text *result_text;
|
|
||||||
char *ptr;
|
char *ptr;
|
||||||
const char *digits = "0123456789abcdef";
|
const char *digits = "0123456789abcdef";
|
||||||
char buf[32]; /* bigger than needed, but reasonable */
|
char buf[32]; /* bigger than needed, but reasonable */
|
||||||
@ -2799,8 +2858,7 @@ to_hex32(PG_FUNCTION_ARGS)
|
|||||||
value /= HEXBASE;
|
value /= HEXBASE;
|
||||||
} while (ptr > buf && value);
|
} while (ptr > buf && value);
|
||||||
|
|
||||||
result_text = PG_STR_GET_TEXT(ptr);
|
PG_RETURN_TEXT_P(cstring_to_text(ptr));
|
||||||
PG_RETURN_TEXT_P(result_text);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2811,7 +2869,6 @@ Datum
|
|||||||
to_hex64(PG_FUNCTION_ARGS)
|
to_hex64(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
uint64 value = (uint64) PG_GETARG_INT64(0);
|
uint64 value = (uint64) PG_GETARG_INT64(0);
|
||||||
text *result_text;
|
|
||||||
char *ptr;
|
char *ptr;
|
||||||
const char *digits = "0123456789abcdef";
|
const char *digits = "0123456789abcdef";
|
||||||
char buf[32]; /* bigger than needed, but reasonable */
|
char buf[32]; /* bigger than needed, but reasonable */
|
||||||
@ -2825,8 +2882,7 @@ to_hex64(PG_FUNCTION_ARGS)
|
|||||||
value /= HEXBASE;
|
value /= HEXBASE;
|
||||||
} while (ptr > buf && value);
|
} while (ptr > buf && value);
|
||||||
|
|
||||||
result_text = PG_STR_GET_TEXT(ptr);
|
PG_RETURN_TEXT_P(cstring_to_text(ptr));
|
||||||
PG_RETURN_TEXT_P(result_text);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2842,7 +2898,6 @@ md5_text(PG_FUNCTION_ARGS)
|
|||||||
text *in_text = PG_GETARG_TEXT_PP(0);
|
text *in_text = PG_GETARG_TEXT_PP(0);
|
||||||
size_t len;
|
size_t len;
|
||||||
char hexsum[MD5_HASH_LEN + 1];
|
char hexsum[MD5_HASH_LEN + 1];
|
||||||
text *result_text;
|
|
||||||
|
|
||||||
/* Calculate the length of the buffer using varlena metadata */
|
/* Calculate the length of the buffer using varlena metadata */
|
||||||
len = VARSIZE_ANY_EXHDR(in_text);
|
len = VARSIZE_ANY_EXHDR(in_text);
|
||||||
@ -2854,8 +2909,7 @@ md5_text(PG_FUNCTION_ARGS)
|
|||||||
errmsg("out of memory")));
|
errmsg("out of memory")));
|
||||||
|
|
||||||
/* convert to text and return it */
|
/* convert to text and return it */
|
||||||
result_text = PG_STR_GET_TEXT(hexsum);
|
PG_RETURN_TEXT_P(cstring_to_text(hexsum));
|
||||||
PG_RETURN_TEXT_P(result_text);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2868,7 +2922,6 @@ md5_bytea(PG_FUNCTION_ARGS)
|
|||||||
bytea *in = PG_GETARG_BYTEA_PP(0);
|
bytea *in = PG_GETARG_BYTEA_PP(0);
|
||||||
size_t len;
|
size_t len;
|
||||||
char hexsum[MD5_HASH_LEN + 1];
|
char hexsum[MD5_HASH_LEN + 1];
|
||||||
text *result_text;
|
|
||||||
|
|
||||||
len = VARSIZE_ANY_EXHDR(in);
|
len = VARSIZE_ANY_EXHDR(in);
|
||||||
if (pg_md5_hash(VARDATA_ANY(in), len, hexsum) == false)
|
if (pg_md5_hash(VARDATA_ANY(in), len, hexsum) == false)
|
||||||
@ -2876,8 +2929,7 @@ md5_bytea(PG_FUNCTION_ARGS)
|
|||||||
(errcode(ERRCODE_OUT_OF_MEMORY),
|
(errcode(ERRCODE_OUT_OF_MEMORY),
|
||||||
errmsg("out of memory")));
|
errmsg("out of memory")));
|
||||||
|
|
||||||
result_text = PG_STR_GET_TEXT(hexsum);
|
PG_RETURN_TEXT_P(cstring_to_text(hexsum));
|
||||||
PG_RETURN_TEXT_P(result_text);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/adt/version.c,v 1.16 2008/01/01 19:45:53 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/adt/version.c,v 1.17 2008/03/25 22:42:44 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -20,11 +20,5 @@
|
|||||||
Datum
|
Datum
|
||||||
pgsql_version(PG_FUNCTION_ARGS)
|
pgsql_version(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
int n = strlen(PG_VERSION_STR);
|
PG_RETURN_TEXT_P(cstring_to_text(PG_VERSION_STR));
|
||||||
text *ret = (text *) palloc(n + VARHDRSZ);
|
|
||||||
|
|
||||||
SET_VARSIZE(ret, n + VARHDRSZ);
|
|
||||||
memcpy(VARDATA(ret), PG_VERSION_STR, n);
|
|
||||||
|
|
||||||
PG_RETURN_TEXT_P(ret);
|
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.70 2008/03/24 19:12:49 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.71 2008/03/25 22:42:44 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -141,10 +141,6 @@ static void SPI_sql_row_to_xmlelement(int rownum, StringInfo result,
|
|||||||
errhint("You need to rebuild PostgreSQL using --with-libxml.")))
|
errhint("You need to rebuild PostgreSQL using --with-libxml.")))
|
||||||
|
|
||||||
|
|
||||||
#define _textin(str) DirectFunctionCall1(textin, CStringGetDatum(str))
|
|
||||||
#define _textout(x) DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(x)))
|
|
||||||
|
|
||||||
|
|
||||||
/* from SQL/XML:2003 section 4.7 */
|
/* from SQL/XML:2003 section 4.7 */
|
||||||
#define NAMESPACE_XSD "http://www.w3.org/2001/XMLSchema"
|
#define NAMESPACE_XSD "http://www.w3.org/2001/XMLSchema"
|
||||||
#define NAMESPACE_XSI "http://www.w3.org/2001/XMLSchema-instance"
|
#define NAMESPACE_XSI "http://www.w3.org/2001/XMLSchema-instance"
|
||||||
@ -168,19 +164,22 @@ xmlChar_to_encoding(xmlChar * encoding_name)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* xml_in uses a plain C string to VARDATA conversion, so for the time being
|
||||||
|
* we use the conversion function for the text datatype.
|
||||||
|
*
|
||||||
|
* This is only acceptable so long as xmltype and text use the same
|
||||||
|
* representation.
|
||||||
|
*/
|
||||||
Datum
|
Datum
|
||||||
xml_in(PG_FUNCTION_ARGS)
|
xml_in(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
#ifdef USE_LIBXML
|
#ifdef USE_LIBXML
|
||||||
char *s = PG_GETARG_CSTRING(0);
|
char *s = PG_GETARG_CSTRING(0);
|
||||||
size_t len;
|
|
||||||
xmltype *vardata;
|
xmltype *vardata;
|
||||||
xmlDocPtr doc;
|
xmlDocPtr doc;
|
||||||
|
|
||||||
len = strlen(s);
|
vardata = (xmltype *) cstring_to_text(s);
|
||||||
vardata = palloc(len + VARHDRSZ);
|
|
||||||
SET_VARSIZE(vardata, len + VARHDRSZ);
|
|
||||||
memcpy(VARDATA(vardata), s, len);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parse the data to check if it is well-formed XML data. Assume that
|
* Parse the data to check if it is well-formed XML data. Assume that
|
||||||
@ -200,6 +199,13 @@ xml_in(PG_FUNCTION_ARGS)
|
|||||||
#define PG_XML_DEFAULT_VERSION "1.0"
|
#define PG_XML_DEFAULT_VERSION "1.0"
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* xml_out_internal uses a plain VARDATA to C string conversion, so for the
|
||||||
|
* time being we use the conversion function for the text datatype.
|
||||||
|
*
|
||||||
|
* This is only acceptable so long as xmltype and text use the same
|
||||||
|
* representation.
|
||||||
|
*/
|
||||||
static char *
|
static char *
|
||||||
xml_out_internal(xmltype *x, pg_enc target_encoding)
|
xml_out_internal(xmltype *x, pg_enc target_encoding)
|
||||||
{
|
{
|
||||||
@ -213,10 +219,8 @@ xml_out_internal(xmltype *x, pg_enc target_encoding)
|
|||||||
int res_code;
|
int res_code;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
len = VARSIZE(x) - VARHDRSZ;
|
str = text_to_cstring((text *) x);
|
||||||
str = palloc(len + 1);
|
len = strlen(str);
|
||||||
memcpy(str, VARDATA(x), len);
|
|
||||||
str[len] = '\0';
|
|
||||||
|
|
||||||
#ifdef USE_LIBXML
|
#ifdef USE_LIBXML
|
||||||
if ((res_code = parse_xml_decl((xmlChar *) str,
|
if ((res_code = parse_xml_decl((xmlChar *) str,
|
||||||
@ -713,7 +717,7 @@ xmlpi(char *target, text *arg, bool arg_is_null, bool *result_is_null)
|
|||||||
{
|
{
|
||||||
char *string;
|
char *string;
|
||||||
|
|
||||||
string = _textout(arg);
|
string = text_to_cstring(arg);
|
||||||
if (strstr(string, "?>") != NULL)
|
if (strstr(string, "?>") != NULL)
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_INVALID_XML_PROCESSING_INSTRUCTION),
|
(errcode(ERRCODE_INVALID_XML_PROCESSING_INSTRUCTION),
|
||||||
@ -1930,7 +1934,7 @@ table_to_xml(PG_FUNCTION_ARGS)
|
|||||||
Oid relid = PG_GETARG_OID(0);
|
Oid relid = PG_GETARG_OID(0);
|
||||||
bool nulls = PG_GETARG_BOOL(1);
|
bool nulls = PG_GETARG_BOOL(1);
|
||||||
bool tableforest = PG_GETARG_BOOL(2);
|
bool tableforest = PG_GETARG_BOOL(2);
|
||||||
const char *targetns = _textout(PG_GETARG_TEXT_P(3));
|
const char *targetns = text_to_cstring(PG_GETARG_TEXT_PP(3));
|
||||||
|
|
||||||
PG_RETURN_XML_P(stringinfo_to_xmltype(table_to_xml_internal(relid, NULL,
|
PG_RETURN_XML_P(stringinfo_to_xmltype(table_to_xml_internal(relid, NULL,
|
||||||
nulls, tableforest,
|
nulls, tableforest,
|
||||||
@ -1941,10 +1945,10 @@ table_to_xml(PG_FUNCTION_ARGS)
|
|||||||
Datum
|
Datum
|
||||||
query_to_xml(PG_FUNCTION_ARGS)
|
query_to_xml(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
char *query = _textout(PG_GETARG_TEXT_P(0));
|
char *query = text_to_cstring(PG_GETARG_TEXT_PP(0));
|
||||||
bool nulls = PG_GETARG_BOOL(1);
|
bool nulls = PG_GETARG_BOOL(1);
|
||||||
bool tableforest = PG_GETARG_BOOL(2);
|
bool tableforest = PG_GETARG_BOOL(2);
|
||||||
const char *targetns = _textout(PG_GETARG_TEXT_P(3));
|
const char *targetns = text_to_cstring(PG_GETARG_TEXT_PP(3));
|
||||||
|
|
||||||
PG_RETURN_XML_P(stringinfo_to_xmltype(query_to_xml_internal(query, NULL,
|
PG_RETURN_XML_P(stringinfo_to_xmltype(query_to_xml_internal(query, NULL,
|
||||||
NULL, nulls, tableforest,
|
NULL, nulls, tableforest,
|
||||||
@ -1955,11 +1959,11 @@ query_to_xml(PG_FUNCTION_ARGS)
|
|||||||
Datum
|
Datum
|
||||||
cursor_to_xml(PG_FUNCTION_ARGS)
|
cursor_to_xml(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
char *name = _textout(PG_GETARG_TEXT_P(0));
|
char *name = text_to_cstring(PG_GETARG_TEXT_PP(0));
|
||||||
int32 count = PG_GETARG_INT32(1);
|
int32 count = PG_GETARG_INT32(1);
|
||||||
bool nulls = PG_GETARG_BOOL(2);
|
bool nulls = PG_GETARG_BOOL(2);
|
||||||
bool tableforest = PG_GETARG_BOOL(3);
|
bool tableforest = PG_GETARG_BOOL(3);
|
||||||
const char *targetns = _textout(PG_GETARG_TEXT_P(4));
|
const char *targetns = text_to_cstring(PG_GETARG_TEXT_PP(4));
|
||||||
|
|
||||||
StringInfoData result;
|
StringInfoData result;
|
||||||
Portal portal;
|
Portal portal;
|
||||||
@ -2079,7 +2083,7 @@ table_to_xmlschema(PG_FUNCTION_ARGS)
|
|||||||
Oid relid = PG_GETARG_OID(0);
|
Oid relid = PG_GETARG_OID(0);
|
||||||
bool nulls = PG_GETARG_BOOL(1);
|
bool nulls = PG_GETARG_BOOL(1);
|
||||||
bool tableforest = PG_GETARG_BOOL(2);
|
bool tableforest = PG_GETARG_BOOL(2);
|
||||||
const char *targetns = _textout(PG_GETARG_TEXT_P(3));
|
const char *targetns = text_to_cstring(PG_GETARG_TEXT_PP(3));
|
||||||
const char *result;
|
const char *result;
|
||||||
Relation rel;
|
Relation rel;
|
||||||
|
|
||||||
@ -2095,10 +2099,10 @@ table_to_xmlschema(PG_FUNCTION_ARGS)
|
|||||||
Datum
|
Datum
|
||||||
query_to_xmlschema(PG_FUNCTION_ARGS)
|
query_to_xmlschema(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
char *query = _textout(PG_GETARG_TEXT_P(0));
|
char *query = text_to_cstring(PG_GETARG_TEXT_PP(0));
|
||||||
bool nulls = PG_GETARG_BOOL(1);
|
bool nulls = PG_GETARG_BOOL(1);
|
||||||
bool tableforest = PG_GETARG_BOOL(2);
|
bool tableforest = PG_GETARG_BOOL(2);
|
||||||
const char *targetns = _textout(PG_GETARG_TEXT_P(3));
|
const char *targetns = text_to_cstring(PG_GETARG_TEXT_PP(3));
|
||||||
const char *result;
|
const char *result;
|
||||||
SPIPlanPtr plan;
|
SPIPlanPtr plan;
|
||||||
Portal portal;
|
Portal portal;
|
||||||
@ -2124,10 +2128,10 @@ query_to_xmlschema(PG_FUNCTION_ARGS)
|
|||||||
Datum
|
Datum
|
||||||
cursor_to_xmlschema(PG_FUNCTION_ARGS)
|
cursor_to_xmlschema(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
char *name = _textout(PG_GETARG_TEXT_P(0));
|
char *name = text_to_cstring(PG_GETARG_TEXT_PP(0));
|
||||||
bool nulls = PG_GETARG_BOOL(1);
|
bool nulls = PG_GETARG_BOOL(1);
|
||||||
bool tableforest = PG_GETARG_BOOL(2);
|
bool tableforest = PG_GETARG_BOOL(2);
|
||||||
const char *targetns = _textout(PG_GETARG_TEXT_P(3));
|
const char *targetns = text_to_cstring(PG_GETARG_TEXT_PP(3));
|
||||||
const char *xmlschema;
|
const char *xmlschema;
|
||||||
Portal portal;
|
Portal portal;
|
||||||
|
|
||||||
@ -2153,7 +2157,7 @@ table_to_xml_and_xmlschema(PG_FUNCTION_ARGS)
|
|||||||
Oid relid = PG_GETARG_OID(0);
|
Oid relid = PG_GETARG_OID(0);
|
||||||
bool nulls = PG_GETARG_BOOL(1);
|
bool nulls = PG_GETARG_BOOL(1);
|
||||||
bool tableforest = PG_GETARG_BOOL(2);
|
bool tableforest = PG_GETARG_BOOL(2);
|
||||||
const char *targetns = _textout(PG_GETARG_TEXT_P(3));
|
const char *targetns = text_to_cstring(PG_GETARG_TEXT_PP(3));
|
||||||
Relation rel;
|
Relation rel;
|
||||||
const char *xmlschema;
|
const char *xmlschema;
|
||||||
|
|
||||||
@ -2171,10 +2175,10 @@ table_to_xml_and_xmlschema(PG_FUNCTION_ARGS)
|
|||||||
Datum
|
Datum
|
||||||
query_to_xml_and_xmlschema(PG_FUNCTION_ARGS)
|
query_to_xml_and_xmlschema(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
char *query = _textout(PG_GETARG_TEXT_P(0));
|
char *query = text_to_cstring(PG_GETARG_TEXT_PP(0));
|
||||||
bool nulls = PG_GETARG_BOOL(1);
|
bool nulls = PG_GETARG_BOOL(1);
|
||||||
bool tableforest = PG_GETARG_BOOL(2);
|
bool tableforest = PG_GETARG_BOOL(2);
|
||||||
const char *targetns = _textout(PG_GETARG_TEXT_P(3));
|
const char *targetns = text_to_cstring(PG_GETARG_TEXT_PP(3));
|
||||||
|
|
||||||
const char *xmlschema;
|
const char *xmlschema;
|
||||||
SPIPlanPtr plan;
|
SPIPlanPtr plan;
|
||||||
@ -2255,7 +2259,7 @@ schema_to_xml(PG_FUNCTION_ARGS)
|
|||||||
Name name = PG_GETARG_NAME(0);
|
Name name = PG_GETARG_NAME(0);
|
||||||
bool nulls = PG_GETARG_BOOL(1);
|
bool nulls = PG_GETARG_BOOL(1);
|
||||||
bool tableforest = PG_GETARG_BOOL(2);
|
bool tableforest = PG_GETARG_BOOL(2);
|
||||||
const char *targetns = _textout(PG_GETARG_TEXT_P(3));
|
const char *targetns = text_to_cstring(PG_GETARG_TEXT_PP(3));
|
||||||
|
|
||||||
char *schemaname;
|
char *schemaname;
|
||||||
Oid nspid;
|
Oid nspid;
|
||||||
@ -2346,7 +2350,7 @@ schema_to_xmlschema(PG_FUNCTION_ARGS)
|
|||||||
Name name = PG_GETARG_NAME(0);
|
Name name = PG_GETARG_NAME(0);
|
||||||
bool nulls = PG_GETARG_BOOL(1);
|
bool nulls = PG_GETARG_BOOL(1);
|
||||||
bool tableforest = PG_GETARG_BOOL(2);
|
bool tableforest = PG_GETARG_BOOL(2);
|
||||||
const char *targetns = _textout(PG_GETARG_TEXT_P(3));
|
const char *targetns = text_to_cstring(PG_GETARG_TEXT_PP(3));
|
||||||
|
|
||||||
PG_RETURN_XML_P(stringinfo_to_xmltype(schema_to_xmlschema_internal(NameStr(*name),
|
PG_RETURN_XML_P(stringinfo_to_xmltype(schema_to_xmlschema_internal(NameStr(*name),
|
||||||
nulls, tableforest, targetns)));
|
nulls, tableforest, targetns)));
|
||||||
@ -2359,7 +2363,7 @@ schema_to_xml_and_xmlschema(PG_FUNCTION_ARGS)
|
|||||||
Name name = PG_GETARG_NAME(0);
|
Name name = PG_GETARG_NAME(0);
|
||||||
bool nulls = PG_GETARG_BOOL(1);
|
bool nulls = PG_GETARG_BOOL(1);
|
||||||
bool tableforest = PG_GETARG_BOOL(2);
|
bool tableforest = PG_GETARG_BOOL(2);
|
||||||
const char *targetns = _textout(PG_GETARG_TEXT_P(3));
|
const char *targetns = text_to_cstring(PG_GETARG_TEXT_PP(3));
|
||||||
char *schemaname;
|
char *schemaname;
|
||||||
Oid nspid;
|
Oid nspid;
|
||||||
StringInfo xmlschema;
|
StringInfo xmlschema;
|
||||||
@ -2431,7 +2435,7 @@ database_to_xml(PG_FUNCTION_ARGS)
|
|||||||
{
|
{
|
||||||
bool nulls = PG_GETARG_BOOL(0);
|
bool nulls = PG_GETARG_BOOL(0);
|
||||||
bool tableforest = PG_GETARG_BOOL(1);
|
bool tableforest = PG_GETARG_BOOL(1);
|
||||||
const char *targetns = _textout(PG_GETARG_TEXT_P(2));
|
const char *targetns = text_to_cstring(PG_GETARG_TEXT_PP(2));
|
||||||
|
|
||||||
PG_RETURN_XML_P(stringinfo_to_xmltype(database_to_xml_internal(NULL, nulls,
|
PG_RETURN_XML_P(stringinfo_to_xmltype(database_to_xml_internal(NULL, nulls,
|
||||||
tableforest, targetns)));
|
tableforest, targetns)));
|
||||||
@ -2486,7 +2490,7 @@ database_to_xmlschema(PG_FUNCTION_ARGS)
|
|||||||
{
|
{
|
||||||
bool nulls = PG_GETARG_BOOL(0);
|
bool nulls = PG_GETARG_BOOL(0);
|
||||||
bool tableforest = PG_GETARG_BOOL(1);
|
bool tableforest = PG_GETARG_BOOL(1);
|
||||||
const char *targetns = _textout(PG_GETARG_TEXT_P(2));
|
const char *targetns = text_to_cstring(PG_GETARG_TEXT_PP(2));
|
||||||
|
|
||||||
PG_RETURN_XML_P(stringinfo_to_xmltype(database_to_xmlschema_internal(nulls,
|
PG_RETURN_XML_P(stringinfo_to_xmltype(database_to_xmlschema_internal(nulls,
|
||||||
tableforest, targetns)));
|
tableforest, targetns)));
|
||||||
@ -2498,7 +2502,7 @@ database_to_xml_and_xmlschema(PG_FUNCTION_ARGS)
|
|||||||
{
|
{
|
||||||
bool nulls = PG_GETARG_BOOL(0);
|
bool nulls = PG_GETARG_BOOL(0);
|
||||||
bool tableforest = PG_GETARG_BOOL(1);
|
bool tableforest = PG_GETARG_BOOL(1);
|
||||||
const char *targetns = _textout(PG_GETARG_TEXT_P(2));
|
const char *targetns = text_to_cstring(PG_GETARG_TEXT_PP(2));
|
||||||
StringInfo xmlschema;
|
StringInfo xmlschema;
|
||||||
|
|
||||||
xmlschema = database_to_xmlschema_internal(nulls, tableforest, targetns);
|
xmlschema = database_to_xmlschema_internal(nulls, tableforest, targetns);
|
||||||
@ -3198,7 +3202,7 @@ xml_xmlnodetoxmltype(xmlNodePtr cur)
|
|||||||
{
|
{
|
||||||
str = xmlXPathCastNodeToString(cur);
|
str = xmlXPathCastNodeToString(cur);
|
||||||
len = strlen((char *) str);
|
len = strlen((char *) str);
|
||||||
result = (text *) palloc(len + VARHDRSZ);
|
result = (xmltype *) palloc(len + VARHDRSZ);
|
||||||
SET_VARSIZE(result, len + VARHDRSZ);
|
SET_VARSIZE(result, len + VARHDRSZ);
|
||||||
memcpy(VARDATA(result), str, len);
|
memcpy(VARDATA(result), str, len);
|
||||||
}
|
}
|
||||||
@ -3363,8 +3367,8 @@ xpath(PG_FUNCTION_ARGS)
|
|||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
|
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
|
||||||
errmsg("neither namespace name nor URI may be null")));
|
errmsg("neither namespace name nor URI may be null")));
|
||||||
ns_name = _textout(ns_names_uris[i * 2]);
|
ns_name = TextDatumGetCString(ns_names_uris[i * 2]);
|
||||||
ns_uri = _textout(ns_names_uris[i * 2 + 1]);
|
ns_uri = TextDatumGetCString(ns_names_uris[i * 2 + 1]);
|
||||||
if (xmlXPathRegisterNs(xpathctx,
|
if (xmlXPathRegisterNs(xpathctx,
|
||||||
(xmlChar *) ns_name,
|
(xmlChar *) ns_name,
|
||||||
(xmlChar *) ns_uri) != 0)
|
(xmlChar *) ns_uri) != 0)
|
||||||
|
8
src/backend/utils/cache/lsyscache.c
vendored
8
src/backend/utils/cache/lsyscache.c
vendored
@ -7,7 +7,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/cache/lsyscache.c,v 1.155 2008/01/01 19:45:53 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/cache/lsyscache.c,v 1.156 2008/03/25 22:42:44 tgl Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* Eventually, the index information should go through here, too.
|
* Eventually, the index information should go through here, too.
|
||||||
@ -1971,8 +1971,7 @@ get_typdefault(Oid typid)
|
|||||||
if (!isNull)
|
if (!isNull)
|
||||||
{
|
{
|
||||||
/* We have an expression default */
|
/* We have an expression default */
|
||||||
expr = stringToNode(DatumGetCString(DirectFunctionCall1(textout,
|
expr = stringToNode(TextDatumGetCString(datum));
|
||||||
datum)));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1987,8 +1986,7 @@ get_typdefault(Oid typid)
|
|||||||
char *strDefaultVal;
|
char *strDefaultVal;
|
||||||
|
|
||||||
/* Convert text datum to C string */
|
/* Convert text datum to C string */
|
||||||
strDefaultVal = DatumGetCString(DirectFunctionCall1(textout,
|
strDefaultVal = TextDatumGetCString(datum);
|
||||||
datum));
|
|
||||||
/* Convert C string to a value of the given type */
|
/* Convert C string to a value of the given type */
|
||||||
datum = OidInputFunctionCall(type->typinput, strDefaultVal,
|
datum = OidInputFunctionCall(type->typinput, strDefaultVal,
|
||||||
getTypeIOParam(typeTuple), -1);
|
getTypeIOParam(typeTuple), -1);
|
||||||
|
25
src/backend/utils/cache/relcache.c
vendored
25
src/backend/utils/cache/relcache.c
vendored
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.267 2008/02/27 17:44:19 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.268 2008/03/25 22:42:44 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -642,7 +642,6 @@ RelationBuildRuleLock(Relation relation)
|
|||||||
Form_pg_rewrite rewrite_form = (Form_pg_rewrite) GETSTRUCT(rewrite_tuple);
|
Form_pg_rewrite rewrite_form = (Form_pg_rewrite) GETSTRUCT(rewrite_tuple);
|
||||||
bool isnull;
|
bool isnull;
|
||||||
Datum rule_datum;
|
Datum rule_datum;
|
||||||
text *rule_text;
|
|
||||||
char *rule_str;
|
char *rule_str;
|
||||||
RewriteRule *rule;
|
RewriteRule *rule;
|
||||||
|
|
||||||
@ -667,30 +666,22 @@ RelationBuildRuleLock(Relation relation)
|
|||||||
rewrite_tupdesc,
|
rewrite_tupdesc,
|
||||||
&isnull);
|
&isnull);
|
||||||
Assert(!isnull);
|
Assert(!isnull);
|
||||||
rule_text = DatumGetTextP(rule_datum);
|
rule_str = TextDatumGetCString(rule_datum);
|
||||||
rule_str = DatumGetCString(DirectFunctionCall1(textout,
|
|
||||||
PointerGetDatum(rule_text)));
|
|
||||||
oldcxt = MemoryContextSwitchTo(rulescxt);
|
oldcxt = MemoryContextSwitchTo(rulescxt);
|
||||||
rule->actions = (List *) stringToNode(rule_str);
|
rule->actions = (List *) stringToNode(rule_str);
|
||||||
MemoryContextSwitchTo(oldcxt);
|
MemoryContextSwitchTo(oldcxt);
|
||||||
pfree(rule_str);
|
pfree(rule_str);
|
||||||
if ((Pointer) rule_text != DatumGetPointer(rule_datum))
|
|
||||||
pfree(rule_text);
|
|
||||||
|
|
||||||
rule_datum = heap_getattr(rewrite_tuple,
|
rule_datum = heap_getattr(rewrite_tuple,
|
||||||
Anum_pg_rewrite_ev_qual,
|
Anum_pg_rewrite_ev_qual,
|
||||||
rewrite_tupdesc,
|
rewrite_tupdesc,
|
||||||
&isnull);
|
&isnull);
|
||||||
Assert(!isnull);
|
Assert(!isnull);
|
||||||
rule_text = DatumGetTextP(rule_datum);
|
rule_str = TextDatumGetCString(rule_datum);
|
||||||
rule_str = DatumGetCString(DirectFunctionCall1(textout,
|
|
||||||
PointerGetDatum(rule_text)));
|
|
||||||
oldcxt = MemoryContextSwitchTo(rulescxt);
|
oldcxt = MemoryContextSwitchTo(rulescxt);
|
||||||
rule->qual = (Node *) stringToNode(rule_str);
|
rule->qual = (Node *) stringToNode(rule_str);
|
||||||
MemoryContextSwitchTo(oldcxt);
|
MemoryContextSwitchTo(oldcxt);
|
||||||
pfree(rule_str);
|
pfree(rule_str);
|
||||||
if ((Pointer) rule_text != DatumGetPointer(rule_datum))
|
|
||||||
pfree(rule_text);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We want the rule's table references to be checked as though by the
|
* We want the rule's table references to be checked as though by the
|
||||||
@ -2770,8 +2761,7 @@ AttrDefaultFetch(Relation relation)
|
|||||||
RelationGetRelationName(relation));
|
RelationGetRelationName(relation));
|
||||||
else
|
else
|
||||||
attrdef[i].adbin = MemoryContextStrdup(CacheMemoryContext,
|
attrdef[i].adbin = MemoryContextStrdup(CacheMemoryContext,
|
||||||
DatumGetCString(DirectFunctionCall1(textout,
|
TextDatumGetCString(val));
|
||||||
val)));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2834,8 +2824,7 @@ CheckConstraintFetch(Relation relation)
|
|||||||
RelationGetRelationName(relation));
|
RelationGetRelationName(relation));
|
||||||
|
|
||||||
check[found].ccbin = MemoryContextStrdup(CacheMemoryContext,
|
check[found].ccbin = MemoryContextStrdup(CacheMemoryContext,
|
||||||
DatumGetCString(DirectFunctionCall1(textout,
|
TextDatumGetCString(val));
|
||||||
val)));
|
|
||||||
found++;
|
found++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3068,7 +3057,7 @@ RelationGetIndexExpressions(Relation relation)
|
|||||||
GetPgIndexDescriptor(),
|
GetPgIndexDescriptor(),
|
||||||
&isnull);
|
&isnull);
|
||||||
Assert(!isnull);
|
Assert(!isnull);
|
||||||
exprsString = DatumGetCString(DirectFunctionCall1(textout, exprsDatum));
|
exprsString = TextDatumGetCString(exprsDatum);
|
||||||
result = (List *) stringToNode(exprsString);
|
result = (List *) stringToNode(exprsString);
|
||||||
pfree(exprsString);
|
pfree(exprsString);
|
||||||
|
|
||||||
@ -3135,7 +3124,7 @@ RelationGetIndexPredicate(Relation relation)
|
|||||||
GetPgIndexDescriptor(),
|
GetPgIndexDescriptor(),
|
||||||
&isnull);
|
&isnull);
|
||||||
Assert(!isnull);
|
Assert(!isnull);
|
||||||
predString = DatumGetCString(DirectFunctionCall1(textout, predDatum));
|
predString = TextDatumGetCString(predDatum);
|
||||||
result = (List *) stringToNode(predString);
|
result = (List *) stringToNode(predString);
|
||||||
pfree(predString);
|
pfree(predString);
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/fmgr/fmgr.c,v 1.113 2008/01/03 21:23:15 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/fmgr/fmgr.c,v 1.114 2008/03/25 22:42:45 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -246,8 +246,7 @@ fmgr_info_cxt_security(Oid functionId, FmgrInfo *finfo, MemoryContext mcxt,
|
|||||||
Anum_pg_proc_prosrc, &isnull);
|
Anum_pg_proc_prosrc, &isnull);
|
||||||
if (isnull)
|
if (isnull)
|
||||||
elog(ERROR, "null prosrc");
|
elog(ERROR, "null prosrc");
|
||||||
prosrc = DatumGetCString(DirectFunctionCall1(textout,
|
prosrc = TextDatumGetCString(prosrcdatum);
|
||||||
prosrcdatum));
|
|
||||||
fbp = fmgr_lookupByName(prosrc);
|
fbp = fmgr_lookupByName(prosrc);
|
||||||
if (fbp == NULL)
|
if (fbp == NULL)
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
@ -315,15 +314,13 @@ fmgr_info_C_lang(Oid functionId, FmgrInfo *finfo, HeapTuple procedureTuple)
|
|||||||
Anum_pg_proc_prosrc, &isnull);
|
Anum_pg_proc_prosrc, &isnull);
|
||||||
if (isnull)
|
if (isnull)
|
||||||
elog(ERROR, "null prosrc for function %u", functionId);
|
elog(ERROR, "null prosrc for function %u", functionId);
|
||||||
prosrcstring = DatumGetCString(DirectFunctionCall1(textout,
|
prosrcstring = TextDatumGetCString(prosrcattr);
|
||||||
prosrcattr));
|
|
||||||
|
|
||||||
probinattr = SysCacheGetAttr(PROCOID, procedureTuple,
|
probinattr = SysCacheGetAttr(PROCOID, procedureTuple,
|
||||||
Anum_pg_proc_probin, &isnull);
|
Anum_pg_proc_probin, &isnull);
|
||||||
if (isnull)
|
if (isnull)
|
||||||
elog(ERROR, "null probin for function %u", functionId);
|
elog(ERROR, "null probin for function %u", functionId);
|
||||||
probinstring = DatumGetCString(DirectFunctionCall1(textout,
|
probinstring = TextDatumGetCString(probinattr);
|
||||||
probinattr));
|
|
||||||
|
|
||||||
/* Look up the function itself */
|
/* Look up the function itself */
|
||||||
user_fn = load_external_function(probinstring, prosrcstring, true,
|
user_fn = load_external_function(probinstring, prosrcstring, true,
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Copyright (c) 2002-2008, PostgreSQL Global Development Group
|
* Copyright (c) 2002-2008, PostgreSQL Global Development Group
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/fmgr/funcapi.c,v 1.38 2008/02/29 02:49:39 neilc Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/fmgr/funcapi.c,v 1.39 2008/03/25 22:42:45 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -741,8 +741,7 @@ get_func_arg_info(HeapTuple procTup,
|
|||||||
elog(ERROR, "proargnames must have the same number of elements as the function has arguments");
|
elog(ERROR, "proargnames must have the same number of elements as the function has arguments");
|
||||||
*p_argnames = (char **) palloc(sizeof(char *) * numargs);
|
*p_argnames = (char **) palloc(sizeof(char *) * numargs);
|
||||||
for (i = 0; i < numargs; i++)
|
for (i = 0; i < numargs; i++)
|
||||||
(*p_argnames)[i] = DatumGetCString(DirectFunctionCall1(textout,
|
(*p_argnames)[i] = TextDatumGetCString(elems[i]);
|
||||||
elems[i]));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get argument modes, if available */
|
/* Get argument modes, if available */
|
||||||
@ -855,8 +854,7 @@ get_func_result_name(Oid functionId)
|
|||||||
result = NULL;
|
result = NULL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
result = DatumGetCString(DirectFunctionCall1(textout,
|
result = TextDatumGetCString(argnames[i]);
|
||||||
argnames[i]));
|
|
||||||
if (result == NULL || result[0] == '\0')
|
if (result == NULL || result[0] == '\0')
|
||||||
{
|
{
|
||||||
/* Parameter is not named, so forget it */
|
/* Parameter is not named, so forget it */
|
||||||
@ -1002,7 +1000,7 @@ build_function_result_tupdesc_d(Datum proallargtypes,
|
|||||||
argmodes[i] == PROARGMODE_INOUT);
|
argmodes[i] == PROARGMODE_INOUT);
|
||||||
outargtypes[numoutargs] = argtypes[i];
|
outargtypes[numoutargs] = argtypes[i];
|
||||||
if (argnames)
|
if (argnames)
|
||||||
pname = DatumGetCString(DirectFunctionCall1(textout, argnames[i]));
|
pname = TextDatumGetCString(argnames[i]);
|
||||||
else
|
else
|
||||||
pname = NULL;
|
pname = NULL;
|
||||||
if (pname == NULL || pname[0] == '\0')
|
if (pname == NULL || pname[0] == '\0')
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/init/flatfiles.c,v 1.30 2008/01/01 19:45:53 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/init/flatfiles.c,v 1.31 2008/03/25 22:42:45 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -461,13 +461,14 @@ write_auth_file(Relation rel_authid, Relation rel_authmem)
|
|||||||
* it is, ignore it, since we can't handle that in startup mode.
|
* it is, ignore it, since we can't handle that in startup mode.
|
||||||
*
|
*
|
||||||
* It is entirely likely that it's 1-byte format not 4-byte, and
|
* It is entirely likely that it's 1-byte format not 4-byte, and
|
||||||
* theoretically possible that it's compressed inline, but textout
|
* theoretically possible that it's compressed inline, but
|
||||||
* should be able to handle those cases even in startup mode.
|
* text_to_cstring should be able to handle those cases even in
|
||||||
|
* startup mode.
|
||||||
*/
|
*/
|
||||||
if (VARATT_IS_EXTERNAL(DatumGetPointer(datum)))
|
if (VARATT_IS_EXTERNAL(DatumGetPointer(datum)))
|
||||||
auth_info[curr_role].rolpassword = pstrdup("");
|
auth_info[curr_role].rolpassword = pstrdup("");
|
||||||
else
|
else
|
||||||
auth_info[curr_role].rolpassword = DatumGetCString(DirectFunctionCall1(textout, datum));
|
auth_info[curr_role].rolpassword = TextDatumGetCString(datum);
|
||||||
|
|
||||||
/* assume passwd has attlen -1 */
|
/* assume passwd has attlen -1 */
|
||||||
off = att_addlength_pointer(off, -1, tp + off);
|
off = att_addlength_pointer(off, -1, tp + off);
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
* Written by Peter Eisentraut <peter_e@gmx.net>.
|
* Written by Peter Eisentraut <peter_e@gmx.net>.
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.439 2008/03/17 17:45:09 mha Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.440 2008/03/25 22:42:45 tgl Exp $
|
||||||
*
|
*
|
||||||
*--------------------------------------------------------------------
|
*--------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -5364,7 +5364,6 @@ set_config_by_name(PG_FUNCTION_ARGS)
|
|||||||
char *value;
|
char *value;
|
||||||
char *new_value;
|
char *new_value;
|
||||||
bool is_local;
|
bool is_local;
|
||||||
text *result_text;
|
|
||||||
|
|
||||||
if (PG_ARGISNULL(0))
|
if (PG_ARGISNULL(0))
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
@ -5372,13 +5371,13 @@ set_config_by_name(PG_FUNCTION_ARGS)
|
|||||||
errmsg("SET requires parameter name")));
|
errmsg("SET requires parameter name")));
|
||||||
|
|
||||||
/* Get the GUC variable name */
|
/* Get the GUC variable name */
|
||||||
name = DatumGetCString(DirectFunctionCall1(textout, PG_GETARG_DATUM(0)));
|
name = TextDatumGetCString(PG_GETARG_DATUM(0));
|
||||||
|
|
||||||
/* Get the desired value or set to NULL for a reset request */
|
/* Get the desired value or set to NULL for a reset request */
|
||||||
if (PG_ARGISNULL(1))
|
if (PG_ARGISNULL(1))
|
||||||
value = NULL;
|
value = NULL;
|
||||||
else
|
else
|
||||||
value = DatumGetCString(DirectFunctionCall1(textout, PG_GETARG_DATUM(1)));
|
value = TextDatumGetCString(PG_GETARG_DATUM(1));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get the desired state of is_local. Default to false if provided value
|
* Get the desired state of is_local. Default to false if provided value
|
||||||
@ -5401,10 +5400,7 @@ set_config_by_name(PG_FUNCTION_ARGS)
|
|||||||
new_value = GetConfigOptionByName(name, NULL);
|
new_value = GetConfigOptionByName(name, NULL);
|
||||||
|
|
||||||
/* Convert return string to text */
|
/* Convert return string to text */
|
||||||
result_text = DatumGetTextP(DirectFunctionCall1(textin, CStringGetDatum(new_value)));
|
PG_RETURN_TEXT_P(cstring_to_text(new_value));
|
||||||
|
|
||||||
/* return it */
|
|
||||||
PG_RETURN_TEXT_P(result_text);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -5992,19 +5988,15 @@ show_config_by_name(PG_FUNCTION_ARGS)
|
|||||||
{
|
{
|
||||||
char *varname;
|
char *varname;
|
||||||
char *varval;
|
char *varval;
|
||||||
text *result_text;
|
|
||||||
|
|
||||||
/* Get the GUC variable name */
|
/* Get the GUC variable name */
|
||||||
varname = DatumGetCString(DirectFunctionCall1(textout, PG_GETARG_DATUM(0)));
|
varname = TextDatumGetCString(PG_GETARG_DATUM(0));
|
||||||
|
|
||||||
/* Get the value */
|
/* Get the value */
|
||||||
varval = GetConfigOptionByName(varname, NULL);
|
varval = GetConfigOptionByName(varname, NULL);
|
||||||
|
|
||||||
/* Convert to text */
|
/* Convert to text */
|
||||||
result_text = DatumGetTextP(DirectFunctionCall1(textin, CStringGetDatum(varval)));
|
PG_RETURN_TEXT_P(cstring_to_text(varval));
|
||||||
|
|
||||||
/* return it */
|
|
||||||
PG_RETURN_TEXT_P(result_text);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -6609,7 +6601,7 @@ ProcessGUCArray(ArrayType *array,
|
|||||||
if (isnull)
|
if (isnull)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
s = DatumGetCString(DirectFunctionCall1(textout, d));
|
s = TextDatumGetCString(d);
|
||||||
|
|
||||||
ParseLongOption(s, &name, &value);
|
ParseLongOption(s, &name, &value);
|
||||||
if (!value)
|
if (!value)
|
||||||
@ -6657,7 +6649,7 @@ GUCArrayAdd(ArrayType *array, const char *name, const char *value)
|
|||||||
|
|
||||||
newval = palloc(strlen(name) + 1 + strlen(value) + 1);
|
newval = palloc(strlen(name) + 1 + strlen(value) + 1);
|
||||||
sprintf(newval, "%s=%s", name, value);
|
sprintf(newval, "%s=%s", name, value);
|
||||||
datum = DirectFunctionCall1(textin, CStringGetDatum(newval));
|
datum = CStringGetTextDatum(newval);
|
||||||
|
|
||||||
if (array)
|
if (array)
|
||||||
{
|
{
|
||||||
@ -6684,7 +6676,7 @@ GUCArrayAdd(ArrayType *array, const char *name, const char *value)
|
|||||||
&isnull);
|
&isnull);
|
||||||
if (isnull)
|
if (isnull)
|
||||||
continue;
|
continue;
|
||||||
current = DatumGetCString(DirectFunctionCall1(textout, d));
|
current = TextDatumGetCString(d);
|
||||||
if (strncmp(current, newval, strlen(name) + 1) == 0)
|
if (strncmp(current, newval, strlen(name) + 1) == 0)
|
||||||
{
|
{
|
||||||
index = i;
|
index = i;
|
||||||
@ -6754,7 +6746,7 @@ GUCArrayDelete(ArrayType *array, const char *name)
|
|||||||
&isnull);
|
&isnull);
|
||||||
if (isnull)
|
if (isnull)
|
||||||
continue;
|
continue;
|
||||||
val = DatumGetCString(DirectFunctionCall1(textout, d));
|
val = TextDatumGetCString(d);
|
||||||
|
|
||||||
/* ignore entry if it's what we want to delete */
|
/* ignore entry if it's what we want to delete */
|
||||||
if (strncmp(val, name, strlen(name)) == 0
|
if (strncmp(val, name, strlen(name)) == 0
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/mmgr/portalmem.c,v 1.107 2008/03/25 19:26:53 neilc Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/mmgr/portalmem.c,v 1.108 2008/03/25 22:42:45 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -923,12 +923,11 @@ pg_cursor(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
MemSet(nulls, 0, sizeof(nulls));
|
MemSet(nulls, 0, sizeof(nulls));
|
||||||
|
|
||||||
values[0] = DirectFunctionCall1(textin, CStringGetDatum(portal->name));
|
values[0] = CStringGetTextDatum(portal->name);
|
||||||
if (!portal->sourceText)
|
if (!portal->sourceText)
|
||||||
nulls[1] = true;
|
nulls[1] = true;
|
||||||
else
|
else
|
||||||
values[1] = DirectFunctionCall1(textin,
|
values[1] = CStringGetTextDatum(portal->sourceText);
|
||||||
CStringGetDatum(portal->sourceText));
|
|
||||||
values[2] = BoolGetDatum(portal->cursorOptions & CURSOR_OPT_HOLD);
|
values[2] = BoolGetDatum(portal->cursorOptions & CURSOR_OPT_HOLD);
|
||||||
values[3] = BoolGetDatum(portal->cursorOptions & CURSOR_OPT_BINARY);
|
values[3] = BoolGetDatum(portal->cursorOptions & CURSOR_OPT_BINARY);
|
||||||
values[4] = BoolGetDatum(portal->cursorOptions & CURSOR_OPT_SCROLL);
|
values[4] = BoolGetDatum(portal->cursorOptions & CURSOR_OPT_SCROLL);
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 1998-2008, PostgreSQL Global Development Group
|
* Copyright (c) 1998-2008, PostgreSQL Global Development Group
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/include/tsearch/ts_utils.h,v 1.12 2008/01/01 19:45:59 momjian Exp $
|
* $PostgreSQL: pgsql/src/include/tsearch/ts_utils.h,v 1.13 2008/03/25 22:42:45 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -106,12 +106,6 @@ extern text *generateHeadline(HeadlineParsedText *prs);
|
|||||||
extern bool TS_execute(QueryItem *curitem, void *checkval, bool calcnot,
|
extern bool TS_execute(QueryItem *curitem, void *checkval, bool calcnot,
|
||||||
bool (*chkcond) (void *checkval, QueryOperand *val));
|
bool (*chkcond) (void *checkval, QueryOperand *val));
|
||||||
|
|
||||||
/*
|
|
||||||
* Useful conversion macros
|
|
||||||
*/
|
|
||||||
#define TextPGetCString(t) DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(t)))
|
|
||||||
#define CStringGetTextP(c) DatumGetTextP(DirectFunctionCall1(textin, CStringGetDatum(c)))
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* to_ts* - text transformation to tsvector, tsquery
|
* to_ts* - text transformation to tsvector, tsquery
|
||||||
*/
|
*/
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/include/utils/builtins.h,v 1.309 2008/03/23 00:24:20 tgl Exp $
|
* $PostgreSQL: pgsql/src/include/utils/builtins.h,v 1.310 2008/03/25 22:42:45 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -617,6 +617,14 @@ extern Datum varchartypmodout(PG_FUNCTION_ARGS);
|
|||||||
extern Datum varchar(PG_FUNCTION_ARGS);
|
extern Datum varchar(PG_FUNCTION_ARGS);
|
||||||
|
|
||||||
/* varlena.c */
|
/* varlena.c */
|
||||||
|
extern text *cstring_to_text(const char *s);
|
||||||
|
extern text *cstring_to_text_with_len(const char *s, int len);
|
||||||
|
extern char *text_to_cstring(const text *t);
|
||||||
|
extern void text_to_cstring_buffer(const text *src, char *dst, size_t dst_len);
|
||||||
|
|
||||||
|
#define CStringGetTextDatum(s) PointerGetDatum(cstring_to_text(s))
|
||||||
|
#define TextDatumGetCString(d) text_to_cstring((text *) DatumGetPointer(d))
|
||||||
|
|
||||||
extern Datum textin(PG_FUNCTION_ARGS);
|
extern Datum textin(PG_FUNCTION_ARGS);
|
||||||
extern Datum textout(PG_FUNCTION_ARGS);
|
extern Datum textout(PG_FUNCTION_ARGS);
|
||||||
extern Datum textrecv(PG_FUNCTION_ARGS);
|
extern Datum textrecv(PG_FUNCTION_ARGS);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* plperl.c - perl as a procedural language for PostgreSQL
|
* plperl.c - perl as a procedural language for PostgreSQL
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.137 2008/03/25 19:26:53 neilc Exp $
|
* $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.138 2008/03/25 22:42:45 tgl Exp $
|
||||||
*
|
*
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
@ -542,7 +542,7 @@ plperl_safe_init(void)
|
|||||||
desc.arg_is_rowtype[0] = false;
|
desc.arg_is_rowtype[0] = false;
|
||||||
fmgr_info(F_TEXTOUT, &(desc.arg_out_func[0]));
|
fmgr_info(F_TEXTOUT, &(desc.arg_out_func[0]));
|
||||||
|
|
||||||
fcinfo.arg[0] = DirectFunctionCall1(textin, CStringGetDatum("a"));
|
fcinfo.arg[0] = CStringGetTextDatum("a");
|
||||||
fcinfo.argnull[0] = false;
|
fcinfo.argnull[0] = false;
|
||||||
|
|
||||||
/* and make the call */
|
/* and make the call */
|
||||||
@ -1668,8 +1668,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger)
|
|||||||
Anum_pg_proc_prosrc, &isnull);
|
Anum_pg_proc_prosrc, &isnull);
|
||||||
if (isnull)
|
if (isnull)
|
||||||
elog(ERROR, "null prosrc");
|
elog(ERROR, "null prosrc");
|
||||||
proc_source = DatumGetCString(DirectFunctionCall1(textout,
|
proc_source = TextDatumGetCString(prosrcdatum);
|
||||||
prosrcdatum));
|
|
||||||
|
|
||||||
/************************************************************
|
/************************************************************
|
||||||
* Create the procedure in the interpreter
|
* Create the procedure in the interpreter
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.121 2008/01/01 19:46:00 momjian Exp $
|
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.122 2008/03/25 22:42:45 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -292,7 +292,7 @@ do_compile(FunctionCallInfo fcinfo,
|
|||||||
Anum_pg_proc_prosrc, &isnull);
|
Anum_pg_proc_prosrc, &isnull);
|
||||||
if (isnull)
|
if (isnull)
|
||||||
elog(ERROR, "null prosrc");
|
elog(ERROR, "null prosrc");
|
||||||
proc_source = DatumGetCString(DirectFunctionCall1(textout, prosrcdatum));
|
proc_source = TextDatumGetCString(prosrcdatum);
|
||||||
plpgsql_scanner_init(proc_source, functype);
|
plpgsql_scanner_init(proc_source, functype);
|
||||||
|
|
||||||
plpgsql_error_funcname = pstrdup(NameStr(procStruct->proname));
|
plpgsql_error_funcname = pstrdup(NameStr(procStruct->proname));
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.203 2008/03/25 19:26:54 neilc Exp $
|
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.204 2008/03/25 22:42:45 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -532,11 +532,11 @@ plpgsql_exec_trigger(PLpgSQL_function *func,
|
|||||||
|
|
||||||
var = (PLpgSQL_var *) (estate.datums[func->tg_op_varno]);
|
var = (PLpgSQL_var *) (estate.datums[func->tg_op_varno]);
|
||||||
if (TRIGGER_FIRED_BY_INSERT(trigdata->tg_event))
|
if (TRIGGER_FIRED_BY_INSERT(trigdata->tg_event))
|
||||||
var->value = DirectFunctionCall1(textin, CStringGetDatum("INSERT"));
|
var->value = CStringGetTextDatum("INSERT");
|
||||||
else if (TRIGGER_FIRED_BY_UPDATE(trigdata->tg_event))
|
else if (TRIGGER_FIRED_BY_UPDATE(trigdata->tg_event))
|
||||||
var->value = DirectFunctionCall1(textin, CStringGetDatum("UPDATE"));
|
var->value = CStringGetTextDatum("UPDATE");
|
||||||
else if (TRIGGER_FIRED_BY_DELETE(trigdata->tg_event))
|
else if (TRIGGER_FIRED_BY_DELETE(trigdata->tg_event))
|
||||||
var->value = DirectFunctionCall1(textin, CStringGetDatum("DELETE"));
|
var->value = CStringGetTextDatum("DELETE");
|
||||||
else
|
else
|
||||||
elog(ERROR, "unrecognized trigger action: not INSERT, DELETE, or UPDATE");
|
elog(ERROR, "unrecognized trigger action: not INSERT, DELETE, or UPDATE");
|
||||||
var->isnull = false;
|
var->isnull = false;
|
||||||
@ -550,9 +550,9 @@ plpgsql_exec_trigger(PLpgSQL_function *func,
|
|||||||
|
|
||||||
var = (PLpgSQL_var *) (estate.datums[func->tg_when_varno]);
|
var = (PLpgSQL_var *) (estate.datums[func->tg_when_varno]);
|
||||||
if (TRIGGER_FIRED_BEFORE(trigdata->tg_event))
|
if (TRIGGER_FIRED_BEFORE(trigdata->tg_event))
|
||||||
var->value = DirectFunctionCall1(textin, CStringGetDatum("BEFORE"));
|
var->value = CStringGetTextDatum("BEFORE");
|
||||||
else if (TRIGGER_FIRED_AFTER(trigdata->tg_event))
|
else if (TRIGGER_FIRED_AFTER(trigdata->tg_event))
|
||||||
var->value = DirectFunctionCall1(textin, CStringGetDatum("AFTER"));
|
var->value = CStringGetTextDatum("AFTER");
|
||||||
else
|
else
|
||||||
elog(ERROR, "unrecognized trigger execution time: not BEFORE or AFTER");
|
elog(ERROR, "unrecognized trigger execution time: not BEFORE or AFTER");
|
||||||
var->isnull = false;
|
var->isnull = false;
|
||||||
@ -560,9 +560,9 @@ plpgsql_exec_trigger(PLpgSQL_function *func,
|
|||||||
|
|
||||||
var = (PLpgSQL_var *) (estate.datums[func->tg_level_varno]);
|
var = (PLpgSQL_var *) (estate.datums[func->tg_level_varno]);
|
||||||
if (TRIGGER_FIRED_FOR_ROW(trigdata->tg_event))
|
if (TRIGGER_FIRED_FOR_ROW(trigdata->tg_event))
|
||||||
var->value = DirectFunctionCall1(textin, CStringGetDatum("ROW"));
|
var->value = CStringGetTextDatum("ROW");
|
||||||
else if (TRIGGER_FIRED_FOR_STATEMENT(trigdata->tg_event))
|
else if (TRIGGER_FIRED_FOR_STATEMENT(trigdata->tg_event))
|
||||||
var->value = DirectFunctionCall1(textin, CStringGetDatum("STATEMENT"));
|
var->value = CStringGetTextDatum("STATEMENT");
|
||||||
else
|
else
|
||||||
elog(ERROR, "unrecognized trigger event type: not ROW or STATEMENT");
|
elog(ERROR, "unrecognized trigger event type: not ROW or STATEMENT");
|
||||||
var->isnull = false;
|
var->isnull = false;
|
||||||
@ -611,8 +611,7 @@ plpgsql_exec_trigger(PLpgSQL_function *func,
|
|||||||
{
|
{
|
||||||
estate.trig_argv = palloc(sizeof(Datum) * estate.trig_nargs);
|
estate.trig_argv = palloc(sizeof(Datum) * estate.trig_nargs);
|
||||||
for (i = 0; i < trigdata->tg_trigger->tgnargs; i++)
|
for (i = 0; i < trigdata->tg_trigger->tgnargs; i++)
|
||||||
estate.trig_argv[i] = DirectFunctionCall1(textin,
|
estate.trig_argv[i] = CStringGetTextDatum(trigdata->tg_trigger->tgargs[i]);
|
||||||
CStringGetDatum(trigdata->tg_trigger->tgargs[i]));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
estate.err_text = gettext_noop("during function entry");
|
estate.err_text = gettext_noop("during function entry");
|
||||||
@ -1070,15 +1069,13 @@ exec_stmt_block(PLpgSQL_execstate *estate, PLpgSQL_stmt_block *block)
|
|||||||
|
|
||||||
state_var = (PLpgSQL_var *)
|
state_var = (PLpgSQL_var *)
|
||||||
estate->datums[block->exceptions->sqlstate_varno];
|
estate->datums[block->exceptions->sqlstate_varno];
|
||||||
state_var->value = DirectFunctionCall1(textin,
|
state_var->value = CStringGetTextDatum(unpack_sql_state(edata->sqlerrcode));
|
||||||
CStringGetDatum(unpack_sql_state(edata->sqlerrcode)));
|
|
||||||
state_var->freeval = true;
|
state_var->freeval = true;
|
||||||
state_var->isnull = false;
|
state_var->isnull = false;
|
||||||
|
|
||||||
errm_var = (PLpgSQL_var *)
|
errm_var = (PLpgSQL_var *)
|
||||||
estate->datums[block->exceptions->sqlerrm_varno];
|
estate->datums[block->exceptions->sqlerrm_varno];
|
||||||
errm_var->value = DirectFunctionCall1(textin,
|
errm_var->value = CStringGetTextDatum(edata->message);
|
||||||
CStringGetDatum(edata->message));
|
|
||||||
errm_var->freeval = true;
|
errm_var->freeval = true;
|
||||||
errm_var->isnull = false;
|
errm_var->isnull = false;
|
||||||
|
|
||||||
@ -3017,7 +3014,7 @@ exec_stmt_open(PLpgSQL_execstate *estate, PLpgSQL_stmt_open *stmt)
|
|||||||
curvar = (PLpgSQL_var *) (estate->datums[stmt->curvar]);
|
curvar = (PLpgSQL_var *) (estate->datums[stmt->curvar]);
|
||||||
if (!curvar->isnull)
|
if (!curvar->isnull)
|
||||||
{
|
{
|
||||||
curname = DatumGetCString(DirectFunctionCall1(textout, curvar->value));
|
curname = TextDatumGetCString(curvar->value);
|
||||||
if (SPI_cursor_find(curname) != NULL)
|
if (SPI_cursor_find(curname) != NULL)
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_DUPLICATE_CURSOR),
|
(errcode(ERRCODE_DUPLICATE_CURSOR),
|
||||||
@ -3090,7 +3087,7 @@ exec_stmt_open(PLpgSQL_execstate *estate, PLpgSQL_stmt_open *stmt)
|
|||||||
* ----------
|
* ----------
|
||||||
*/
|
*/
|
||||||
free_var(curvar);
|
free_var(curvar);
|
||||||
curvar->value = DirectFunctionCall1(textin, CStringGetDatum(portal->name));
|
curvar->value = CStringGetTextDatum(portal->name);
|
||||||
curvar->isnull = false;
|
curvar->isnull = false;
|
||||||
curvar->freeval = true;
|
curvar->freeval = true;
|
||||||
|
|
||||||
@ -3188,7 +3185,7 @@ exec_stmt_open(PLpgSQL_execstate *estate, PLpgSQL_stmt_open *stmt)
|
|||||||
* ----------
|
* ----------
|
||||||
*/
|
*/
|
||||||
free_var(curvar);
|
free_var(curvar);
|
||||||
curvar->value = DirectFunctionCall1(textin, CStringGetDatum(portal->name));
|
curvar->value = CStringGetTextDatum(portal->name);
|
||||||
curvar->isnull = false;
|
curvar->isnull = false;
|
||||||
curvar->freeval = true;
|
curvar->freeval = true;
|
||||||
|
|
||||||
@ -3222,7 +3219,7 @@ exec_stmt_fetch(PLpgSQL_execstate *estate, PLpgSQL_stmt_fetch *stmt)
|
|||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
|
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
|
||||||
errmsg("cursor variable \"%s\" is NULL", curvar->refname)));
|
errmsg("cursor variable \"%s\" is NULL", curvar->refname)));
|
||||||
curname = DatumGetCString(DirectFunctionCall1(textout, curvar->value));
|
curname = TextDatumGetCString(curvar->value);
|
||||||
|
|
||||||
portal = SPI_cursor_find(curname);
|
portal = SPI_cursor_find(curname);
|
||||||
if (portal == NULL)
|
if (portal == NULL)
|
||||||
@ -3318,7 +3315,7 @@ exec_stmt_close(PLpgSQL_execstate *estate, PLpgSQL_stmt_close *stmt)
|
|||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
|
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
|
||||||
errmsg("cursor variable \"%s\" is NULL", curvar->refname)));
|
errmsg("cursor variable \"%s\" is NULL", curvar->refname)));
|
||||||
curname = DatumGetCString(DirectFunctionCall1(textout, curvar->value));
|
curname = TextDatumGetCString(curvar->value);
|
||||||
|
|
||||||
portal = SPI_cursor_find(curname);
|
portal = SPI_cursor_find(curname);
|
||||||
if (portal == NULL)
|
if (portal == NULL)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* plpython.c - python as a procedural language for PostgreSQL
|
* plpython.c - python as a procedural language for PostgreSQL
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.106 2008/01/02 03:10:27 tgl Exp $
|
* $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.107 2008/03/25 22:42:45 tgl Exp $
|
||||||
*
|
*
|
||||||
*********************************************************************
|
*********************************************************************
|
||||||
*/
|
*/
|
||||||
@ -1298,7 +1298,7 @@ PLy_procedure_create(HeapTuple procTup, Oid tgreloid, char *key)
|
|||||||
|
|
||||||
/* Fetch argument name */
|
/* Fetch argument name */
|
||||||
if (proc->argnames)
|
if (proc->argnames)
|
||||||
proc->argnames[i] = PLy_strdup(DatumGetCString(DirectFunctionCall1(textout, elems[i])));
|
proc->argnames[i] = PLy_strdup(TextDatumGetCString(elems[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1308,8 +1308,7 @@ PLy_procedure_create(HeapTuple procTup, Oid tgreloid, char *key)
|
|||||||
Anum_pg_proc_prosrc, &isnull);
|
Anum_pg_proc_prosrc, &isnull);
|
||||||
if (isnull)
|
if (isnull)
|
||||||
elog(ERROR, "null prosrc");
|
elog(ERROR, "null prosrc");
|
||||||
procSource = DatumGetCString(DirectFunctionCall1(textout,
|
procSource = TextDatumGetCString(prosrcdatum);
|
||||||
prosrcdatum));
|
|
||||||
|
|
||||||
PLy_procedure_compile(proc, procSource);
|
PLy_procedure_compile(proc, procSource);
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* pltcl.c - PostgreSQL support for Tcl as
|
* pltcl.c - PostgreSQL support for Tcl as
|
||||||
* procedural language (PL)
|
* procedural language (PL)
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/pl/tcl/pltcl.c,v 1.117 2007/11/15 21:14:46 momjian Exp $
|
* $PostgreSQL: pgsql/src/pl/tcl/pltcl.c,v 1.118 2008/03/25 22:42:46 tgl Exp $
|
||||||
*
|
*
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
@ -1298,8 +1298,7 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid)
|
|||||||
Anum_pg_proc_prosrc, &isnull);
|
Anum_pg_proc_prosrc, &isnull);
|
||||||
if (isnull)
|
if (isnull)
|
||||||
elog(ERROR, "null prosrc");
|
elog(ERROR, "null prosrc");
|
||||||
proc_source = DatumGetCString(DirectFunctionCall1(textout,
|
proc_source = TextDatumGetCString(prosrcdatum);
|
||||||
prosrcdatum));
|
|
||||||
UTF_BEGIN;
|
UTF_BEGIN;
|
||||||
Tcl_DStringAppend(&proc_internal_body, UTF_E2U(proc_source), -1);
|
Tcl_DStringAppend(&proc_internal_body, UTF_E2U(proc_source), -1);
|
||||||
UTF_END;
|
UTF_END;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $PostgreSQL: pgsql/src/test/regress/regress.c,v 1.70 2007/03/15 23:12:07 tgl Exp $
|
* $PostgreSQL: pgsql/src/test/regress/regress.c,v 1.71 2008/03/25 22:42:46 tgl Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
@ -556,16 +556,9 @@ ttdummy(PG_FUNCTION_ARGS)
|
|||||||
return PointerGetDatum(NULL);
|
return PointerGetDatum(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
newoff = DirectFunctionCall1(nextval, CStringGetTextDatum("ttdummy_seq"));
|
||||||
text *seqname = DatumGetTextP(DirectFunctionCall1(textin,
|
/* nextval now returns int64; coerce down to int32 */
|
||||||
CStringGetDatum("ttdummy_seq")));
|
newoff = Int32GetDatum((int32) DatumGetInt64(newoff));
|
||||||
|
|
||||||
newoff = DirectFunctionCall1(nextval,
|
|
||||||
PointerGetDatum(seqname));
|
|
||||||
/* nextval now returns int64; coerce down to int32 */
|
|
||||||
newoff = Int32GetDatum((int32) DatumGetInt64(newoff));
|
|
||||||
pfree(seqname);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Connect to SPI manager */
|
/* Connect to SPI manager */
|
||||||
if ((ret = SPI_connect()) < 0)
|
if ((ret = SPI_connect()) < 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user