Thu May 31 09:46:20 PDT 2007
- Previous message: [Slony1-commit] slony1-engine/src/slonik slonik.c
- Next message: [Slony1-commit] slony1-engine/src/backend slony1_funcs.sql
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Update of /home/cvsd/slony1/slony1-engine/src/backend
In directory main.slony.info:/tmp/cvs-serv2496/src/backend
Modified Files:
Makefile slony1_funcs.c slony1_funcs.sql
Removed Files:
slony1_base.v73.sql slony1_base.v74.sql slony1_base.v80.sql
slony1_base.v81.sql slony1_funcs.v73.sql slony1_funcs.v74.sql
slony1_funcs.v80.sql slony1_funcs.v81.sql
Log Message:
This is the first step towards Slony-I version 2.0.
It drops all support for databases prior to Postgres version 8.3.
This is required because we now make use of new functionality in
Postgres, namely the trigger and rule support for session replication
role. As of now, every node (origin/subscriber/mixed) can be dumped
with pg_dump and result in a consistent snapshot of the database.
TODO:
- Run DDL scripts as "local" replication role. Currently DDL
scripts don't work at all.
- Get rid of STORE TRIGGER and force users to make use of 8.3's
advanced trigger and rule configuration.
Jan
--- slony1_funcs.v73.sql DELETED ---
Index: slony1_funcs.sql
===================================================================
RCS file: /home/cvsd/slony1/slony1-engine/src/backend/slony1_funcs.sql,v
retrieving revision 1.108
retrieving revision 1.109
diff -C2 -d -r1.108 -r1.109
*** slony1_funcs.sql 18 Apr 2007 19:26:54 -0000 1.108
--- slony1_funcs.sql 31 May 2007 16:46:18 -0000 1.109
***************
*** 4,8 ****
-- Declaration of replication support functions.
--
! -- Copyright (c) 2003-2004, PostgreSQL Global Development Group
-- Author: Jan Wieck, Afilias USA INC.
--
--- 4,8 ----
-- Declaration of replication support functions.
--
! -- Copyright (c) 2003-2007, PostgreSQL Global Development Group
-- Author: Jan Wieck, Afilias USA INC.
[...1091 lines suppressed...]
+ ' language plpgsql;
+
+ comment on function @NAMESPACE at .finishTableAfterCopy(int4) is
+ 'Reenable index maintenance and reindex the table';
+
+ create or replace function @NAMESPACE at .make_function_strict (text, text) returns void as
+ '
+ declare
+ fun alias for $1;
+ parms alias for $2;
+ stmt text;
+ begin
+ stmt := ''ALTER FUNCTION "_ at CLUSTERNAME@".'' || fun || '' '' || parms || '' STRICT;'';
+ execute stmt;
+ return;
+ end
+ ' language plpgsql;
+
+ comment on function @NAMESPACE at .make_function_strict (text, text) is
+ 'Equivalent to 8.1+ ALTER FUNCTION ... STRICT';
Index: Makefile
===================================================================
RCS file: /home/cvsd/slony1/slony1-engine/src/backend/Makefile,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** Makefile 18 Apr 2007 21:20:22 -0000 1.24
--- Makefile 31 May 2007 16:46:18 -0000 1.25
***************
*** 22,48 ****
BASE_COMMON = slony1_base.sql
FUNCS_COMMON = slony1_funcs.sql
- BASE_73 = slony1_base.v73.sql
- FUNCS_73 = slony1_funcs.v73.sql
-
- BASE_74 = slony1_base.v74.sql
- FUNCS_74 = slony1_funcs.v74.sql
! BASE_80 = slony1_base.v80.sql
! FUNCS_80 = slony1_funcs.v80.sql
!
! BASE_81 = slony1_base.v81.sql
! FUNCS_81 = slony1_funcs.v81.sql
SQL_NAMES = \
$(BASE_COMMON) \
$(FUNCS_COMMON) \
! $(BASE_73) \
! $(FUNCS_73) \
! $(BASE_74) \
! $(FUNCS_74) \
! $(BASE_80) \
! $(FUNCS_80) \
! $(BASE_81) \
! $(FUNCS_81)
DISTFILES = Makefile README README.events $(wildcard *.sql) $(wildcard *.in) $(wildcard *.c)
--- 22,34 ----
BASE_COMMON = slony1_base.sql
FUNCS_COMMON = slony1_funcs.sql
! BASE_83 = slony1_base.v83.sql
! FUNCS_83 = slony1_funcs.v83.sql
SQL_NAMES = \
$(BASE_COMMON) \
$(FUNCS_COMMON) \
! $(BASE_83) \
! $(FUNCS_83)
DISTFILES = Makefile README README.events $(wildcard *.sql) $(wildcard *.in) $(wildcard *.c)
--- slony1_base.v74.sql DELETED ---
--- slony1_base.v80.sql DELETED ---
--- slony1_funcs.v80.sql DELETED ---
--- slony1_funcs.v74.sql DELETED ---
--- slony1_base.v81.sql DELETED ---
--- slony1_funcs.v81.sql DELETED ---
Index: slony1_funcs.c
===================================================================
RCS file: /home/cvsd/slony1/slony1-engine/src/backend/slony1_funcs.c,v
retrieving revision 1.60
retrieving revision 1.61
diff -C2 -d -r1.60 -r1.61
*** slony1_funcs.c 2 May 2007 21:36:17 -0000 1.60
--- slony1_funcs.c 31 May 2007 16:46:18 -0000 1.61
***************
*** 44,58 ****
#endif
- /* -- Change from PostgreSQL Ver 8.3 -- */
- #if !((PG_VERSION_MAJOR > 8) || ((PG_VERSION_MAJOR == 8) && (PG_VERSION_MINOR >= 3)))
- #define SET_VARSIZE(datum, size) (VARATT_SIZEP(datum)=(size))
- #endif
-
PG_FUNCTION_INFO_V1(_Slony_I_createEvent);
PG_FUNCTION_INFO_V1(_Slony_I_getLocalNodeId);
PG_FUNCTION_INFO_V1(_Slony_I_getModuleVersion);
- PG_FUNCTION_INFO_V1(_Slony_I_setSessionRole);
- PG_FUNCTION_INFO_V1(_Slony_I_getSessionRole);
PG_FUNCTION_INFO_V1(_Slony_I_logTrigger);
PG_FUNCTION_INFO_V1(_Slony_I_denyAccess);
--- 44,51 ----
***************
*** 67,72 ****
Datum _Slony_I_getModuleVersion(PG_FUNCTION_ARGS);
- Datum _Slony_I_setSessionRole(PG_FUNCTION_ARGS);
- Datum _Slony_I_getSessionRole(PG_FUNCTION_ARGS);
Datum _Slony_I_logTrigger(PG_FUNCTION_ARGS);
Datum _Slony_I_denyAccess(PG_FUNCTION_ARGS);
--- 60,63 ----
***************
*** 103,107 ****
int32 localNodeId;
TransactionId currentXid;
- int session_role;
void *plan_active_log;
--- 94,97 ----
***************
*** 320,410 ****
Datum
- _Slony_I_setSessionRole(PG_FUNCTION_ARGS)
- {
- Slony_I_ClusterStatus *cs;
- int rc;
- text *new_role_t = PG_GETARG_TEXT_P(1);
- int new_role = SLON_ROLE_UNSET;
-
- if ((rc = SPI_connect()) < 0)
- elog(ERROR, "Slony-I: SPI_connect() failed in setSessionRole()");
-
- cs = getClusterStatus(PG_GETARG_NAME(0), PLAN_NONE);
-
- SPI_finish();
-
- if (VARSIZE(new_role_t) == VARHDRSZ + 6 &&
- memcmp(VARDATA(new_role_t), "normal", 6) == 0)
- {
- new_role = SLON_ROLE_NORMAL;
- }
- else if (VARSIZE(new_role_t) == VARHDRSZ + 4 &&
- memcmp(VARDATA(new_role_t), "slon", 4) == 0)
- {
- if (!superuser())
- elog(ERROR, "Slony-I: insufficient privilege for replication role");
-
- new_role = SLON_ROLE_SLON;
- }
- else
- {
- elog(ERROR, "Slony-I: invalid session role");
- }
-
- if (cs->session_role == SLON_ROLE_UNSET ||
- cs->session_role == new_role)
- {
- cs->session_role = new_role;
- }
- else
- {
- elog(ERROR, "Slony-I: cannot change session role once set");
- }
-
- PG_RETURN_TEXT_P(new_role_t);
- }
-
-
- Datum
- _Slony_I_getSessionRole(PG_FUNCTION_ARGS)
- {
- Slony_I_ClusterStatus *cs;
- int rc;
- text *retval = NULL;
-
- if ((rc = SPI_connect()) < 0)
- elog(ERROR, "Slony-I: SPI_connect() failed in getSessionRole()");
-
- cs = getClusterStatus(PG_GETARG_NAME(0), PLAN_NONE);
-
- SPI_finish();
-
- switch (cs->session_role)
- {
- case SLON_ROLE_UNSET:
- cs->session_role = SLON_ROLE_NORMAL;
- retval = palloc(VARHDRSZ + 6);
- SET_VARSIZE(retval, VARHDRSZ + 6);
- memcpy(VARDATA(retval), "normal", 6);
- break;
-
- case SLON_ROLE_NORMAL:
- retval = palloc(VARHDRSZ + 6);
- SET_VARSIZE(retval, VARHDRSZ + 6);
- memcpy(VARDATA(retval), "normal", 6);
- break;
-
- case SLON_ROLE_SLON:
- retval = palloc(VARHDRSZ + 4);
- SET_VARSIZE(retval, VARHDRSZ + 4);
- memcpy(VARDATA(retval), "slon", 4);
- break;
- }
-
- PG_RETURN_TEXT_P(retval);
- }
-
-
- Datum
_Slony_I_logTrigger(PG_FUNCTION_ARGS)
{
--- 310,313 ----
***************
*** 422,425 ****
--- 325,334 ----
/*
+ * Don't do any logging if the current session role isn't Origin.
+ */
+ if (SessionReplicationRole != SESSION_REPLICATION_ROLE_ORIGIN)
+ return PointerGetDatum(NULL);
+
+ /*
* Get the trigger call context
*/
***************
*** 459,482 ****
/*
- * Check/set the session role
- */
- switch (cs->session_role)
- {
- case SLON_ROLE_UNSET: /* Nobody told us, force it to normal */
- cs->session_role = SLON_ROLE_NORMAL;
- break;
-
- case SLON_ROLE_NORMAL: /* Normal, that's good */
- break;
-
- case SLON_ROLE_SLON: /* non-client session ??? */
- /* This would happen when a trigger on a
- * subscriber on a replicated table fires, and
- * modifies a tuple in a replication set for
- * which this node is the origin */
- break;
- }
-
- /*
* Do the following only once per transaction.
*/
--- 368,371 ----
***************
*** 966,973 ****
_Slony_I_denyAccess(PG_FUNCTION_ARGS)
{
- Slony_I_ClusterStatus *cs;
TriggerData *tg;
- int rc;
- Name cluster_name;
/*
--- 855,859 ----
***************
*** 991,1026 ****
* Connect to the SPI manager
*/
! if ((rc = SPI_connect()) < 0)
elog(ERROR, "Slony-I: SPI_connect() failed in denyAccess()");
! /*
! * Get all the trigger arguments
! */
! cluster_name = DatumGetName(DirectFunctionCall1(namein,
! CStringGetDatum(tg->tg_trigger->tgargs[0])));
!
! /*
! * Get or create the cluster status information and make sure it has the
! * SPI plans that we need here.
! */
! cs = getClusterStatus(cluster_name, PLAN_INSERT_LOG);
!
! /*
! * Check/set the session role
! */
! switch (cs->session_role)
! {
! case SLON_ROLE_UNSET: /* Unknown or Normal is not allowed here */
! case SLON_ROLE_NORMAL:
! cs->session_role = SLON_ROLE_NORMAL;
! elog(ERROR,
! "Slony-I: Table %s is replicated and cannot be "
! "modified on a subscriber node",
! NameStr(tg->tg_relation->rd_rel->relname));
! break;
!
! case SLON_ROLE_SLON: /* Replication session, nothing to do here */
! break;
! }
SPI_finish();
--- 877,887 ----
* Connect to the SPI manager
*/
! if (SPI_connect() < 0)
elog(ERROR, "Slony-I: SPI_connect() failed in denyAccess()");
! elog(ERROR,
! "Slony-I: Table %s is replicated and cannot be "
! "modified on a subscriber node",
! NameStr(tg->tg_relation->rd_rel->relname));
SPI_finish();
--- slony1_base.v73.sql DELETED ---
- Previous message: [Slony1-commit] slony1-engine/src/slonik slonik.c
- Next message: [Slony1-commit] slony1-engine/src/backend slony1_funcs.sql
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Slony1-commit mailing list