Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit30f6094

Browse files
committed
Add binary I/O routines for a bunch more datatypes. Still a few to go,
but that was enough tedium for one day. Along the way, move the fewsupport routines for types xid and cid into a more logical place.
1 parentb028327 commit30f6094

File tree

25 files changed

+1133
-216
lines changed

25 files changed

+1133
-216
lines changed

‎src/backend/access/transam/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
# Makefile for access/transam
55
#
66
# IDENTIFICATION
7-
# $Header: /cvsroot/pgsql/src/backend/access/transam/Makefile,v 1.15 2001/08/25 18:52:41 tgl Exp $
7+
# $Header: /cvsroot/pgsql/src/backend/access/transam/Makefile,v 1.16 2003/05/12 23:08:50 tgl Exp $
88
#
99
#-------------------------------------------------------------------------
1010

1111
subdir = src/backend/access/transam
1212
top_builddir = ../../../..
1313
include$(top_builddir)/src/Makefile.global
1414

15-
OBJS = clog.o transam.o varsup.o xact.oxid.oxlog.o xlogutils.o rmgr.o
15+
OBJS = clog.o transam.o varsup.o xact.o xlog.o xlogutils.o rmgr.o
1616

1717
all: SUBSYS.o
1818

‎src/backend/access/transam/xid.c

Lines changed: 0 additions & 72 deletions
This file was deleted.

‎src/backend/commands/user.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Header: /cvsroot/pgsql/src/backend/commands/user.c,v 1.116 2003/01/27 00:47:37 tgl Exp $
9+
* $Header: /cvsroot/pgsql/src/backend/commands/user.c,v 1.117 2003/05/12 23:08:50 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -324,7 +324,7 @@ write_user_file(Relation urel)
324324
if (isnull)
325325
valuntil=pstrdup("");
326326
else
327-
valuntil=DatumGetCString(DirectFunctionCall1(nabstimeout,datum));
327+
valuntil=DatumGetCString(DirectFunctionCall1(abstimeout,datum));
328328

329329
/*
330330
* Check for illegal characters in the username and password.
@@ -649,7 +649,7 @@ CreateUser(CreateUserStmt *stmt)
649649

650650
if (validUntil)
651651
new_record[Anum_pg_shadow_valuntil-1]=
652-
DirectFunctionCall1(nabstimein,CStringGetDatum(validUntil));
652+
DirectFunctionCall1(abstimein,CStringGetDatum(validUntil));
653653
else
654654
new_record_nulls[Anum_pg_shadow_valuntil-1]='n';
655655

@@ -851,7 +851,7 @@ AlterUser(AlterUserStmt *stmt)
851851
if (validUntil)
852852
{
853853
new_record[Anum_pg_shadow_valuntil-1]=
854-
DirectFunctionCall1(nabstimein,CStringGetDatum(validUntil));
854+
DirectFunctionCall1(abstimein,CStringGetDatum(validUntil));
855855
new_record_repl[Anum_pg_shadow_valuntil-1]='r';
856856
}
857857

‎src/backend/libpq/crypt.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
1010
* Portions Copyright (c) 1994, Regents of the University of California
1111
*
12-
* $Header: /cvsroot/pgsql/src/backend/libpq/crypt.c,v 1.52 2003/04/17 22:26:01 tgl Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/libpq/crypt.c,v 1.53 2003/05/12 23:08:50 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -145,7 +145,7 @@ md5_crypt_verify(const Port *port, const char *user, char *client_pass)
145145
if (!valuntil)
146146
vuntil=INVALID_ABSTIME;
147147
else
148-
vuntil=DatumGetAbsoluteTime(DirectFunctionCall1(nabstimein,
148+
vuntil=DatumGetAbsoluteTime(DirectFunctionCall1(abstimein,
149149
CStringGetDatum(valuntil)));
150150
current=GetCurrentAbsoluteTime();
151151
if (vuntil!=INVALID_ABSTIME&&vuntil<current)

‎src/backend/utils/adt/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#
22
# Makefile for utils/adt
33
#
4-
# $Header: /cvsroot/pgsql/src/backend/utils/adt/Makefile,v 1.54 2003/04/08 23:20:02 tgl Exp $
4+
# $Header: /cvsroot/pgsql/src/backend/utils/adt/Makefile,v 1.55 2003/05/12 23:08:50 tgl Exp $
55
#
66

77
subdir = src/backend/utils/adt
@@ -21,7 +21,7 @@ OBJS = acl.o arrayfuncs.o array_userfuncs.o arrayutils.o bool.o \
2121
misc.o nabstime.o name.o not_in.o numeric.o numutils.o\
2222
oid.o oracle_compat.o pseudotypes.o\
2323
regexp.o regproc.o ruleutils.o selfuncs.o sets.o\
24-
tid.o timestamp.o varbit.o varchar.o varlena.o version.o\
24+
tid.o timestamp.o varbit.o varchar.o varlena.o version.oxid.o\
2525
network.o mac.o inet_net_ntop.o inet_net_pton.o\
2626
ri_triggers.o pg_lzcompress.o pg_locale.o formatting.o\
2727
ascii.o quote.o pgstatfuncs.o encode.o

‎src/backend/utils/adt/bool.c

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/bool.c,v 1.26 2002/06/20 20:29:36 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/bool.c,v 1.27 2003/05/12 23:08:50 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
1515

1616
#include"postgres.h"
1717

18+
#include"libpq/pqformat.h"
1819
#include"utils/builtins.h"
1920

2021
/*****************************************************************************
@@ -94,6 +95,36 @@ boolout(PG_FUNCTION_ARGS)
9495
PG_RETURN_CSTRING(result);
9596
}
9697

98+
/*
99+
*boolrecv- converts external binary format to bool
100+
*
101+
* The external representation is one byte. Any nonzero value is taken
102+
* as "true".
103+
*/
104+
Datum
105+
boolrecv(PG_FUNCTION_ARGS)
106+
{
107+
StringInfobuf= (StringInfo)PG_GETARG_POINTER(0);
108+
intext;
109+
110+
ext=pq_getmsgbyte(buf);
111+
PG_RETURN_BOOL((ext!=0) ? true : false);
112+
}
113+
114+
/*
115+
*boolsend- converts bool to binary format
116+
*/
117+
Datum
118+
boolsend(PG_FUNCTION_ARGS)
119+
{
120+
boolarg1=PG_GETARG_BOOL(0);
121+
StringInfoDatabuf;
122+
123+
pq_begintypsend(&buf);
124+
pq_sendbyte(&buf,arg1 ?1 :0);
125+
PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
126+
}
127+
97128

98129
/*****************************************************************************
99130
* PUBLIC ROUTINES *

‎src/backend/utils/adt/char.c

Lines changed: 33 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
/*-------------------------------------------------------------------------
22
*
33
* char.c
4-
* Functions for the built-in type "char".
5-
*Functions forthebuilt-in type "cid" (what's that doing here?)
4+
* Functions for the built-in type "char" (not to be confused with
5+
*bpchar, which istheSQL CHAR(n) type).
66
*
77
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/char.c,v 1.34 2003/03/11 21:01:33 tgl Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/char.c,v 1.35 2003/05/12 23:08:50 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
1616
#include"postgres.h"
1717

18+
#include"libpq/pqformat.h"
1819
#include"utils/builtins.h"
1920

2021
/*****************************************************************************
@@ -52,6 +53,35 @@ charout(PG_FUNCTION_ARGS)
5253
PG_RETURN_CSTRING(result);
5354
}
5455

56+
/*
57+
*charrecv- converts external binary format to char
58+
*
59+
* The external representation is one byte, with no character set
60+
* conversion. This is somewhat dubious, perhaps, but in many
61+
* cases people use char for a 1-byte binary type.
62+
*/
63+
Datum
64+
charrecv(PG_FUNCTION_ARGS)
65+
{
66+
StringInfobuf= (StringInfo)PG_GETARG_POINTER(0);
67+
68+
PG_RETURN_CHAR(pq_getmsgbyte(buf));
69+
}
70+
71+
/*
72+
*charsend- converts char to binary format
73+
*/
74+
Datum
75+
charsend(PG_FUNCTION_ARGS)
76+
{
77+
chararg1=PG_GETARG_CHAR(0);
78+
StringInfoDatabuf;
79+
80+
pq_begintypsend(&buf);
81+
pq_sendbyte(&buf,arg1);
82+
PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
83+
}
84+
5585
/*****************************************************************************
5686
* PUBLIC ROUTINES *
5787
*****************************************************************************/
@@ -196,51 +226,3 @@ char_text(PG_FUNCTION_ARGS)
196226

197227
PG_RETURN_TEXT_P(result);
198228
}
199-
200-
201-
/*****************************************************************************
202-
* USER I/O ROUTINES *
203-
*****************************************************************************/
204-
205-
/*
206-
*cidin- converts CommandId to internal representation.
207-
*/
208-
Datum
209-
cidin(PG_FUNCTION_ARGS)
210-
{
211-
char*s=PG_GETARG_CSTRING(0);
212-
CommandIdc;
213-
214-
c=atoi(s);
215-
216-
/* XXX assume that CommandId is 32 bits... */
217-
PG_RETURN_INT32((int32)c);
218-
}
219-
220-
/*
221-
*cidout- converts a cid to external representation.
222-
*/
223-
Datum
224-
cidout(PG_FUNCTION_ARGS)
225-
{
226-
/* XXX assume that CommandId is 32 bits... */
227-
CommandIdc=PG_GETARG_INT32(0);
228-
char*result= (char*)palloc(16);
229-
230-
sprintf(result,"%u", (unsignedint)c);
231-
PG_RETURN_CSTRING(result);
232-
}
233-
234-
/*****************************************************************************
235-
* PUBLIC ROUTINES *
236-
*****************************************************************************/
237-
238-
Datum
239-
cideq(PG_FUNCTION_ARGS)
240-
{
241-
/* XXX assume that CommandId is 32 bits... */
242-
CommandIdarg1=PG_GETARG_INT32(0);
243-
CommandIdarg2=PG_GETARG_INT32(1);
244-
245-
PG_RETURN_BOOL(arg1==arg2);
246-
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp