Commit f5297bdf authored by Tom Lane's avatar Tom Lane

Refer to the default foreign key match style as MATCH SIMPLE internally.

Previously we followed the SQL92 wording, "MATCH <unspecified>", but since
SQL99 there's been a less awkward way to refer to the default style.

In addition to the code changes, pg_constraint.confmatchtype now stores
this match style as 's' (SIMPLE) rather than 'u' (UNSPECIFIED).  This
doesn't affect pg_dump or psql because they use pg_get_constraintdef()
to reconstruct foreign key definitions.  But other client-side code might
examine that column directly, so this change will have to be marked as
an incompatibility in the 9.3 release notes.
parent bb7520cc
...@@ -2010,7 +2010,7 @@ ...@@ -2010,7 +2010,7 @@
<entry>Foreign key match type: <entry>Foreign key match type:
<literal>f</> = full, <literal>f</> = full,
<literal>p</> = partial, <literal>p</> = partial,
<literal>u</> = simple (unspecified) <literal>s</> = simple
</entry> </entry>
</row> </row>
......
...@@ -1160,7 +1160,7 @@ CREATE VIEW referential_constraints AS ...@@ -1160,7 +1160,7 @@ CREATE VIEW referential_constraints AS
CAST( CAST(
CASE con.confmatchtype WHEN 'f' THEN 'FULL' CASE con.confmatchtype WHEN 'f' THEN 'FULL'
WHEN 'p' THEN 'PARTIAL' WHEN 'p' THEN 'PARTIAL'
WHEN 'u' THEN 'NONE' END WHEN 's' THEN 'NONE' END
AS character_data) AS match_option, AS character_data) AS match_option,
CAST( CAST(
......
...@@ -805,7 +805,7 @@ ConvertTriggerToFK(CreateTrigStmt *stmt, Oid funcoid) ...@@ -805,7 +805,7 @@ ConvertTriggerToFK(CreateTrigStmt *stmt, Oid funcoid)
char *constr_name; char *constr_name;
char *fk_table_name; char *fk_table_name;
char *pk_table_name; char *pk_table_name;
char fk_matchtype = FKCONSTR_MATCH_UNSPECIFIED; char fk_matchtype = FKCONSTR_MATCH_SIMPLE;
List *fk_attrs = NIL; List *fk_attrs = NIL;
List *pk_attrs = NIL; List *pk_attrs = NIL;
StringInfoData buf; StringInfoData buf;
...@@ -831,7 +831,7 @@ ConvertTriggerToFK(CreateTrigStmt *stmt, Oid funcoid) ...@@ -831,7 +831,7 @@ ConvertTriggerToFK(CreateTrigStmt *stmt, Oid funcoid)
if (strcmp(strVal(arg), "FULL") == 0) if (strcmp(strVal(arg), "FULL") == 0)
fk_matchtype = FKCONSTR_MATCH_FULL; fk_matchtype = FKCONSTR_MATCH_FULL;
else else
fk_matchtype = FKCONSTR_MATCH_UNSPECIFIED; fk_matchtype = FKCONSTR_MATCH_SIMPLE;
continue; continue;
} }
if (i % 2) if (i % 2)
......
...@@ -2972,11 +2972,11 @@ key_match: MATCH FULL ...@@ -2972,11 +2972,11 @@ key_match: MATCH FULL
} }
| MATCH SIMPLE | MATCH SIMPLE
{ {
$$ = FKCONSTR_MATCH_UNSPECIFIED; $$ = FKCONSTR_MATCH_SIMPLE;
} }
| /*EMPTY*/ | /*EMPTY*/
{ {
$$ = FKCONSTR_MATCH_UNSPECIFIED; $$ = FKCONSTR_MATCH_SIMPLE;
} }
; ;
......
This diff is collapsed.
...@@ -1184,7 +1184,7 @@ pg_get_constraintdef_worker(Oid constraintId, bool fullCommand, ...@@ -1184,7 +1184,7 @@ pg_get_constraintdef_worker(Oid constraintId, bool fullCommand,
case FKCONSTR_MATCH_PARTIAL: case FKCONSTR_MATCH_PARTIAL:
string = " MATCH PARTIAL"; string = " MATCH PARTIAL";
break; break;
case FKCONSTR_MATCH_UNSPECIFIED: case FKCONSTR_MATCH_SIMPLE:
string = ""; string = "";
break; break;
default: default:
......
...@@ -53,6 +53,6 @@ ...@@ -53,6 +53,6 @@
*/ */
/* yyyymmddN */ /* yyyymmddN */
#define CATALOG_VERSION_NO 201206141 #define CATALOG_VERSION_NO 201206171
#endif #endif
...@@ -1514,7 +1514,7 @@ typedef enum ConstrType /* types of constraints */ ...@@ -1514,7 +1514,7 @@ typedef enum ConstrType /* types of constraints */
/* Foreign key matchtype codes */ /* Foreign key matchtype codes */
#define FKCONSTR_MATCH_FULL 'f' #define FKCONSTR_MATCH_FULL 'f'
#define FKCONSTR_MATCH_PARTIAL 'p' #define FKCONSTR_MATCH_PARTIAL 'p'
#define FKCONSTR_MATCH_UNSPECIFIED 'u' #define FKCONSTR_MATCH_SIMPLE 's'
typedef struct Constraint typedef struct Constraint
{ {
...@@ -1550,7 +1550,7 @@ typedef struct Constraint ...@@ -1550,7 +1550,7 @@ typedef struct Constraint
RangeVar *pktable; /* Primary key table */ RangeVar *pktable; /* Primary key table */
List *fk_attrs; /* Attributes of foreign key */ List *fk_attrs; /* Attributes of foreign key */
List *pk_attrs; /* Corresponding attrs in PK table */ List *pk_attrs; /* Corresponding attrs in PK table */
char fk_matchtype; /* FULL, PARTIAL, UNSPECIFIED */ char fk_matchtype; /* FULL, PARTIAL, SIMPLE */
char fk_upd_action; /* ON UPDATE action */ char fk_upd_action; /* ON UPDATE action */
char fk_del_action; /* ON DELETE action */ char fk_del_action; /* ON DELETE action */
List *old_conpfeqop; /* pg_constraint.conpfeqop of my former self */ List *old_conpfeqop; /* pg_constraint.conpfeqop of my former self */
......
...@@ -339,7 +339,7 @@ SELECT * FROM PKTABLE; ...@@ -339,7 +339,7 @@ SELECT * FROM PKTABLE;
DROP TABLE FKTABLE; DROP TABLE FKTABLE;
DROP TABLE PKTABLE; DROP TABLE PKTABLE;
-- MATCH unspecified -- MATCH SIMPLE
-- Base test restricting update/delete -- Base test restricting update/delete
CREATE TABLE PKTABLE ( ptest1 int, ptest2 int, ptest3 int, ptest4 text, PRIMARY KEY(ptest1, ptest2, ptest3) ); CREATE TABLE PKTABLE ( ptest1 int, ptest2 int, ptest3 int, ptest4 text, PRIMARY KEY(ptest1, ptest2, ptest3) );
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "pktable_pkey" for table "pktable" NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "pktable_pkey" for table "pktable"
......
...@@ -214,7 +214,7 @@ DROP TABLE FKTABLE; ...@@ -214,7 +214,7 @@ DROP TABLE FKTABLE;
DROP TABLE PKTABLE; DROP TABLE PKTABLE;
-- MATCH unspecified -- MATCH SIMPLE
-- Base test restricting update/delete -- Base test restricting update/delete
CREATE TABLE PKTABLE ( ptest1 int, ptest2 int, ptest3 int, ptest4 text, PRIMARY KEY(ptest1, ptest2, ptest3) ); CREATE TABLE PKTABLE ( ptest1 int, ptest2 int, ptest3 int, ptest4 text, PRIMARY KEY(ptest1, ptest2, ptest3) );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment