cur = (GBT_NUMKEY *) DatumGetPointer((entryvec->vector[i].key));
c.lower = &cur[0];
c.upper = &cur[tinfo->size];
- if ((*tinfo->f_gt) (o.lower, c.lower, flinfo)) /* out->lower > cur->lower */
+ /* if out->lower > cur->lower, adopt cur as lower */
+ if ((*tinfo->f_gt) (o.lower, c.lower, flinfo))
memcpy((void *) o.lower, (void *) c.lower, tinfo->size);
- if ((*tinfo->f_lt) (o.upper, c.upper, flinfo)) /* out->upper < cur->upper */
+ /* if out->upper < cur->upper, adopt cur as upper */
+ if ((*tinfo->f_lt) (o.upper, c.upper, flinfo))
memcpy((void *) o.upper, (void *) c.upper, tinfo->size);
}
if (is_leaf)
retval = (*tinfo->f_eq) (query, key->lower, flinfo);
else
- retval = ((*tinfo->f_le) (key->lower, query, flinfo) && (*tinfo->f_le) (query, key->upper, flinfo)) ? true : false;
+ retval = ((*tinfo->f_le) (key->lower, query, flinfo) &&
+ (*tinfo->f_le) (query, key->upper, flinfo));
break;
case BTGreaterStrategyNumber:
if (is_leaf)
break;
case BtreeGistNotEqualStrategyNumber:
retval = (!((*tinfo->f_eq) (query, key->lower, flinfo) &&
- (*tinfo->f_eq) (query, key->upper, flinfo))) ? true : false;
+ (*tinfo->f_eq) (query, key->upper, flinfo)));
break;
default:
retval = false;
*
* Does same checks as the above, but does not need relation to be opened
* and also does not throw errors.
+ *
+ * Note this also excludes all tables with relid < FirstNormalObjectId,
+ * ie all tables created during initdb. This mainly affects the preinstalled
+ * information_schema. (IsCatalogClass() only checks for these inside
+ * pg_catalog and toast schemas.)
*/
static bool
is_publishable_class(Oid relid, Form_pg_class reltuple)
return reltuple->relkind == RELKIND_RELATION &&
!IsCatalogClass(relid, reltuple) &&
reltuple->relpersistence == RELPERSISTENCE_PERMANENT &&
- /*
- * Also exclude any tables created as part of initdb. This mainly
- * affects the preinstalled information_schema.
- * Note that IsCatalogClass() only checks for these inside pg_catalog
- * and toast schemas.
- */
relid >= FirstNormalObjectId;
}
rel = heap_openrv(rv, ShareUpdateExclusiveLock);
myrelid = RelationGetRelid(rel);
+
/*
- * filter out duplicates when user specifies "foo, foo"
+ * Filter out duplicates if user specifies "foo, foo".
+ *
* Note that this algorithm is known to not be very efficient (O(N^2))
* but given that it only works on list of tables given to us by user
* it's deemed acceptable.
/*
* Parse and check options.
+ *
* Connection and publication should not be specified here.
*/
parse_subscription_options(stmt->options, &connect, &enabled_given,
/*
* XXX: Should we add a function to free that read pointer when done?
+ *
* This was attempted, but it did not improve performance or memory usage
* in any tested cases.
*/
*/
TransactionId initial_xmin_horizon;
- /* Indicates if we are building full snapshot or just catalog one .*/
+ /* Indicates if we are building full snapshot or just catalog one. */
bool building_full_snapshot;
/*
OutputPluginWrite(ctx, false);
OutputPluginPrepareWrite(ctx, true);
- /*
- * XXX: which behaviour we want here?
+ /*----------
+ * XXX: which behaviour do we want here?
*
* Alternatives:
* - don't send origin message if origin name not found
* (that's what we do now)
* - throw error - that will break replication, not good
* - send some special "unknown" origin
+ *----------
*/
if (replorigin_by_oid(txn->origin_id, true, &origin))
logicalrep_write_origin(ctx->out, origin, txn->origin_lsn);
Datum
ts_headline_byid_opt(PG_FUNCTION_ARGS)
{
+ Oid tsconfig = PG_GETARG_OID(0);
text *in = PG_GETARG_TEXT_PP(1);
TSQuery query = PG_GETARG_TSQUERY(2);
text *opt = (PG_NARGS() > 3 && PG_GETARG_POINTER(3)) ? PG_GETARG_TEXT_PP(3) : NULL;
TSConfigCacheEntry *cfg;
TSParserCacheEntry *prsobj;
- cfg = lookup_ts_config_cache(PG_GETARG_OID(0));
+ cfg = lookup_ts_config_cache(tsconfig);
prsobj = lookup_ts_parser_cache(cfg->prsId);
if (!OidIsValid(prsobj->headlineOid))
Datum
ts_headline_jsonb_byid_opt(PG_FUNCTION_ARGS)
{
- Jsonb *out, *jb = PG_GETARG_JSONB(1);
+ Oid tsconfig = PG_GETARG_OID(0);
+ Jsonb *jb = PG_GETARG_JSONB(1);
TSQuery query = PG_GETARG_TSQUERY(2);
text *opt = (PG_NARGS() > 3 && PG_GETARG_POINTER(3)) ? PG_GETARG_TEXT_P(3) : NULL;
+ Jsonb *out;
JsonTransformStringValuesAction action = (JsonTransformStringValuesAction) headline_json_value;
-
HeadlineParsedText prs;
HeadlineJsonState *state = palloc0(sizeof(HeadlineJsonState));
prs.words = (HeadlineWordEntry *) palloc(sizeof(HeadlineWordEntry) * prs.lenwords);
state->prs = &prs;
- state->cfg = lookup_ts_config_cache(PG_GETARG_OID(0));
+ state->cfg = lookup_ts_config_cache(tsconfig);
state->prsobj = lookup_ts_parser_cache(state->cfg->prsId);
state->query = query;
if (opt)
Datum
ts_headline_json_byid_opt(PG_FUNCTION_ARGS)
{
+ Oid tsconfig = PG_GETARG_OID(0);
text *json = PG_GETARG_TEXT_P(1);
TSQuery query = PG_GETARG_TSQUERY(2);
text *opt = (PG_NARGS() > 3 && PG_GETARG_POINTER(3)) ? PG_GETARG_TEXT_P(3) : NULL;
prs.words = (HeadlineWordEntry *) palloc(sizeof(HeadlineWordEntry) * prs.lenwords);
state->prs = &prs;
- state->cfg = lookup_ts_config_cache(PG_GETARG_OID(0));
+ state->cfg = lookup_ts_config_cache(tsconfig);
state->prsobj = lookup_ts_parser_cache(state->cfg->prsId);
state->query = query;
if (opt)
*****************************************************************************/
#ifdef USE_ICU
+
+typedef int32_t (*ICU_Convert_Func)(UChar *dest, int32_t destCapacity,
+ const UChar *src, int32_t srcLength,
+ const char *locale,
+ UErrorCode *pErrorCode);
+
static int32_t
-icu_convert_case(int32_t (*func)(UChar *, int32_t, const UChar *, int32_t, const char *, UErrorCode *),
- pg_locale_t mylocale, UChar **buff_dest, UChar *buff_source, int32_t len_source)
+icu_convert_case(ICU_Convert_Func func, pg_locale_t mylocale,
+ UChar **buff_dest, UChar *buff_source, int32_t len_source)
{
UErrorCode status;
int32_t len_dest;
len_dest = len_source; /* try first with same length */
*buff_dest = palloc(len_dest * sizeof(**buff_dest));
status = U_ZERO_ERROR;
- len_dest = func(*buff_dest, len_dest, buff_source, len_source, mylocale->info.icu.locale, &status);
+ len_dest = func(*buff_dest, len_dest, buff_source, len_source,
+ mylocale->info.icu.locale, &status);
if (status == U_BUFFER_OVERFLOW_ERROR)
{
/* try again with adjusted length */
- pfree(buff_dest);
- buff_dest = palloc(len_dest * sizeof(**buff_dest));
+ pfree(*buff_dest);
+ *buff_dest = palloc(len_dest * sizeof(**buff_dest));
status = U_ZERO_ERROR;
- len_dest = func(*buff_dest, len_dest, buff_source, len_source, mylocale->info.icu.locale, &status);
+ len_dest = func(*buff_dest, len_dest, buff_source, len_source,
+ mylocale->info.icu.locale, &status);
}
if (U_FAILURE(status))
ereport(ERROR,
const char *locale,
UErrorCode *pErrorCode)
{
- return u_strToTitle(dest, destCapacity, src, srcLength, NULL, locale, pErrorCode);
+ return u_strToTitle(dest, destCapacity, src, srcLength,
+ NULL, locale, pErrorCode);
}
-#endif
+
+#endif /* USE_ICU */
/*
* If the system provides the needed functions for wide-character manipulation
UChar *buff_conv;
len_uchar = icu_to_uchar(&buff_uchar, buff, nbytes);
- len_conv = icu_convert_case(u_strToLower, mylocale, &buff_conv, buff_uchar, len_uchar);
+ len_conv = icu_convert_case(u_strToLower, mylocale,
+ &buff_conv, buff_uchar, len_uchar);
icu_from_uchar(&result, buff_conv, len_conv);
}
else
UChar *buff_conv;
len_uchar = icu_to_uchar(&buff_uchar, buff, nbytes);
- len_conv = icu_convert_case(u_strToUpper, mylocale, &buff_conv, buff_uchar, len_uchar);
+ len_conv = icu_convert_case(u_strToUpper, mylocale,
+ &buff_conv, buff_uchar, len_uchar);
icu_from_uchar(&result, buff_conv, len_conv);
}
else
UChar *buff_conv;
len_uchar = icu_to_uchar(&buff_uchar, buff, nbytes);
- len_conv = icu_convert_case(u_strToTitle_default_BI, mylocale, &buff_conv, buff_uchar, len_uchar);
+ len_conv = icu_convert_case(u_strToTitle_default_BI, mylocale,
+ &buff_conv, buff_uchar, len_uchar);
icu_from_uchar(&result, buff_conv, len_conv);
}
else
actual_versionstr = get_collation_actual_version(collform->collprovider, collcollate);
if (!actual_versionstr)
+ {
/* This could happen when specifying a version in CREATE
* COLLATION for a libc locale, or manually creating a mess
* in the catalogs. */
ereport(ERROR,
(errmsg("collation \"%s\" has no actual version, but a version was specified",
NameStr(collform->collname))));
+ }
collversionstr = TextDatumGetCString(collversion);
if (strcmp(actual_versionstr, collversionstr) != 0)
printf(_("\nOptions controlling the output:\n"));
printf(_(" -D, --pgdata=DIRECTORY receive base backup into directory\n"));
printf(_(" -F, --format=p|t output format (plain (default), tar)\n"));
- printf(_(" -r, --max-rate=RATE maximum transfer rate to transfer data directory\n"
- " (in kB/s, or use suffix \"k\" or \"M\")\n"));
- printf(_(" -R, --write-recovery-conf\n"
- " write recovery.conf for replication\n"));
+ printf(_(" -r, --max-rate=RATE maximum transfer rate to transfer data directory\n"));
+ printf(_(" (in kB/s, or use suffix \"k\" or \"M\")\n"));
+ printf(_(" -R, --write-recovery-conf\n"));
+ printf(_(" write recovery.conf for replication\n"));
printf(_(" -S, --slot=SLOTNAME replication slot to use\n"));
printf(_(" --no-slot prevent creation of temporary replication slot\n"));
- printf(_(" -T, --tablespace-mapping=OLDDIR=NEWDIR\n"
- " relocate tablespace in OLDDIR to NEWDIR\n"));
- printf(_(" -X, --wal-method=none|fetch|stream\n"
- " include required WAL files with specified method\n"));
+ printf(_(" -T, --tablespace-mapping=OLDDIR=NEWDIR\n"));
+ printf(_(" relocate tablespace in OLDDIR to NEWDIR\n"));
+ printf(_(" -X, --wal-method=none|fetch|stream\n"));
+ printf(_(" include required WAL files with specified method\n"));
printf(_(" --waldir=WALDIR location for the write-ahead log directory\n"));
printf(_(" -z, --gzip compress tar output\n"));
printf(_(" -Z, --compress=0-9 compress tar output with given compression level\n"));
printf(_("\nGeneral options:\n"));
- printf(_(" -c, --checkpoint=fast|spread\n"
- " set fast or spread checkpointing\n"));
+ printf(_(" -c, --checkpoint=fast|spread\n"));
+ printf(_(" set fast or spread checkpointing\n"));
printf(_(" -l, --label=LABEL set backup label\n"));
printf(_(" -n, --no-clean do not clean up after errors\n"));
printf(_(" -N, --no-sync do not wait for changes to be written safely to disk\n"));
printf(_(" -d, --dbname=CONNSTR connection string\n"));
printf(_(" -h, --host=HOSTNAME database server host or socket directory\n"));
printf(_(" -p, --port=PORT database server port number\n"));
- printf(_(" -s, --status-interval=INTERVAL\n"
- " time between status packets sent to server (in seconds)\n"));
+ printf(_(" -s, --status-interval=INTERVAL\n"));
+ printf(_(" time between status packets sent to server (in seconds)\n"));
printf(_(" -U, --username=NAME connect as specified database user\n"));
printf(_(" -w, --no-password never prompt for password\n"));
printf(_(" -W, --password force password prompt (should happen automatically)\n"));
else if (strcmp(type, "LANGUAGE") == 0)
CONVERT_PRIV('U', "USAGE");
else if (strcmp(type, "SCHEMA") == 0 ||
- strcmp(type, "SCHEMAS") == 0
- )
+ strcmp(type, "SCHEMAS") == 0)
{
CONVERT_PRIV('C', "CREATE");
CONVERT_PRIV('U', "USAGE");
WriteExtraTocPtrType WriteExtraTocPtr; /* Write extra TOC entry data
* associated with the current archive
* format */
- ReadExtraTocPtrType ReadExtraTocPtr; /* Read extr info associated with
- * archie format */
+ ReadExtraTocPtrType ReadExtraTocPtr; /* Read extra info associated with
+ * archive format */
PrintExtraTocPtrType PrintExtraTocPtr; /* Extra TOC info for format */
PrintTocDataPtrType PrintTocDataPtr;
printf(_(" -e, --end=RECPTR stop reading at WAL location RECPTR\n"));
printf(_(" -f, --follow keep retrying after reaching end of WAL\n"));
printf(_(" -n, --limit=N number of records to display\n"));
- printf(_(" -p, --path=PATH directory in which to find log segment files or a\n"
- " directory with a ./pg_wal that contains such files\n"
- " (default: current directory, ./pg_wal, PGDATA/pg_wal)\n"));
- printf(_(" -r, --rmgr=RMGR only show records generated by resource manager RMGR\n"
- " use --rmgr=list to list valid resource manager names\n"));
+ printf(_(" -p, --path=PATH directory in which to find log segment files or a\n"));
+ printf(_(" directory with a ./pg_wal that contains such files\n"));
+ printf(_(" (default: current directory, ./pg_wal, PGDATA/pg_wal)\n"));
+ printf(_(" -r, --rmgr=RMGR only show records generated by resource manager RMGR\n"));
+ printf(_(" use --rmgr=list to list valid resource manager names\n"));
printf(_(" -s, --start=RECPTR start reading at WAL location RECPTR\n"));
- printf(_(" -t, --timeline=TLI timeline from which to read log records\n"
- " (default: 1 or the value used in STARTSEG)\n"));
+ printf(_(" -t, --timeline=TLI timeline from which to read log records\n"));
+ printf(_(" (default: 1 or the value used in STARTSEG)\n"));
printf(_(" -V, --version output version information, then exit\n"));
printf(_(" -x, --xid=XID only show records with TransactionId XID\n"));
- printf(_(" -z, --stats[=record] show statistics instead of records\n"
- " (optionally, show per-record statistics)\n"));
+ printf(_(" -z, --stats[=record] show statistics instead of records\n"));
+ printf(_(" (optionally, show per-record statistics)\n"));
printf(_(" -?, --help show this help, then exit\n"));
}
*/
/* Complete GRANT/REVOKE with a list of roles and privileges */
else if (TailMatches1("GRANT|REVOKE"))
+ {
/*
* With ALTER DEFAULT PRIVILEGES, restrict completion
* to grantable privileges (can't grant roles)
" UNION SELECT 'EXECUTE'"
" UNION SELECT 'USAGE'"
" UNION SELECT 'ALL'");
-
+ }
/*
* Complete GRANT/REVOKE <privilege> with "ON", GRANT/REVOKE <role> with
* TO/FROM
* privilege.
*/
else if (TailMatches3("GRANT|REVOKE", MatchAny, "ON"))
+ {
/*
* With ALTER DEFAULT PRIVILEGES, restrict completion
* to the kinds of objects supported.
" UNION SELECT 'TABLE'"
" UNION SELECT 'TABLESPACE'"
" UNION SELECT 'TYPE'");
-
+ }
else if (TailMatches4("GRANT|REVOKE", MatchAny, "ON", "ALL"))
COMPLETE_WITH_LIST3("FUNCTIONS IN SCHEMA", "SEQUENCES IN SCHEMA",
"TABLES IN SCHEMA");
-
else if (TailMatches4("GRANT|REVOKE", MatchAny, "ON", "FOREIGN"))
COMPLETE_WITH_LIST2("DATA WRAPPER", "SERVER");
scram_ServerKey(salted_password, server_key);
- /*
+ /*----------
* The format is:
* SCRAM-SHA-256$<iteration count>:<salt>$<StoredKey>:<ServerKey>
+ *----------
*/
maxlen = strlen("SCRAM-SHA-256") + 1
+ 10 + 1 /* iteration count */
* The uppercase quantities will be replaced at initdb time with
* user choices.
*
- * If adding new default roles or changing the OIDs below, be sure to add or
- * update the #defines which follow as appropriate.
+ * The C code typically refers to these roles using the #define symbols,
+ * so be sure to keep those in sync with the DATA lines.
* ----------------
*/
DATA(insert OID = 10 ( "POSTGRES" t t t t t t t -1 _null_ _null_));
-DATA(insert OID = 3373 ( "pg_monitor" f t f f f f f -1 _null_ _null_));
-DATA(insert OID = 3374 ( "pg_read_all_settings" f t f f f f f -1 _null_ _null_));
-DATA(insert OID = 3375 ( "pg_read_all_stats" f t f f f f f -1 _null_ _null_));
-DATA(insert OID = 3377 ( "pg_stat_scan_tables" f t f f f f f -1 _null_ _null_));
-DATA(insert OID = 4200 ( "pg_signal_backend" f t f f f f f -1 _null_ _null_));
-
#define BOOTSTRAP_SUPERUSERID 10
-
+DATA(insert OID = 3373 ( "pg_monitor" f t f f f f f -1 _null_ _null_));
#define DEFAULT_ROLE_MONITOR 3373
+DATA(insert OID = 3374 ( "pg_read_all_settings" f t f f f f f -1 _null_ _null_));
#define DEFAULT_ROLE_READ_ALL_SETTINGS 3374
+DATA(insert OID = 3375 ( "pg_read_all_stats" f t f f f f f -1 _null_ _null_));
#define DEFAULT_ROLE_READ_ALL_STATS 3375
+DATA(insert OID = 3377 ( "pg_stat_scan_tables" f t f f f f f -1 _null_ _null_));
#define DEFAULT_ROLE_STAT_SCAN_TABLES 3377
+DATA(insert OID = 4200 ( "pg_signal_backend" f t f f f f f -1 _null_ _null_));
#define DEFAULT_ROLE_SIGNAL_BACKENDID 4200
#endif /* PG_AUTHID_H */
* substate constants
* ----------------
*/
-#define SUBREL_STATE_INIT 'i' /* initializing (sublsn NULL) */
-#define SUBREL_STATE_DATASYNC 'd' /* data is being synchronized (sublsn NULL) */
-#define SUBREL_STATE_SYNCDONE 's' /* synchronization finished infront of apply (sublsn set) */
-#define SUBREL_STATE_READY 'r' /* ready (sublsn set) */
+#define SUBREL_STATE_INIT 'i' /* initializing (sublsn NULL) */
+#define SUBREL_STATE_DATASYNC 'd' /* data is being synchronized (sublsn NULL) */
+#define SUBREL_STATE_SYNCDONE 's' /* synchronization finished in front of apply (sublsn set) */
+#define SUBREL_STATE_READY 'r' /* ready (sublsn set) */
/* These are never stored in the catalog, we only use them for IPC. */
-#define SUBREL_STATE_UNKNOWN '\0' /* unknown state */
-#define SUBREL_STATE_SYNCWAIT 'w' /* waiting for sync */
-#define SUBREL_STATE_CATCHUP 'c' /* catching up with apply */
+#define SUBREL_STATE_UNKNOWN '\0' /* unknown state */
+#define SUBREL_STATE_SYNCWAIT 'w' /* waiting for sync */
+#define SUBREL_STATE_CATCHUP 'c' /* catching up with apply */
typedef struct SubscriptionRelState
{
/* Tuple coming via logical replication. */
typedef struct LogicalRepTupleData
{
- char *values[MaxTupleAttributeNumber]; /* value in out function format or NULL if values is NULL */
- bool changed[MaxTupleAttributeNumber]; /* marker for changed/unchanged values */
+ /* column values in text format, or NULL for a null value: */
+ char *values[MaxTupleAttributeNumber];
+ /* markers for changed/unchanged column values: */
+ bool changed[MaxTupleAttributeNumber];
} LogicalRepTupleData;
typedef uint32 LogicalRepRelId;
char *krbsrvname; /* Kerberos service name */
#endif
- char *target_session_attrs; /* Type of connection to make
- * Possible values any, read-write. */
+ /* Type of connection to make. Possible values: any, read-write. */
+ char *target_session_attrs;
/* Optional file to write trace info to */
FILE *Pfdebug;