Skip to content

Commit a647e30

Browse files
committed
New patch with corrected README attached.
Also quickly added mention that it may be a qualified schema name. Rod Taylor
1 parent ef2ba42 commit a647e30

File tree

18 files changed

+146
-30
lines changed

18 files changed

+146
-30
lines changed

contrib/pgstattuple/README.pgstattuple

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pgstattuple README 2002/08/29 Tatsuo Ishii
88

99
test=# \x
1010
Expanded display is on.
11-
test=# select * from pgstattuple('pg_proc');
11+
test=# select * from pgstattuple('pg_catalog.pg_proc');
1212
-[ RECORD 1 ]------+-------
1313
table_len | 458752
1414
tuple_count | 1470
@@ -45,9 +45,14 @@ free_percent -- free space in %
4545

4646
CREATE OR REPLACE FUNCTION pgstattuple(text) RETURNS pgstattuple_type
4747
AS 'MODULE_PATHNAME', 'pgstattuple'
48-
LANGUAGE 'c' WITH (isstrict);
48+
LANGUAGE 'c' STRICT;
4949

50-
The argument is the table name. Note that pgstattuple only returns
50+
CREATE OR REPLACE FUNCTION pgstattuple(oid) RETURNS pgstattuple_type
51+
AS 'MODULE_PATHNAME', 'pgstattuplebyid'
52+
LANGUAGE 'c' STRICT;
53+
54+
The argument is the table name (optionally it may be qualified)
55+
or the OID of the table. Note that pgstattuple only returns
5156
one row.
5257

5358
4. Notes

contrib/pgstattuple/pgstattuple.c

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* $Header: /cvsroot/pgsql/contrib/pgstattuple/pgstattuple.c,v 1.9 2002/09/04 20:31:08 momjian Exp $
2+
* $Header: /cvsroot/pgsql/contrib/pgstattuple/pgstattuple.c,v 1.10 2003/06/12 08:02:53 momjian Exp $
33
*
44
* Copyright (c) 2001,2002 Tatsuo Ishii
55
*
@@ -33,8 +33,12 @@
3333

3434

3535
PG_FUNCTION_INFO_V1(pgstattuple);
36+
PG_FUNCTION_INFO_V1(pgstattuplebyid);
3637

3738
extern Datum pgstattuple(PG_FUNCTION_ARGS);
39+
extern Datum pgstattuplebyid(PG_FUNCTION_ARGS);
40+
41+
static Datum pgstattuple_real(Relation rel);
3842

3943
/* ----------
4044
* pgstattuple:
@@ -46,7 +50,7 @@ extern Datum pgstattuple(PG_FUNCTION_ARGS);
4650
* ----------
4751
*/
4852

49-
#define DUMMY_TUPLE "pgstattuple_type"
53+
#define DUMMY_TUPLE "public.pgstattuple_type"
5054
#define NCOLUMNS 9
5155
#define NCHARS 32
5256

@@ -56,6 +60,41 @@ pgstattuple(PG_FUNCTION_ARGS)
5660
text *relname = PG_GETARG_TEXT_P(0);
5761
RangeVar *relrv;
5862
Relation rel;
63+
Datum result;
64+
65+
/* open relation */
66+
relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname,
67+
"pgstattuple"));
68+
rel = heap_openrv(relrv, AccessShareLock);
69+
70+
result = pgstattuple_real(rel);
71+
72+
PG_RETURN_DATUM(result);
73+
}
74+
75+
Datum
76+
pgstattuplebyid(PG_FUNCTION_ARGS)
77+
{
78+
Oid relid = PG_GETARG_OID(0);
79+
Relation rel;
80+
Datum result;
81+
82+
/* open relation */
83+
rel = heap_open(relid, AccessShareLock);
84+
85+
result = pgstattuple_real(rel);
86+
87+
PG_RETURN_DATUM(result);
88+
}
89+
90+
/*
91+
* pgstattuple_real
92+
*
93+
* The real work occurs here
94+
*/
95+
static Datum
96+
pgstattuple_real(Relation rel)
97+
{
5998
HeapScanDesc scan;
6099
HeapTuple tuple;
61100
BlockNumber nblocks;
@@ -92,11 +131,6 @@ pgstattuple(PG_FUNCTION_ARGS)
92131
*/
93132
attinmeta = TupleDescGetAttInMetadata(tupdesc);
94133

95-
/* open relation */
96-
relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname,
97-
"pgstattuple"));
98-
rel = heap_openrv(relrv, AccessShareLock);
99-
100134
nblocks = RelationGetNumberOfBlocks(rel);
101135
scan = heap_beginscan(rel, SnapshotAny, 0, NULL);
102136

@@ -187,5 +221,5 @@ pgstattuple(PG_FUNCTION_ARGS)
187221
pfree(values[i]);
188222
pfree(values);
189223

190-
PG_RETURN_DATUM(result);
224+
return(result);
191225
}

contrib/pgstattuple/pgstattuple.sql.in

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,9 @@ CREATE TYPE pgstattuple_type AS (
1717
CREATE OR REPLACE FUNCTION pgstattuple(text)
1818
RETURNS pgstattuple_type
1919
AS 'MODULE_PATHNAME', 'pgstattuple'
20-
LANGUAGE 'C' WITH (isstrict);
20+
LANGUAGE 'C' STRICT;
21+
22+
CREATE OR REPLACE FUNCTION pgstattuple(oid)
23+
RETURNS pgstattuple_type
24+
AS 'MODULE_PATHNAME', 'pgstattuplebyid'
25+
LANGUAGE 'C' STRICT;

src/backend/libpq/ip.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/libpq/ip.c,v 1.12 2003/06/12 07:36:51 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/libpq/ip.c,v 1.13 2003/06/12 08:02:53 momjian Exp $
1212
*
1313
* This file and the IPV6 implementation were initially provided by
1414
* Nigel Kukard <nkukard@lbsd.net>, Linux Based Systems Design
@@ -20,6 +20,8 @@
2020
/* This is intended to be used in both frontend and backend, so use c.h */
2121
#include "c.h"
2222

23+
#if !defined(_MSC_VER) && !defined(__BORLANDC__)
24+
2325
#include <errno.h>
2426
#include <unistd.h>
2527
#include <sys/types.h>
@@ -33,6 +35,8 @@
3335
#include <arpa/inet.h>
3436
#include <sys/file.h>
3537

38+
#endif
39+
3640
#include "libpq/ip.h"
3741

3842

src/backend/utils/mb/encnames.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Encoding names and routines for work with it. All
33
* in this file is shared bedween FE and BE.
44
*
5-
* $Id: encnames.c,v 1.13 2003/05/15 16:35:29 momjian Exp $
5+
* $Id: encnames.c,v 1.14 2003/06/12 08:02:53 momjian Exp $
66
*/
77
#ifdef FRONTEND
88
#include "postgres_fe.h"
@@ -13,7 +13,9 @@
1313
#include "utils/builtins.h"
1414
#endif
1515

16+
#if !defined(_MSC_VER) && !defined(__BORLANDC__)
1617
#include <unistd.h>
18+
#endif
1719

1820
#include "mb/pg_wchar.h"
1921
#include <ctype.h>

src/include/c.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
1313
* Portions Copyright (c) 1994, Regents of the University of California
1414
*
15-
* $Id: c.h,v 1.147 2003/05/16 01:57:51 momjian Exp $
15+
* $Id: c.h,v 1.148 2003/06/12 08:02:56 momjian Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -73,7 +73,7 @@
7373
#include <SupportDefs.h>
7474
#endif
7575

76-
#ifdef WIN32
76+
#if defined(WIN32) && !defined(_MSC_VER) && !defined(__BORLANDC__)
7777
/* We have to redefine some system functions after they are included above */
7878
#include "pg_config_os.h"
7979
#endif

src/include/getaddrinfo.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,17 @@
1616
*
1717
* Copyright (c) 2003, PostgreSQL Global Development Group
1818
*
19-
* $Id: getaddrinfo.h,v 1.3 2003/06/12 07:36:51 momjian Exp $
19+
* $Id: getaddrinfo.h,v 1.4 2003/06/12 08:02:56 momjian Exp $
2020
*
2121
*-------------------------------------------------------------------------
2222
*/
2323
#ifndef GETADDRINFO_H
2424
#define GETADDRINFO_H
2525

26+
#if !defined(WIN32) || (!defined(_MSC_VER) && !defined(__BORLANDC__))
2627
#include <sys/socket.h>
2728
#include <netdb.h>
29+
#endif
2830

2931

3032
#ifndef HAVE_STRUCT_ADDRINFO

src/include/pg_config.h.win32

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
#define HAVE_ATEXIT
2222
#define HAVE_MEMMOVE
2323

24+
#ifdef __BORLANDC__
25+
#define HAVE_RANDOM
26+
#endif
27+
2428
/* use _snprintf instead of snprintf */
2529
#define HAVE_DECL_SNPRINTF 1
2630
#define snprintf _snprintf

src/include/port.h

Lines changed: 3 additions & 1 deletion
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-
* $Id: port.h,v 1.3 2003/05/16 04:59:22 momjian Exp $
9+
* $Id: port.h,v 1.4 2003/06/12 08:02:56 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -76,8 +76,10 @@ extern double rint(double x);
7676
#endif
7777

7878
#ifndef HAVE_INET_ATON
79+
#if !defined(WIN32) || (!defined(_MSC_VER) && !defined(__BORLANDC__))
7980
# include <netinet/in.h>
8081
# include <arpa/inet.h>
82+
#endif
8183
extern int inet_aton(const char *cp, struct in_addr * addr);
8284
#endif
8385

src/interfaces/libpq/bcc32.mak

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# and a Win32 dynamic library libpq.dll with import library libpqdll.lib
55

66
# Borland C++ base install directory goes here
7-
BCB=d:\Borland\Bcc55
7+
# BCB=d:\Borland\Bcc55
88

99
!MESSAGE Building the Win32 DLL and Static Library...
1010
!MESSAGE
@@ -63,8 +63,13 @@ LIB32=tlib.exe
6363
LIB32_FLAGS=
6464
LIB32_OBJS= \
6565
"$(OUTDIR)\win32.obj" \
66+
"$(INTDIR)\getaddrinfo.obj" \
67+
"$(INTDIR)\inet_aton.obj" \
68+
"$(INTDIR)\crypt.obj" \
69+
"$(INTDIR)\path.obj" \
6670
"$(INTDIR)\dllist.obj" \
6771
"$(INTDIR)\md5.obj" \
72+
"$(INTDIR)\ip.obj" \
6873
"$(INTDIR)\fe-auth.obj" \
6974
"$(INTDIR)\fe-connect.obj" \
7075
"$(INTDIR)\fe-exec.obj" \
@@ -77,7 +82,7 @@ LIB32_OBJS= \
7782
"$(INTDIR)\encnames.obj"
7883

7984
RSC=brcc32.exe
80-
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\libpq.res"
85+
RSC_PROJ=-l 0x409 -i$(BCB)\include -fo"$(INTDIR)\libpq.res"
8186

8287
LINK32=ilink32.exe
8388
LINK32_FLAGS = -Gn -L$(BCB)\lib;$(INTDIR); -x -Tpd -v
@@ -86,15 +91,20 @@ LINK32_OBJS= "$(INTDIR)\libpqdll.obj"
8691
# ---------------------------------------------------------------------------
8792

8893
.path.obj = $(INTDIR)
89-
.path.c = .;..\..\backend\libpq;..\..\backend\lib;..\..\backend\utils\mb
94+
.path.c = .;..\..\port;..\..\backend\libpq;..\..\backend\lib;..\..\backend\utils\mb
9095

9196
# ---------------------------------------------------------------------------
9297

9398
ALL: "$(OUTDIR)" "$(OUTDIR)\blibpq.dll" "$(OUTDIR)\blibpq.lib"
9499

95100
CLEAN :
101+
-@erase "$(INTDIR)\getaddrinfo.obj"
102+
-@erase "$(INTDIR)\inet_aton.obj"
103+
-@erase "$(INTDIR)\crypt.obj"
104+
-@erase "$(INTDIR)\path.obj"
96105
-@erase "$(INTDIR)\dllist.obj"
97106
-@erase "$(INTDIR)\md5.obj"
107+
-@erase "$(INTDIR)\ip.obj"
98108
-@erase "$(INTDIR)\fe-auth.obj"
99109
-@erase "$(INTDIR)\fe-connect.obj"
100110
-@erase "$(INTDIR)\fe-exec.obj"
@@ -125,7 +135,7 @@ CLEAN :
125135
"$(OUTDIR)\blibpq.lib" import32.lib cw32mti.lib, +
126136
blibpqdll.def,"$(INTDIR)\libpq.res"
127137
!
128-
implib -a "$(OUTDIR)\blibpqdll.lib" blibpqdll.def $@
138+
implib -w "$(OUTDIR)\blibpqdll.lib" blibpqdll.def $@
129139

130140
"$(INTDIR)\libpq.res" : "$(INTDIR)" libpq.rc
131141
$(RSC) $(RSC_PROJ) libpq.rc

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy