workaround with 8.2.

This commit is contained in:
Takahiro Itagaki 2009-01-27 01:35:53 +00:00
parent aab19c7db0
commit 942180c2d8
5 changed files with 17 additions and 11 deletions

View File

@ -90,7 +90,6 @@ Indexes:
Indexes:
"tbl_only_pkey_pkey" PRIMARY KEY, btree (col1)
SET synchronize_seqscans = off;
SELECT col1, to_char(col2, 'YYYY-MM-DD HH24:MI:SS'), ":-)" FROM tbl_cluster;
col1 | to_char | :-)
------+---------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
@ -122,7 +121,6 @@ SELECT * FROM tbl_gistkey ORDER BY 1;
2 | <(4,5),6>
(2 rows)
RESET synchronize_seqscans;
--
-- clean up
--

View File

@ -581,7 +581,7 @@ reorg_one_table(const reorg_table *table, const char *orderby)
command("BEGIN ISOLATION LEVEL SERIALIZABLE", 0, NULL);
/* SET work_mem = maintenance_work_mem */
command("SELECT set_config('work_mem', current_setting('maintenance_work_mem'), true)", 0, NULL);
if (orderby && !orderby[0])
if (PQserverVersion(current_conn) >= 80300 && orderby && !orderby[0])
command("SET LOCAL synchronize_seqscans = off", 0, NULL);
res = execute(SQL_XID_SNAPSHOT, 0, NULL);
vxid = strdup(PQgetvalue(res, 0, 0));

View File

@ -70,12 +70,10 @@ INSERT INTO tbl_gistkey VALUES(2, '<(4,5),6>');
\d tbl_only_ckey
\d tbl_only_pkey
SET synchronize_seqscans = off;
SELECT col1, to_char(col2, 'YYYY-MM-DD HH24:MI:SS'), ":-)" FROM tbl_cluster;
SELECT * FROM tbl_only_ckey ORDER BY 1;
SELECT * FROM tbl_only_pkey ORDER BY 1;
SELECT * FROM tbl_gistkey ORDER BY 1;
RESET synchronize_seqscans;
--
-- clean up

View File

@ -18,6 +18,12 @@ CREATE AGGREGATE reorg.array_accum (
initcond = '{}'
);
CREATE FUNCTION reorg.oid2text(oid) RETURNS text AS
$$
SELECT textin(regclassout($1));
$$
LANGUAGE sql STABLE STRICT;
CREATE FUNCTION reorg.get_index_columns(oid, text) RETURNS text AS
$$
SELECT array_to_string(reorg.array_accum(quote_ident(attname)), $2)
@ -58,7 +64,7 @@ CREATE FUNCTION reorg.get_create_trigger(relid oid, pkid oid)
RETURNS text AS
$$
SELECT 'CREATE TRIGGER z_reorg_trigger' ||
' BEFORE INSERT OR DELETE OR UPDATE ON ' || $1::regclass ||
' BEFORE INSERT OR DELETE OR UPDATE ON ' || reorg.oid2text($1) ||
' FOR EACH ROW EXECUTE PROCEDURE reorg.reorg_trigger(' ||
'''INSERT INTO reorg.log_' || $1 || '(pk, row) VALUES(' ||
' CASE WHEN $1 IS NULL THEN NULL ELSE (ROW($1.' ||
@ -104,11 +110,11 @@ CREATE VIEW reorg.tables AS
PK.indexrelid AS pkid,
CK.indexrelid AS ckid,
reorg.get_create_index_type(PK.indexrelid, 'reorg.pk_' || R.oid) AS create_pktype,
'CREATE TABLE reorg.log_' || R.oid || ' (id bigserial PRIMARY KEY, pk reorg.pk_' || R.oid || ', row ' || R.oid::regclass || ')' AS create_log,
'CREATE TABLE reorg.log_' || R.oid || ' (id bigserial PRIMARY KEY, pk reorg.pk_' || R.oid || ', row ' || reorg.oid2text(R.oid) || ')' AS create_log,
reorg.get_create_trigger(R.oid, PK.indexrelid) AS create_trigger,
'CREATE TABLE reorg.table_' || R.oid || ' WITH (' || array_to_string(array_append(R.reloptions, 'oids=' || R.relhasoids), ',') || ') TABLESPACE ' || coalesce(quote_ident(S.spcname), 'pg_default') || ' AS SELECT * FROM ONLY ' || R.oid::regclass AS create_table,
'CREATE TABLE reorg.table_' || R.oid || ' WITH (' || array_to_string(array_append(R.reloptions, 'oids=' || CASE WHEN R.relhasoids THEN 'true' ELSE 'false' END), ',') || ') TABLESPACE ' || coalesce(quote_ident(S.spcname), 'pg_default') || ' AS SELECT * FROM ONLY ' || reorg.oid2text(R.oid) AS create_table,
'DELETE FROM reorg.log_' || R.oid AS delete_log,
'LOCK TABLE ' || R.oid::regclass || ' IN ACCESS EXCLUSIVE MODE' AS lock_table,
'LOCK TABLE ' || reorg.oid2text(R.oid) || ' IN ACCESS EXCLUSIVE MODE' AS lock_table,
reorg.get_index_keys(CK.indexrelid, R.oid) AS ckey,
'SELECT * FROM reorg.log_' || R.oid || ' ORDER BY id LIMIT $1' AS sql_peek,
'INSERT INTO reorg.table_' || R.oid || ' VALUES ($1.*)' AS sql_insert,

View File

@ -29,10 +29,10 @@ PG_MODULE_MAGIC;
#if PG_VERSION_NUM < 80300
#define SET_VARSIZE(PTR, len) (VARATT_SIZEP((PTR)) = (len))
#define PGDLLIMPORT DLLIMPORT
typedef void *SPIPlanPtr;
#endif
Datum reorg_trigger(PG_FUNCTION_ARGS);
Datum reorg_apply(PG_FUNCTION_ARGS);
Datum reorg_get_index_keys(PG_FUNCTION_ARGS);
@ -931,7 +931,11 @@ RenameRelationInternal(Oid myrelid, const char *newrelname, Oid namespaceId)
allowSystemTableMods = true;
PG_TRY();
{
renamerel(myrelid, newrelname, OBJECT_TABLE);
renamerel(myrelid, newrelname
#if PG_VERSION_NUM >= 80300
, OBJECT_TABLE
#endif
);
allowSystemTableMods = save_allowSystemTableMods;
}
PG_CATCH();