Skip to content

Commit ec3da33

Browse files
committed
Apply 1C patches
1 parent 2de2911 commit ec3da33

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+10031
-53
lines changed

contrib/Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,14 @@ SUBDIRS = \
6161
sr_plan \
6262
pg_arman \
6363
pg_pathman \
64-
shared_ispell
64+
shared_ispell \
65+
vacuumlo \
66+
mchar \
67+
fulleq \
68+
fasttrun \
69+
online_analyze \
70+
plantuner
71+
6572

6673
ifeq ($(with_openssl),yes)
6774
SUBDIRS += sslinfo

contrib/fasttrun/Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
MODULE_big = fasttrun
2+
OBJS = fasttrun.o
3+
DATA_built = fasttrun.sql
4+
DOCS = README.fasttrun
5+
REGRESS = fasttrun
6+
7+
ifdef USE_PGXS
8+
PGXS := $(shell pg_config --pgxs)
9+
include $(PGXS)
10+
else
11+
subdir = contrib/fasttrun
12+
top_builddir = ../..
13+
include $(top_builddir)/src/Makefile.global
14+
include $(top_srcdir)/contrib/contrib-global.mk
15+
endif

contrib/fasttrun/README.fasttrun

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
select fasttruncate('TABLE_NAME');
2+
3+
Function truncates the temporary table and doesn't grow
4+
pg_class size.
5+
6+
Warning: function isn't transaction safe!
7+
8+
For tests:
9+
create or replace function f() returns void as $$
10+
begin
11+
for i in 1..1000
12+
loop
13+
PERFORM fasttruncate('tt1');
14+
end loop;
15+
end;
16+
$$ language plpgsql;
17+
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
\set ECHO none
2+
create table persist ( a int );
3+
insert into persist values (1);
4+
select fasttruncate('persist');
5+
ERROR: Relation isn't a temporary table
6+
insert into persist values (2);
7+
select * from persist order by a;
8+
a
9+
---
10+
1
11+
2
12+
(2 rows)
13+
14+
create temp table temp1 (a int);
15+
insert into temp1 values (1);
16+
BEGIN;
17+
create temp table temp2 (a int);
18+
insert into temp2 values (1);
19+
select * from temp1 order by a;
20+
a
21+
---
22+
1
23+
(1 row)
24+
25+
select * from temp2 order by a;
26+
a
27+
---
28+
1
29+
(1 row)
30+
31+
insert into temp1 (select * from generate_series(1,10000));
32+
insert into temp2 (select * from generate_series(1,11000));
33+
analyze temp2;
34+
select relname, relpages>0, reltuples>0 from pg_class where relname in ('temp1', 'temp2') order by relname;
35+
relname | ?column? | ?column?
36+
---------+----------+----------
37+
temp1 | f | f
38+
temp2 | t | t
39+
(2 rows)
40+
41+
select fasttruncate('temp1');
42+
fasttruncate
43+
--------------
44+
45+
(1 row)
46+
47+
select fasttruncate('temp2');
48+
fasttruncate
49+
--------------
50+
51+
(1 row)
52+
53+
insert into temp1 values (-2);
54+
insert into temp2 values (-2);
55+
select * from temp1 order by a;
56+
a
57+
----
58+
-2
59+
(1 row)
60+
61+
select * from temp2 order by a;
62+
a
63+
----
64+
-2
65+
(1 row)
66+
67+
COMMIT;
68+
select * from temp1 order by a;
69+
a
70+
----
71+
-2
72+
(1 row)
73+
74+
select * from temp2 order by a;
75+
a
76+
----
77+
-2
78+
(1 row)
79+
80+
select relname, relpages>0, reltuples>0 from pg_class where relname in ('temp1', 'temp2') order by relname;
81+
relname | ?column? | ?column?
82+
---------+----------+----------
83+
temp1 | f | f
84+
temp2 | f | f
85+
(2 rows)
86+
87+
select fasttruncate('temp1');
88+
fasttruncate
89+
--------------
90+
91+
(1 row)
92+
93+
select fasttruncate('temp2');
94+
fasttruncate
95+
--------------
96+
97+
(1 row)
98+
99+
select * from temp1 order by a;
100+
a
101+
---
102+
(0 rows)
103+
104+
select * from temp2 order by a;
105+
a
106+
---
107+
(0 rows)
108+
109+
select relname, relpages>0, reltuples>0 from pg_class where relname in ('temp1', 'temp2') order by relname;
110+
relname | ?column? | ?column?
111+
---------+----------+----------
112+
temp1 | f | f
113+
temp2 | f | f
114+
(2 rows)
115+

contrib/fasttrun/fasttrun.c

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#include "postgres.h"
2+
3+
#include "access/genam.h"
4+
#include "access/heapam.h"
5+
#include "miscadmin.h"
6+
#include "storage/lmgr.h"
7+
#include "storage/bufmgr.h"
8+
#include "catalog/namespace.h"
9+
#include "utils/lsyscache.h"
10+
#include "utils/builtins.h"
11+
#include <fmgr.h>
12+
#include <funcapi.h>
13+
#include <access/heapam.h>
14+
#include <catalog/pg_type.h>
15+
#include <catalog/heap.h>
16+
#include <commands/vacuum.h>
17+
18+
#ifdef PG_MODULE_MAGIC
19+
PG_MODULE_MAGIC;
20+
#endif
21+
22+
PG_FUNCTION_INFO_V1(fasttruncate);
23+
Datum fasttruncate(PG_FUNCTION_ARGS);
24+
Datum
25+
fasttruncate(PG_FUNCTION_ARGS) {
26+
text *name=PG_GETARG_TEXT_P(0);
27+
char *relname;
28+
List *relname_list;
29+
RangeVar *relvar;
30+
Oid relOid;
31+
Relation rel;
32+
bool makeanalyze = false;
33+
34+
relname = palloc( VARSIZE(name) + 1);
35+
memcpy(relname, VARDATA(name), VARSIZE(name)-VARHDRSZ);
36+
relname[ VARSIZE(name)-VARHDRSZ ] = '\0';
37+
38+
relname_list = stringToQualifiedNameList(relname);
39+
relvar = makeRangeVarFromNameList(relname_list);
40+
relOid = RangeVarGetRelid(relvar, AccessExclusiveLock, false);
41+
42+
if ( get_rel_relkind(relOid) != RELKIND_RELATION )
43+
elog(ERROR,"Relation isn't a ordinary table");
44+
45+
rel = heap_open(relOid, NoLock);
46+
47+
if ( !isTempNamespace(get_rel_namespace(relOid)) )
48+
elog(ERROR,"Relation isn't a temporary table");
49+
50+
heap_truncate(list_make1_oid(relOid));
51+
52+
if ( rel->rd_rel->relpages > 0 || rel->rd_rel->reltuples > 0 )
53+
makeanalyze = true;
54+
55+
/*
56+
* heap_truncate doesn't unlock the table,
57+
* so we should unlock it.
58+
*/
59+
60+
heap_close(rel, AccessExclusiveLock);
61+
62+
if ( makeanalyze ) {
63+
VacuumParams params;
64+
65+
params.freeze_min_age = -1;
66+
params.freeze_table_age = -1;
67+
params.multixact_freeze_min_age = -1;
68+
params.multixact_freeze_table_age = -1;
69+
params.is_wraparound = false;
70+
params.log_min_duration = -1;
71+
72+
vacuum(VACOPT_ANALYZE, NULL, relOid, &params, NULL,
73+
GetAccessStrategy(BAS_VACUUM), false);
74+
}
75+
76+
PG_RETURN_VOID();
77+
}

contrib/fasttrun/fasttrun.sql.in

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
BEGIN;
2+
3+
4+
CREATE OR REPLACE FUNCTION fasttruncate(text)
5+
RETURNS void AS 'MODULE_PATHNAME'
6+
LANGUAGE C RETURNS NULL ON NULL INPUT VOLATILE;
7+
8+
COMMIT;

contrib/fasttrun/sql/fasttrun.sql

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
\set ECHO none
2+
\i fasttrun.sql
3+
\set ECHO all
4+
5+
create table persist ( a int );
6+
insert into persist values (1);
7+
select fasttruncate('persist');
8+
insert into persist values (2);
9+
select * from persist order by a;
10+
11+
create temp table temp1 (a int);
12+
insert into temp1 values (1);
13+
14+
BEGIN;
15+
16+
create temp table temp2 (a int);
17+
insert into temp2 values (1);
18+
19+
select * from temp1 order by a;
20+
select * from temp2 order by a;
21+
22+
insert into temp1 (select * from generate_series(1,10000));
23+
insert into temp2 (select * from generate_series(1,11000));
24+
25+
analyze temp2;
26+
select relname, relpages>0, reltuples>0 from pg_class where relname in ('temp1', 'temp2') order by relname;
27+
28+
select fasttruncate('temp1');
29+
select fasttruncate('temp2');
30+
31+
insert into temp1 values (-2);
32+
insert into temp2 values (-2);
33+
34+
select * from temp1 order by a;
35+
select * from temp2 order by a;
36+
37+
COMMIT;
38+
39+
select * from temp1 order by a;
40+
select * from temp2 order by a;
41+
42+
select relname, relpages>0, reltuples>0 from pg_class where relname in ('temp1', 'temp2') order by relname;
43+
44+
select fasttruncate('temp1');
45+
select fasttruncate('temp2');
46+
47+
select * from temp1 order by a;
48+
select * from temp2 order by a;
49+
50+
select relname, relpages>0, reltuples>0 from pg_class where relname in ('temp1', 'temp2') order by relname;

contrib/fulleq/Makefile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
MODULE_big = fulleq
2+
OBJS = fulleq.o
3+
DATA_built = fulleq.sql
4+
DOCS = README.fulleq
5+
REGRESS = fulleq
6+
7+
ARGTYPE = bool bytea char name int8 int2 int2vector int4 text \
8+
oid xid cid oidvector float4 float8 abstime reltime macaddr \
9+
inet cidr varchar date time timestamp timestamptz \
10+
interval timetz
11+
12+
EXTRA_CLEAN = fulleq.sql.in
13+
14+
ifdef USE_PGXS
15+
PGXS := $(shell pg_config --pgxs)
16+
include $(PGXS)
17+
else
18+
subdir = contrib/fulleq
19+
top_builddir = ../..
20+
include $(top_builddir)/src/Makefile.global
21+
include $(top_srcdir)/contrib/contrib-global.mk
22+
endif
23+
24+
fulleq.sql.in: fulleq.sql.in.in
25+
echo 'BEGIN;' > $@
26+
echo 'SET search_path = public;' >> $@
27+
for type in $(ARGTYPE); \
28+
do \
29+
sed -e "s/ARGTYPE/$$type/g" < $< >> $@; \
30+
done
31+
echo 'COMMIT;' >> $@
32+

contrib/fulleq/README.fulleq

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Introduce operator == which returns true when
2+
operands are equal or both are nulls.
3+

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