Skip to content

Commit 3a43b15

Browse files
authored
Merge pull request IvorySQL#749 from bigplaice/ora_rowid
Oracle rowid feature
2 parents 0eb8c91 + 15dfd41 commit 3a43b15

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

+1950
-200
lines changed

contrib/amcheck/verify_heapam.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -956,6 +956,10 @@ check_tuple_header(HeapCheckContext *ctx)
956956
expected_hoff = MAXALIGN(SizeofHeapTupleHeader + BITMAPLEN(ctx->natts));
957957
else
958958
expected_hoff = MAXALIGN(SizeofHeapTupleHeader);
959+
960+
if (infomask & HEAP_HASROWID)
961+
expected_hoff = expected_hoff + sizeof(int64);
962+
959963
if (ctx->tuphdr->t_hoff != expected_hoff)
960964
{
961965
if ((infomask & HEAP_HASNULL) && ctx->natts == 1)

contrib/ivorysql_ora/Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,18 @@ DATA = ivorysql_ora--1.0.sql
3636

3737
all: gensql
3838

39+
install: install-data
40+
3941
clean: cleansql
4042

4143
# SQL(s) merge using perl
4244
gensql: gensql.pl
4345
$(PERL) $< gcc_build $(patsubst ivorysql_ora--%.sql, %, $(DATA))
4446

47+
# Preload the compatible oracle misc sql script
48+
install-data:
49+
$(INSTALL_DATA) $(srcdir)/preload_ora_misc.sql '$(DESTDIR)$(datadir)/preload_ora_misc.sql'
50+
4551
# Clean the generated SQL(s).
4652
cleansql:
4753
rm -f $(DATA)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
GRANT USAGE ON SCHEMA sys TO PUBLIC;
2+
SET search_path TO sys;
3+
4+
CREATE table dual (DUMMY pg_catalog.bpchar(1));
5+
insert into dual values('X');
6+
GRANT SELECT ON dual TO PUBLIC;
7+
8+
--
9+
-- ROWID type
10+
--
11+
CREATE TYPE sys.rowid AS(rowoid OID, rowno bigint);
12+
CREATE TYPE sys.urowid AS(rowoid OID, rowno bigint);
13+
14+
CREATE CAST (sys.rowid AS sys.urowid) WITH INOUT AS IMPLICIT;
15+
CREATE CAST (sys.urowid AS sys.rowid) WITH INOUT AS IMPLICIT;

contrib/ivorysql_ora/src/sysview/sysview--1.0.sql

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
GRANT USAGE ON SCHEMA sys TO PUBLIC;
2-
SET search_path TO sys;
3-
4-
CREATE table dual (DUMMY pg_catalog.bpchar(1));
5-
insert into dual values('X');
6-
GRANT SELECT ON dual TO PUBLIC;
7-
81
/*
92
* function which converts all-uppercase text to all-lowercase text
103
* and vice versa.

contrib/pageinspect/expected/ivy_page.out

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ SELECT unnest(raw_flags)
133133
HEAP_COMBOCID
134134
HEAP_HASEXTERNAL
135135
HEAP_HASNULL
136-
HEAP_HASOID_OLD
137136
HEAP_HASVARWIDTH
138137
HEAP_HOT_UPDATED
139138
HEAP_KEYS_UPDATED
@@ -149,7 +148,7 @@ SELECT unnest(raw_flags)
149148
HEAP_XMAX_LOCK_ONLY
150149
HEAP_XMIN_COMMITTED
151150
HEAP_XMIN_INVALID
152-
(19 rows)
151+
(18 rows)
153152

154153
SELECT unnest(combined_flags)
155154
FROM heap_tuple_infomask_flags(x'FFFF'::int, x'FFFF'::int) ORDER BY 1;

contrib/pageinspect/expected/page.out

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ SELECT unnest(raw_flags)
134134
HEAP_COMBOCID
135135
HEAP_HASEXTERNAL
136136
HEAP_HASNULL
137-
HEAP_HASOID_OLD
138137
HEAP_HASVARWIDTH
139138
HEAP_HOT_UPDATED
140139
HEAP_KEYS_UPDATED
@@ -150,7 +149,7 @@ SELECT unnest(raw_flags)
150149
HEAP_XMAX_LOCK_ONLY
151150
HEAP_XMIN_COMMITTED
152151
HEAP_XMIN_INVALID
153-
(19 rows)
152+
(18 rows)
154153

155154
SELECT unnest(combined_flags)
156155
FROM heap_tuple_infomask_flags(x'FFFF'::int, x'FFFF'::int) ORDER BY 1;

contrib/pageinspect/heapfuncs.c

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,6 @@
3838
#include "utils/builtins.h"
3939
#include "utils/rel.h"
4040

41-
/*
42-
* It's not supported to create tuples with oids anymore, but when pg_upgrade
43-
* was used to upgrade from an older version, tuples might still have an
44-
* oid. Seems worthwhile to display that.
45-
*/
46-
#define HeapTupleHeaderGetOidOld(tup) \
47-
( \
48-
((tup)->t_infomask & HEAP_HASOID_OLD) ? \
49-
*((Oid *) ((char *)(tup) + (tup)->t_hoff - sizeof(Oid))) \
50-
: \
51-
InvalidOid \
52-
)
53-
5441

5542
/*
5643
* bits_to_text
@@ -257,10 +244,7 @@ heap_page_items(PG_FUNCTION_ARGS)
257244
else
258245
nulls[11] = true;
259246

260-
if (tuphdr->t_infomask & HEAP_HASOID_OLD)
261-
values[12] = HeapTupleHeaderGetOidOld(tuphdr);
262-
else
263-
nulls[12] = true;
247+
nulls[12] = true;
264248
}
265249
else
266250
{
@@ -549,8 +533,6 @@ heap_tuple_infomask_flags(PG_FUNCTION_ARGS)
549533
flags[cnt++] = CStringGetTextDatum("HEAP_HASVARWIDTH");
550534
if ((t_infomask & HEAP_HASEXTERNAL) != 0)
551535
flags[cnt++] = CStringGetTextDatum("HEAP_HASEXTERNAL");
552-
if ((t_infomask & HEAP_HASOID_OLD) != 0)
553-
flags[cnt++] = CStringGetTextDatum("HEAP_HASOID_OLD");
554536
if ((t_infomask & HEAP_XMAX_KEYSHR_LOCK) != 0)
555537
flags[cnt++] = CStringGetTextDatum("HEAP_XMAX_KEYSHR_LOCK");
556538
if ((t_infomask & HEAP_COMBOCID) != 0)

contrib/tablefunc/expected/ivy_tablefunc.out

Lines changed: 42 additions & 42 deletions
Large diffs are not rendered by default.

contrib/tablefunc/sql/ivy_tablefunc.sql

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,28 @@ SELECT avg(normal_rand)::int, count(*) FROM normal_rand(-1, 250, 0.2);
1111
--
1212
-- crosstab()
1313
--
14-
CREATE TABLE ct(id int, rowclass text, rowid text, attribute text, val text);
14+
CREATE TABLE ct(id int, rowclass text, orarowid text, attribute text, val text);
1515
\copy ct from 'data/ct.data'
1616

17-
SELECT * FROM crosstab2('SELECT rowid, attribute, val FROM ct where rowclass = ''group1'' and (attribute = ''att2'' or attribute = ''att3'') ORDER BY 1,2;');
18-
SELECT * FROM crosstab3('SELECT rowid, attribute, val FROM ct where rowclass = ''group1'' and (attribute = ''att2'' or attribute = ''att3'') ORDER BY 1,2;');
19-
SELECT * FROM crosstab4('SELECT rowid, attribute, val FROM ct where rowclass = ''group1'' and (attribute = ''att2'' or attribute = ''att3'') ORDER BY 1,2;');
17+
SELECT * FROM crosstab2('SELECT orarowid, attribute, val FROM ct where rowclass = ''group1'' and (attribute = ''att2'' or attribute = ''att3'') ORDER BY 1,2;');
18+
SELECT * FROM crosstab3('SELECT orarowid, attribute, val FROM ct where rowclass = ''group1'' and (attribute = ''att2'' or attribute = ''att3'') ORDER BY 1,2;');
19+
SELECT * FROM crosstab4('SELECT orarowid, attribute, val FROM ct where rowclass = ''group1'' and (attribute = ''att2'' or attribute = ''att3'') ORDER BY 1,2;');
2020

21-
SELECT * FROM crosstab2('SELECT rowid, attribute, val FROM ct where rowclass = ''group1'' ORDER BY 1,2;');
22-
SELECT * FROM crosstab3('SELECT rowid, attribute, val FROM ct where rowclass = ''group1'' ORDER BY 1,2;');
23-
SELECT * FROM crosstab4('SELECT rowid, attribute, val FROM ct where rowclass = ''group1'' ORDER BY 1,2;');
21+
SELECT * FROM crosstab2('SELECT orarowid, attribute, val FROM ct where rowclass = ''group1'' ORDER BY 1,2;');
22+
SELECT * FROM crosstab3('SELECT orarowid, attribute, val FROM ct where rowclass = ''group1'' ORDER BY 1,2;');
23+
SELECT * FROM crosstab4('SELECT orarowid, attribute, val FROM ct where rowclass = ''group1'' ORDER BY 1,2;');
2424

25-
SELECT * FROM crosstab2('SELECT rowid, attribute, val FROM ct where rowclass = ''group2'' and (attribute = ''att1'' or attribute = ''att2'') ORDER BY 1,2;');
26-
SELECT * FROM crosstab3('SELECT rowid, attribute, val FROM ct where rowclass = ''group2'' and (attribute = ''att1'' or attribute = ''att2'') ORDER BY 1,2;');
27-
SELECT * FROM crosstab4('SELECT rowid, attribute, val FROM ct where rowclass = ''group2'' and (attribute = ''att1'' or attribute = ''att2'') ORDER BY 1,2;');
25+
SELECT * FROM crosstab2('SELECT orarowid, attribute, val FROM ct where rowclass = ''group2'' and (attribute = ''att1'' or attribute = ''att2'') ORDER BY 1,2;');
26+
SELECT * FROM crosstab3('SELECT orarowid, attribute, val FROM ct where rowclass = ''group2'' and (attribute = ''att1'' or attribute = ''att2'') ORDER BY 1,2;');
27+
SELECT * FROM crosstab4('SELECT orarowid, attribute, val FROM ct where rowclass = ''group2'' and (attribute = ''att1'' or attribute = ''att2'') ORDER BY 1,2;');
2828

29-
SELECT * FROM crosstab2('SELECT rowid, attribute, val FROM ct where rowclass = ''group2'' ORDER BY 1,2;');
30-
SELECT * FROM crosstab3('SELECT rowid, attribute, val FROM ct where rowclass = ''group2'' ORDER BY 1,2;');
31-
SELECT * FROM crosstab4('SELECT rowid, attribute, val FROM ct where rowclass = ''group2'' ORDER BY 1,2;');
29+
SELECT * FROM crosstab2('SELECT orarowid, attribute, val FROM ct where rowclass = ''group2'' ORDER BY 1,2;');
30+
SELECT * FROM crosstab3('SELECT orarowid, attribute, val FROM ct where rowclass = ''group2'' ORDER BY 1,2;');
31+
SELECT * FROM crosstab4('SELECT orarowid, attribute, val FROM ct where rowclass = ''group2'' ORDER BY 1,2;');
3232

33-
SELECT * FROM crosstab('SELECT rowid, attribute, val FROM ct where rowclass = ''group1'' ORDER BY 1,2;') AS c(rowid text, att1 text, att2 text);
34-
SELECT * FROM crosstab('SELECT rowid, attribute, val FROM ct where rowclass = ''group1'' ORDER BY 1,2;') AS c(rowid text, att1 text, att2 text, att3 text);
35-
SELECT * FROM crosstab('SELECT rowid, attribute, val FROM ct where rowclass = ''group1'' ORDER BY 1,2;') AS c(rowid text, att1 text, att2 text, att3 text, att4 text);
33+
SELECT * FROM crosstab('SELECT orarowid, attribute, val FROM ct where rowclass = ''group1'' ORDER BY 1,2;') AS c(rowid text, att1 text, att2 text);
34+
SELECT * FROM crosstab('SELECT orarowid, attribute, val FROM ct where rowclass = ''group1'' ORDER BY 1,2;') AS c(rowid text, att1 text, att2 text, att3 text);
35+
SELECT * FROM crosstab('SELECT orarowid, attribute, val FROM ct where rowclass = ''group1'' ORDER BY 1,2;') AS c(rowid text, att1 text, att2 text, att3 text, att4 text);
3636

3737
-- check it works with OUT parameters, too
3838

@@ -43,23 +43,23 @@ AS '$libdir/tablefunc','crosstab'
4343
LANGUAGE C STABLE STRICT;
4444
/
4545

46-
SELECT * FROM crosstab_out('SELECT rowid, attribute, val FROM ct where rowclass = ''group1'' ORDER BY 1,2;');
46+
SELECT * FROM crosstab_out('SELECT orarowid, attribute, val FROM ct where rowclass = ''group1'' ORDER BY 1,2;');
4747

4848
-- check error reporting
49-
SELECT * FROM crosstab('SELECT rowid, val FROM ct where rowclass = ''group1'' and (attribute = ''att2'' or attribute = ''att3'') ORDER BY 1,2;')
49+
SELECT * FROM crosstab('SELECT orarowid, val FROM ct where rowclass = ''group1'' and (attribute = ''att2'' or attribute = ''att3'') ORDER BY 1,2;')
5050
AS ct(row_name text, category_1 text, category_2 text);
51-
SELECT * FROM crosstab('SELECT rowid, attribute, val FROM ct where rowclass = ''group1'' and (attribute = ''att2'' or attribute = ''att3'') ORDER BY 1,2;')
51+
SELECT * FROM crosstab('SELECT orarowid, attribute, val FROM ct where rowclass = ''group1'' and (attribute = ''att2'' or attribute = ''att3'') ORDER BY 1,2;')
5252
AS ct(row_name text);
53-
SELECT * FROM crosstab('SELECT rowid, attribute, val FROM ct where rowclass = ''group1'' and (attribute = ''att2'' or attribute = ''att3'') ORDER BY 1,2;')
53+
SELECT * FROM crosstab('SELECT orarowid, attribute, val FROM ct where rowclass = ''group1'' and (attribute = ''att2'' or attribute = ''att3'') ORDER BY 1,2;')
5454
AS ct(row_name int, category_1 text, category_2 text);
55-
SELECT * FROM crosstab('SELECT rowid, attribute, val FROM ct where rowclass = ''group1'' and (attribute = ''att2'' or attribute = ''att3'') ORDER BY 1,2;')
55+
SELECT * FROM crosstab('SELECT orarowid, attribute, val FROM ct where rowclass = ''group1'' and (attribute = ''att2'' or attribute = ''att3'') ORDER BY 1,2;')
5656
AS ct(row_name text, category_1 text, category_2 int);
5757

5858
--
5959
-- hash based crosstab
6060
--
6161

62-
create table cth(id serial, rowid text, rowdt pg_catalog.timestamp, attribute text, val text);
62+
create table cth(id serial, orarowid text, rowdt pg_catalog.timestamp, attribute text, val text);
6363
insert into cth values(DEFAULT,'test1','01 Mar 2003','temperature','42');
6464
insert into cth values(DEFAULT,'test1','01 Mar 2003','test_result','PASS');
6565
-- the next line is intentionally left commented and is therefore a "missing" attribute
@@ -77,71 +77,71 @@ insert into cth values(DEFAULT,NULL,'25 Oct 2007','volts','1.41234');
7777

7878
-- return attributes as plain text
7979
SELECT * FROM crosstab(
80-
'SELECT rowid, rowdt, attribute, val FROM cth ORDER BY 1',
80+
'SELECT orarowid, rowdt, attribute, val FROM cth ORDER BY 1',
8181
'SELECT DISTINCT attribute FROM cth ORDER BY 1')
8282
AS c(rowid text, rowdt pg_catalog.timestamp, temperature text, test_result text, test_startdate text, volts text);
8383

8484
-- this time without rowdt
8585
SELECT * FROM crosstab(
86-
'SELECT rowid, attribute, val FROM cth ORDER BY 1',
86+
'SELECT orarowid, attribute, val FROM cth ORDER BY 1',
8787
'SELECT DISTINCT attribute FROM cth ORDER BY 1')
8888
AS c(rowid text, temperature text, test_result text, test_startdate text, volts text);
8989

9090
-- convert attributes to specific datatypes
9191
SELECT * FROM crosstab(
92-
'SELECT rowid, rowdt, attribute, val FROM cth ORDER BY 1',
92+
'SELECT orarowid, rowdt, attribute, val FROM cth ORDER BY 1',
9393
'SELECT DISTINCT attribute FROM cth ORDER BY 1')
9494
AS c(rowid text, rowdt pg_catalog.timestamp, temperature int4, test_result text, test_startdate pg_catalog.timestamp, volts float8);
9595

9696
-- source query and category query out of sync
9797
SELECT * FROM crosstab(
98-
'SELECT rowid, rowdt, attribute, val FROM cth ORDER BY 1',
98+
'SELECT orarowid, rowdt, attribute, val FROM cth ORDER BY 1',
9999
'SELECT DISTINCT attribute FROM cth WHERE attribute IN (''temperature'',''test_result'',''test_startdate'') ORDER BY 1')
100100
AS c(rowid text, rowdt pg_catalog.timestamp, temperature int4, test_result text, test_startdate pg_catalog.timestamp);
101101

102102
-- if category query generates no rows, get expected error
103103
SELECT * FROM crosstab(
104-
'SELECT rowid, rowdt, attribute, val FROM cth ORDER BY 1',
104+
'SELECT orarowid, rowdt, attribute, val FROM cth ORDER BY 1',
105105
'SELECT DISTINCT attribute FROM cth WHERE attribute = ''a'' ORDER BY 1')
106106
AS c(rowid text, rowdt pg_catalog.timestamp, temperature int4, test_result text, test_startdate pg_catalog.timestamp, volts float8);
107107

108108
-- if category query generates more than one column, get expected error
109109
SELECT * FROM crosstab(
110-
'SELECT rowid, rowdt, attribute, val FROM cth ORDER BY 1',
110+
'SELECT orarowid, rowdt, attribute, val FROM cth ORDER BY 1',
111111
'SELECT DISTINCT rowdt, attribute FROM cth ORDER BY 2')
112112
AS c(rowid text, rowdt pg_catalog.timestamp, temperature int4, test_result text, test_startdate pg_catalog.timestamp, volts float8);
113113

114114
-- if category query generates a NULL value, get expected error
115115
SELECT * FROM crosstab(
116-
'SELECT rowid, rowdt, attribute, val FROM cth ORDER BY 1',
116+
'SELECT orarowid, rowdt, attribute, val FROM cth ORDER BY 1',
117117
'SELECT NULL::text')
118118
AS c(rowid text, rowdt timestamp, temperature int4, test_result text, test_startdate timestamp, volts float8);
119119

120120
-- if source query returns zero rows, get zero rows returned
121121
SELECT * FROM crosstab(
122-
'SELECT rowid, rowdt, attribute, val FROM cth WHERE false ORDER BY 1',
122+
'SELECT orarowid, rowdt, attribute, val FROM cth WHERE false ORDER BY 1',
123123
'SELECT DISTINCT attribute FROM cth ORDER BY 1')
124124
AS c(rowid text, rowdt timestamp, temperature text, test_result text, test_startdate text, volts text);
125125

126126
-- if source query returns zero rows, get zero rows returned even if category query generates no rows
127127
SELECT * FROM crosstab(
128-
'SELECT rowid, rowdt, attribute, val FROM cth WHERE false ORDER BY 1',
128+
'SELECT orarowid, rowdt, attribute, val FROM cth WHERE false ORDER BY 1',
129129
'SELECT DISTINCT attribute FROM cth WHERE false ORDER BY 1')
130130
AS c(rowid text, rowdt pg_catalog.timestamp, temperature text, test_result text, test_startdate text, volts text);
131131

132132
-- check errors with inappropriate input rowtype
133133
SELECT * FROM crosstab(
134-
'SELECT rowid, attribute FROM cth ORDER BY 1',
134+
'SELECT orarowid, attribute FROM cth ORDER BY 1',
135135
'SELECT DISTINCT attribute FROM cth ORDER BY 1')
136136
AS c(rowid text, temperature text, test_result text, test_startdate text, volts text);
137137
SELECT * FROM crosstab(
138-
'SELECT rowid, rowdt, rowdt, attribute, val FROM cth ORDER BY 1',
138+
'SELECT orarowid, rowdt, rowdt, attribute, val FROM cth ORDER BY 1',
139139
'SELECT DISTINCT attribute FROM cth ORDER BY 1')
140140
AS c(rowid text, rowdt timestamp, temperature int4, test_result text, test_startdate timestamp, volts float8);
141141

142142
-- check errors with inappropriate result rowtype
143143
SELECT * FROM crosstab(
144-
'SELECT rowid, attribute, val FROM cth ORDER BY 1',
144+
'SELECT orarowid, attribute, val FROM cth ORDER BY 1',
145145
'SELECT DISTINCT attribute FROM cth ORDER BY 1')
146146
AS c(rowid text);
147147

@@ -158,13 +158,13 @@ LANGUAGE C STABLE STRICT;
158158
/
159159

160160
SELECT * FROM crosstab_named(
161-
'SELECT rowid, rowdt, attribute, val FROM cth ORDER BY 1',
161+
'SELECT orarowid, rowdt, attribute, val FROM cth ORDER BY 1',
162162
'SELECT DISTINCT attribute FROM cth ORDER BY 1');
163163

164164
-- check it works with OUT parameters
165165

166166
CREATE FUNCTION crosstab_out(text, text,
167-
OUT rowid text, OUT rowdt pg_catalog.timestamp,
167+
OUT orarowid text, OUT rowdt pg_catalog.timestamp,
168168
OUT temperature int4, OUT test_result text,
169169
OUT test_startdate pg_catalog.timestamp, OUT volts float8)
170170
RETURNS setof record
@@ -173,7 +173,7 @@ LANGUAGE C STABLE STRICT;
173173
/
174174

175175
SELECT * FROM crosstab_out(
176-
'SELECT rowid, rowdt, attribute, val FROM cth ORDER BY 1',
176+
'SELECT orarowid, rowdt, attribute, val FROM cth ORDER BY 1',
177177
'SELECT DISTINCT attribute FROM cth ORDER BY 1');
178178

179179
--

0 commit comments

Comments
 (0)