break;
case AT_ReAddConstraint: /* Re-add pre-existing check
* constraint */
- ATExecAddConstraint(wqueue, tab, rel, (Constraint *) cmd->def,
- true, true, lockmode);
+ newoid =
+ ATExecAddConstraint(wqueue, tab, rel, (Constraint *) cmd->def,
- false, true, lockmode);
++ true, true, lockmode);
break;
case AT_AddIndexConstraint: /* ADD CONSTRAINT USING INDEX */
- ATExecAddIndexConstraint(tab, rel, (IndexStmt *) cmd->def, lockmode);
+ newoid = ATExecAddIndexConstraint(tab, rel, (IndexStmt *) cmd->def,
+ lockmode);
break;
case AT_AlterConstraint: /* ALTER CONSTRAINT */
- ATExecAlterConstraint(rel, cmd, false, false, lockmode);
+ newoid = ATExecAlterConstraint(rel, cmd, false, false, lockmode);
break;
case AT_ValidateConstraint: /* VALIDATE CONSTRAINT */
- ATExecValidateConstraint(rel, cmd->name, false, false, lockmode);
+ newoid = ATExecValidateConstraint(rel, cmd->name, false, false,
+ lockmode);
break;
case AT_ValidateConstraintRecurse: /* VALIDATE CONSTRAINT with
* recursion */
* AddRelationNewConstraints would normally assign different names to the
* child constraints. To fix that, we must capture the name assigned at
* the parent table and pass that down.
- *
- * When re-adding a previously existing constraint (during ALTER COLUMN TYPE),
- * we don't need to recurse here, because recursion will be carried out at a
- * higher level; the constraint name issue doesn't apply because the names
- * have already been assigned and are just being re-used. We need a separate
- * "is_readd" flag for that; just setting recurse=false would result in an
- * error if there are child tables.
*/
-static void
+static Oid
ATAddCheckConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
Constraint *constr, bool recurse, bool recursing,
bool is_readd, LOCKMODE lockmode)
/*
* If adding a NO INHERIT constraint, no need to find our children.
- * Likewise, in a re-add operation, we don't need to recurse (that will be
- * handled at higher levels).
*/
- if (constr->is_no_inherit || is_readd)
+ if (constr->is_no_inherit)
- return;
+ return constrOid;
/*
* Propagate to children as appropriate. Unlike most other ALTER
Datum
pg_logical_slot_peek_binary_changes(PG_FUNCTION_ARGS)
{
- Datum ret = pg_logical_slot_get_changes_guts(fcinfo, false, true);
-
- return ret;
+ return pg_logical_slot_get_changes_guts(fcinfo, false, true);
}
+
+
+/*
+ * SQL function returning the changestream in binary, only peeking ahead.
+ */
+Datum
+pg_logical_send_message_bytea(PG_FUNCTION_ARGS)
+{
+ bool transactional = PG_GETARG_BOOL(0);
+ bytea *data = PG_GETARG_BYTEA_PP(1);
+ XLogRecPtr lsn;
+
+ lsn = LogStandbyMessage(VARDATA_ANY(data), VARSIZE_ANY_EXHDR(data), transactional);
+ PG_RETURN_LSN(lsn);
+}
+
+Datum
+pg_logical_send_message_text(PG_FUNCTION_ARGS)
+{
+ /* bytea and text are compatible */
+ return pg_logical_send_message_bytea(fcinfo);
+}
char xpos[MAXFNAMELEN];
XLogRecPtr logptr;
char *dbname = NULL;
+ char dboid[10];
+ Size len;
/*
* Reply with a result set with one row, four columns. First col is system
/* Send a DataRow message */
pq_beginmessage(&buf, 'D');
- pq_sendint(&buf, 4, 2); /* # of columns */
+ pq_sendint(&buf, 5, 2); /* # of columns */
- pq_sendint(&buf, strlen(sysid), 4); /* col1 len */
- pq_sendbytes(&buf, (char *) &sysid, strlen(sysid));
- pq_sendint(&buf, strlen(tli), 4); /* col2 len */
- pq_sendbytes(&buf, (char *) tli, strlen(tli));
- pq_sendint(&buf, strlen(xpos), 4); /* col3 len */
- pq_sendbytes(&buf, (char *) xpos, strlen(xpos));
- /* send NULL if not connected to a database */
+
+ /* column 1: system identifier */
+ len = strlen(sysid);
+ pq_sendint(&buf, len, 4);
+ pq_sendbytes(&buf, (char *) &sysid, len);
+
+ /* column 2: timeline */
+ len = strlen(tli);
+ pq_sendint(&buf, len, 4);
+ pq_sendbytes(&buf, (char *) tli, len);
+
+ /* column 3: xlog position */
+ len = strlen(xpos);
+ pq_sendint(&buf, len, 4);
+ pq_sendbytes(&buf, (char *) xpos, len);
+
- /* column 4: database name, or NULL if none */
++ /* column 4 & 5: database name and oid, or NULL if none */
if (dbname)
{
- pq_sendint(&buf, strlen(dbname), 4); /* col4 len */
- pq_sendbytes(&buf, (char *) dbname, strlen(dbname));
+ len = strlen(dbname);
+ pq_sendint(&buf, len, 4);
+ pq_sendbytes(&buf, (char *) dbname, len);
+
- pq_sendint(&buf, strlen(dboid), 4); /* col5 len */
- pq_sendbytes(&buf, dboid, strlen(dboid));
++ len = strlen(dboid);
++ pq_sendint(&buf, len, 4);
++ pq_sendbytes(&buf, dboid, len);
}
else
{
- pq_sendint(&buf, -1, 4); /* col4 len, NULL */
- pq_sendint(&buf, -1, 4); /* col5 len, NULL */
+ pq_sendint(&buf, -1, 4);
++ pq_sendint(&buf, -1, 4);
}
pq_endmessage(&buf);
#include "utils/array.h"
#include "utils/builtins.h"
#include "utils/fmgroids.h"
+ #include "utils/hsearch.h"
#include "utils/lsyscache.h"
#include "utils/rel.h"
+#include "utils/ruleutils.h"
#include "utils/snapmgr.h"
#include "utils/syscache.h"
#include "utils/tqual.h"
prettyFlags)));
}
- /* Internal version that returns a palloc'd C string; no pretty-printing */
+ /*
+ * Internal version that returns a full ALTER TABLE ... ADD CONSTRAINT command
+ */
char *
-pg_get_constraintdef_string(Oid constraintId)
+pg_get_constraintdef_string(Oid constraintId, bool fullCommand)
{
- return pg_get_constraintdef_worker(constraintId, true, 0);
+ return pg_get_constraintdef_worker(constraintId, fullCommand, 0);
}
/*
#endif
static const char *subdirs[] = {
"global",
- "pg_xlog",
"pg_xlog/archive_status",
"pg_clog",
+ "pg_committs",
"pg_dynshmem",
"pg_notify",
"pg_serial",