Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions contrib/amcheck/verify_heapam.c
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,10 @@ check_tuple_header(HeapCheckContext *ctx)
expected_hoff = MAXALIGN(SizeofHeapTupleHeader + BITMAPLEN(ctx->natts));
else
expected_hoff = MAXALIGN(SizeofHeapTupleHeader);

if (infomask & HEAP_HASROWID)
expected_hoff = expected_hoff + sizeof(int64);

if (ctx->tuphdr->t_hoff != expected_hoff)
{
if ((infomask & HEAP_HASNULL) && ctx->natts == 1)
Expand Down
6 changes: 6 additions & 0 deletions contrib/ivorysql_ora/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,18 @@ DATA = ivorysql_ora--1.0.sql

all: gensql

install: install-data

clean: cleansql

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

# Preload the compatible oracle misc sql script
install-data:
$(INSTALL_DATA) $(srcdir)/preload_ora_misc.sql '$(DESTDIR)$(datadir)/preload_ora_misc.sql'

# Clean the generated SQL(s).
cleansql:
rm -f $(DATA)
Expand Down
15 changes: 15 additions & 0 deletions contrib/ivorysql_ora/preload_ora_misc.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
GRANT USAGE ON SCHEMA sys TO PUBLIC;
SET search_path TO sys;

CREATE table dual (DUMMY pg_catalog.bpchar(1));
insert into dual values('X');
GRANT SELECT ON dual TO PUBLIC;

--
-- ROWID type
--
CREATE TYPE sys.rowid AS(rowoid OID, rowno bigint);
CREATE TYPE sys.urowid AS(rowoid OID, rowno bigint);

CREATE CAST (sys.rowid AS sys.urowid) WITH INOUT AS IMPLICIT;
CREATE CAST (sys.urowid AS sys.rowid) WITH INOUT AS IMPLICIT;
7 changes: 0 additions & 7 deletions contrib/ivorysql_ora/src/sysview/sysview--1.0.sql
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
GRANT USAGE ON SCHEMA sys TO PUBLIC;
SET search_path TO sys;

CREATE table dual (DUMMY pg_catalog.bpchar(1));
insert into dual values('X');
GRANT SELECT ON dual TO PUBLIC;

/*
* function which converts all-uppercase text to all-lowercase text
* and vice versa.
Expand Down
3 changes: 1 addition & 2 deletions contrib/pageinspect/expected/ivy_page.out
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ SELECT unnest(raw_flags)
HEAP_COMBOCID
HEAP_HASEXTERNAL
HEAP_HASNULL
HEAP_HASOID_OLD
HEAP_HASVARWIDTH
HEAP_HOT_UPDATED
HEAP_KEYS_UPDATED
Expand All @@ -149,7 +148,7 @@ SELECT unnest(raw_flags)
HEAP_XMAX_LOCK_ONLY
HEAP_XMIN_COMMITTED
HEAP_XMIN_INVALID
(19 rows)
(18 rows)

SELECT unnest(combined_flags)
FROM heap_tuple_infomask_flags(x'FFFF'::int, x'FFFF'::int) ORDER BY 1;
Expand Down
3 changes: 1 addition & 2 deletions contrib/pageinspect/expected/page.out
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ SELECT unnest(raw_flags)
HEAP_COMBOCID
HEAP_HASEXTERNAL
HEAP_HASNULL
HEAP_HASOID_OLD
HEAP_HASVARWIDTH
HEAP_HOT_UPDATED
HEAP_KEYS_UPDATED
Expand All @@ -150,7 +149,7 @@ SELECT unnest(raw_flags)
HEAP_XMAX_LOCK_ONLY
HEAP_XMIN_COMMITTED
HEAP_XMIN_INVALID
(19 rows)
(18 rows)

SELECT unnest(combined_flags)
FROM heap_tuple_infomask_flags(x'FFFF'::int, x'FFFF'::int) ORDER BY 1;
Expand Down
20 changes: 1 addition & 19 deletions contrib/pageinspect/heapfuncs.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,6 @@
#include "utils/builtins.h"
#include "utils/rel.h"

/*
* It's not supported to create tuples with oids anymore, but when pg_upgrade
* was used to upgrade from an older version, tuples might still have an
* oid. Seems worthwhile to display that.
*/
#define HeapTupleHeaderGetOidOld(tup) \
( \
((tup)->t_infomask & HEAP_HASOID_OLD) ? \
*((Oid *) ((char *)(tup) + (tup)->t_hoff - sizeof(Oid))) \
: \
InvalidOid \
)


/*
* bits_to_text
Expand Down Expand Up @@ -257,10 +244,7 @@ heap_page_items(PG_FUNCTION_ARGS)
else
nulls[11] = true;

if (tuphdr->t_infomask & HEAP_HASOID_OLD)
values[12] = HeapTupleHeaderGetOidOld(tuphdr);
else
nulls[12] = true;
nulls[12] = true;
}
else
{
Expand Down Expand Up @@ -549,8 +533,6 @@ heap_tuple_infomask_flags(PG_FUNCTION_ARGS)
flags[cnt++] = CStringGetTextDatum("HEAP_HASVARWIDTH");
if ((t_infomask & HEAP_HASEXTERNAL) != 0)
flags[cnt++] = CStringGetTextDatum("HEAP_HASEXTERNAL");
if ((t_infomask & HEAP_HASOID_OLD) != 0)
flags[cnt++] = CStringGetTextDatum("HEAP_HASOID_OLD");
if ((t_infomask & HEAP_XMAX_KEYSHR_LOCK) != 0)
flags[cnt++] = CStringGetTextDatum("HEAP_XMAX_KEYSHR_LOCK");
if ((t_infomask & HEAP_COMBOCID) != 0)
Expand Down
84 changes: 42 additions & 42 deletions contrib/tablefunc/expected/ivy_tablefunc.out

Large diffs are not rendered by default.

74 changes: 37 additions & 37 deletions contrib/tablefunc/sql/ivy_tablefunc.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,28 @@ SELECT avg(normal_rand)::int, count(*) FROM normal_rand(-1, 250, 0.2);
--
-- crosstab()
--
CREATE TABLE ct(id int, rowclass text, rowid text, attribute text, val text);
CREATE TABLE ct(id int, rowclass text, orarowid text, attribute text, val text);
\copy ct from 'data/ct.data'

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

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

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

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

SELECT * FROM crosstab('SELECT rowid, attribute, val FROM ct where rowclass = ''group1'' ORDER BY 1,2;') AS c(rowid text, att1 text, att2 text);
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);
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);
SELECT * FROM crosstab('SELECT orarowid, attribute, val FROM ct where rowclass = ''group1'' ORDER BY 1,2;') AS c(rowid text, att1 text, att2 text);
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);
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);

-- check it works with OUT parameters, too

Expand All @@ -43,23 +43,23 @@ AS '$libdir/tablefunc','crosstab'
LANGUAGE C STABLE STRICT;
/

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

-- check error reporting
SELECT * FROM crosstab('SELECT rowid, val FROM ct where rowclass = ''group1'' and (attribute = ''att2'' or attribute = ''att3'') ORDER BY 1,2;')
SELECT * FROM crosstab('SELECT orarowid, val FROM ct where rowclass = ''group1'' and (attribute = ''att2'' or attribute = ''att3'') ORDER BY 1,2;')
AS ct(row_name text, category_1 text, category_2 text);
SELECT * FROM crosstab('SELECT rowid, attribute, val FROM ct where rowclass = ''group1'' and (attribute = ''att2'' or attribute = ''att3'') ORDER BY 1,2;')
SELECT * FROM crosstab('SELECT orarowid, attribute, val FROM ct where rowclass = ''group1'' and (attribute = ''att2'' or attribute = ''att3'') ORDER BY 1,2;')
AS ct(row_name text);
SELECT * FROM crosstab('SELECT rowid, attribute, val FROM ct where rowclass = ''group1'' and (attribute = ''att2'' or attribute = ''att3'') ORDER BY 1,2;')
SELECT * FROM crosstab('SELECT orarowid, attribute, val FROM ct where rowclass = ''group1'' and (attribute = ''att2'' or attribute = ''att3'') ORDER BY 1,2;')
AS ct(row_name int, category_1 text, category_2 text);
SELECT * FROM crosstab('SELECT rowid, attribute, val FROM ct where rowclass = ''group1'' and (attribute = ''att2'' or attribute = ''att3'') ORDER BY 1,2;')
SELECT * FROM crosstab('SELECT orarowid, attribute, val FROM ct where rowclass = ''group1'' and (attribute = ''att2'' or attribute = ''att3'') ORDER BY 1,2;')
AS ct(row_name text, category_1 text, category_2 int);

--
-- hash based crosstab
--

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

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

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

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

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

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

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

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

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

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

-- check errors with inappropriate input rowtype
SELECT * FROM crosstab(
'SELECT rowid, attribute FROM cth ORDER BY 1',
'SELECT orarowid, attribute FROM cth ORDER BY 1',
'SELECT DISTINCT attribute FROM cth ORDER BY 1')
AS c(rowid text, temperature text, test_result text, test_startdate text, volts text);
SELECT * FROM crosstab(
'SELECT rowid, rowdt, rowdt, attribute, val FROM cth ORDER BY 1',
'SELECT orarowid, rowdt, rowdt, attribute, val FROM cth ORDER BY 1',
'SELECT DISTINCT attribute FROM cth ORDER BY 1')
AS c(rowid text, rowdt timestamp, temperature int4, test_result text, test_startdate timestamp, volts float8);

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

Expand All @@ -158,13 +158,13 @@ LANGUAGE C STABLE STRICT;
/

SELECT * FROM crosstab_named(
'SELECT rowid, rowdt, attribute, val FROM cth ORDER BY 1',
'SELECT orarowid, rowdt, attribute, val FROM cth ORDER BY 1',
'SELECT DISTINCT attribute FROM cth ORDER BY 1');

-- check it works with OUT parameters

CREATE FUNCTION crosstab_out(text, text,
OUT rowid text, OUT rowdt pg_catalog.timestamp,
OUT orarowid text, OUT rowdt pg_catalog.timestamp,
OUT temperature int4, OUT test_result text,
OUT test_startdate pg_catalog.timestamp, OUT volts float8)
RETURNS setof record
Expand All @@ -173,7 +173,7 @@ LANGUAGE C STABLE STRICT;
/

SELECT * FROM crosstab_out(
'SELECT rowid, rowdt, attribute, val FROM cth ORDER BY 1',
'SELECT orarowid, rowdt, attribute, val FROM cth ORDER BY 1',
'SELECT DISTINCT attribute FROM cth ORDER BY 1');

--
Expand Down
Loading