break;
case OVSDB_TYPE_STRING:
+#ifdef HAVE_PCRE
base->u.string.re = NULL;
+#endif
base->u.string.reMatch = NULL;
base->u.string.reComment = NULL;
base->u.string.minLen = 0;
break;
case OVSDB_TYPE_UUID:
+ base->u.uuid.refTableName = NULL;
+ base->u.uuid.refTable = NULL;
break;
case OVSDB_N_TYPES:
break;
case OVSDB_TYPE_STRING:
+#if HAVE_PCRE
if (dst->u.string.re) {
pcre_refcount(dst->u.string.re, 1);
}
+#else
+ if (dst->u.string.reMatch) {
+ dst->u.string.reMatch = xstrdup(dst->u.string.reMatch);
+ }
+ if (dst->u.string.reComment) {
+ dst->u.string.reComment = xstrdup(dst->u.string.reComment);
+ }
+#endif
break;
+
case OVSDB_TYPE_UUID:
+ if (dst->u.uuid.refTableName) {
+ dst->u.uuid.refTableName = xstrdup(dst->u.uuid.refTableName);
+ }
break;
case OVSDB_N_TYPES:
break;
case OVSDB_TYPE_STRING:
+#ifdef HAVE_PCRE
if (base->u.string.re && !pcre_refcount(base->u.string.re, -1)) {
pcre_free(base->u.string.re);
free(base->u.string.reMatch);
free(base->u.string.reComment);
}
+#else
+ free(base->u.string.reMatch);
+ free(base->u.string.reComment);
+#endif
break;
case OVSDB_TYPE_UUID:
+ free(base->u.uuid.refTableName);
break;
case OVSDB_N_TYPES:
|| base->u.string.maxLen != UINT_MAX);
case OVSDB_TYPE_UUID:
- return false;
+ return base->u.uuid.refTableName != NULL;
case OVSDB_N_TYPES:
NOT_REACHED();
ovsdb_base_type_set_regex(struct ovsdb_base_type *base,
const char *reMatch, const char *reComment)
{
+#ifdef HAVE_PCRE
const char *errorString;
const char *pattern;
int errorOffset;
if (pattern[0] == '\0' || strchr(pattern, '\0')[-1] != '$') {
pattern = xasprintf("%s$", pattern);
}
+
+#ifndef PCRE_JAVASCRIPT_COMPAT /* Added in PCRE 7.7. */
+#define PCRE_JAVASCRIPT_COMPAT 0
+#endif
base->u.string.re = pcre_compile(pattern, (PCRE_ANCHORED | PCRE_UTF8
| PCRE_JAVASCRIPT_COMPAT),
&errorString, &errorOffset, NULL);
"\"%s\" is not a valid regular "
"expression: %s", reMatch, errorString);
}
+ pcre_refcount(base->u.string.re, 1);
+#endif
/* Save regular expression. */
- pcre_refcount(base->u.string.re, 1);
base->u.string.reMatch = xstrdup(reMatch);
base->u.string.reComment = reComment ? xstrdup(reComment) : NULL;
return NULL;
error = ovsdb_syntax_error(json, NULL,
"minLength exceeds maxLength");
}
+ } else if (base->type == OVSDB_TYPE_UUID) {
+ const struct json *refTable;
+
+ refTable = ovsdb_parser_member(&parser, "refTable",
+ OP_ID | OP_OPTIONAL);
+ if (refTable) {
+ base->u.uuid.refTableName = xstrdup(refTable->u.string);
+ /* We can't set base->u.uuid.refTable here because we don't have
+ * enough context (we might not even be running in ovsdb-server).
+ * ovsdb_create() will set refTable later. */
+ }
}
if (error) {
break;
case OVSDB_TYPE_UUID:
+ if (base->u.uuid.refTableName) {
+ json_object_put_string(json, "refTable",
+ base->u.uuid.refTableName);
+ }
break;
case OVSDB_N_TYPES:
&& ovsdb_base_type_is_valid(&type->key)
&& ovsdb_base_type_is_valid(&type->value)
&& type->n_min <= 1
- && type->n_min <= type->n_max);
+ && type->n_min <= type->n_max
+ && type->n_max >= 1);
}
static struct ovsdb_error *