s/UNSPECIFIED/SIMPLE/ in foreign key code?
Our foreign-key-related code uses MATCH_UNSPECIFIED to denote the
default foreign key match behavior. This corresponds to the wording
used in the SQL92 spec, for instance "If <match type> is not specified
or if FULL is specified, ...". But I always found it rather confusing;
it sounds like we don't know what match behavior we're supposed to
implement.
I notice that in SQL99 and later, the SQL committee introduced "MATCH
SIMPLE" as a way to name the behavior that formerly had no name.
So now they can write things like "If M specifies SIMPLE or FULL, ..."
which seems much nicer to me.
I think it would be a useful advance in readability if we replaced
UNSPECIFIED by SIMPLE throughout the FK code, and barring objections
I will go do that.
A small flaw in this plan is that in pg_constraint.confmatchtype,
MATCH_UNSPECIFIED is stored as 'u'. In a green field I'd just rename
that to 's' for SIMPLE, but it seems possible that this would confuse
client-side code such as pg_dump or psql. A quick look shows that
neither of those programs actually look directly at
pg_constraint.confmatchtype, instead relying on backend functions when
they want to deconstruct a foreign key constraint. But there could well
be other client code that would notice the change. So I'm a bit torn
as to whether to change it and create a release-note-worthy
compatibility issue, or to leave it as-is (with documentation notes that
"u" for MATCH_SIMPLE is a historical accident).
Thoughts?
regards, tom lane
A small flaw in this plan is that in pg_constraint.confmatchtype,
MATCH_UNSPECIFIED is stored as 'u'. In a green field I'd just rename
that to 's' for SIMPLE, but it seems possible that this would confuse
client-side code such as pg_dump or psql. A quick look shows that
neither of those programs actually look directly at
pg_constraint.confmatchtype, instead relying on backend functions when
they want to deconstruct a foreign key constraint. But there could well
be other client code that would notice the change. So I'm a bit torn
as to whether to change it and create a release-note-worthy
compatibility issue, or to leave it as-is (with documentation notes that
"u" for MATCH_SIMPLE is a historical accident).
As user can also query system tables, so might be some of the application
have
also used this column's value. However I don't know if any has used.
I believe as this is not helping in a big way to adhere to standards,
so it is okay to keep "u" for MATCH SIMPLE.
I notice that in SQL99 and later, the SQL committee introduced "MATCH
SIMPLE" as a way to name the behavior that formerly had no name.
One of the documents which I referred as SQL-2003 specs says option is NONE.
The document which I referred is attached in mail.
I am sorry, if this is not the right document or I have mis-interpreted it.
I have downloaded SQL-2003 specs by following site.
http://en.wikipedia.org/wiki/SQL:2003
-----Original Message-----
From: pgsql-hackers-owner@postgresql.org
[mailto:pgsql-hackers-owner@postgresql.org] On Behalf Of Tom Lane
Sent: Sunday, June 17, 2012 3:08 AM
To: pgsql-hackers@postgreSQL.org
Subject: [HACKERS] s/UNSPECIFIED/SIMPLE/ in foreign key code?
Our foreign-key-related code uses MATCH_UNSPECIFIED to denote the
default foreign key match behavior. This corresponds to the wording
used in the SQL92 spec, for instance "If <match type> is not specified
or if FULL is specified, ...". But I always found it rather confusing;
it sounds like we don't know what match behavior we're supposed to
implement.
I notice that in SQL99 and later, the SQL committee introduced "MATCH
SIMPLE" as a way to name the behavior that formerly had no name.
So now they can write things like "If M specifies SIMPLE or FULL, ..."
which seems much nicer to me.
I think it would be a useful advance in readability if we replaced
UNSPECIFIED by SIMPLE throughout the FK code, and barring objections
I will go do that.
A small flaw in this plan is that in pg_constraint.confmatchtype,
MATCH_UNSPECIFIED is stored as 'u'. In a green field I'd just rename
that to 's' for SIMPLE, but it seems possible that this would confuse
client-side code such as pg_dump or psql. A quick look shows that
neither of those programs actually look directly at
pg_constraint.confmatchtype, instead relying on backend functions when
they want to deconstruct a foreign key constraint. But there could well
be other client code that would notice the change. So I'm a bit torn
as to whether to change it and create a release-note-worthy
compatibility issue, or to leave it as-is (with documentation notes that
"u" for MATCH_SIMPLE is a historical accident).
Thoughts?
regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Attachments:
5WD-11-Schemata-2003-09.rarapplication/octet-stream; name=5WD-11-Schemata-2003-09.rarDownload
Rar! ��s
bt��; l�
�o ���/3 5WD-11-Schemata-2003-09.pdfL�L��Y��� `�`�T�������)����BR%"Ys�8R(H�w��y�s�{�}���9��I�����_�4��5����yYoz{�����
9��9YApQ~��W|����p�q�e�����H������E��(k���
��c�e'��XXd^Y���
���?h�p��E(�6����X���E`
����4������sB����,���}���d������1Q���7 `Y�r�����8�a��[�x+�qqg�b�����w�� *���_�N/*,���
��2����>��s"�����1-�T�����;x��d�"����ee�3|�������a}�q���I+�'�qQJ;B�g������v�S�RJP<���K�7;R5 X^Z`�U�-[\0��w�<�+K��1,��������,�p�p�ea`�_�-����XZ�����V��;W}��a���J�h������Gb����k���K����I�������bX�����_�]�������}�"��_��w�t��0���7r6S����F��2�p�*���w�f���k�~�1).��%O��4����LIg;�}�M���,�6���&d�o'�lF��b�66�Aem'�r�+*���>�m^u�x:r��
�������K�U��W���.�.� a��]��l
����P6��81k�Vz�c�7O���F�J���H`r#�1�U+%�?�p��������q�_�]������C��<i4^y�(��1
�h!��}�b����� �-���}t�m��y���<���ZEZi���Je:�{!n���b��[���&�Z����e�Jr?y�C
��<��+NR��w�J�&j��=�{��������d���f��A�F�f�6a����H�i���1��5��L��j%����zs+v�
�Bp��|Z�4
���H@�(�@��gl�Y02S���.���E����?!�
]vnGB��f�o�%�4���lE��������*��D�5|�vWRR_�w��/�Do��d��C0� V ����o��o�u+g=��g��,�D��t��)%Z�� ��aI�Xw�9{�`M �4�:����\��@�*sk� 2���L�usK'w��/�(�~o-^?N��|�+��'Ns.���_�����]����4�L�J�����O����SX��LR�v������!{�c}f������V�s5�N4,���5�+��S�76r�'�H�^���~������*�m��
U�ro(���i�����o�g%�����z��`�pY����|A����5�7��2�aJS����~�i�O
*��OT���9�w���E���I+a��;�}R�����ZA�V��p5'ofpf����.B�31��)|D����D�V&k���;�7W�8�~%ll��{\�m0+��/8���R��� �������&^��,RR�,�����+O+VU ���N����i2<�&.7�b&J40�Pa���p�YS�e��y���1�E(�v�\s�m�,��9E���rAG�:�u���*�\�>����y�:9}�:F%�z�tq�^W����P�r�(c3��YQ@��4�����l�R77������y�u�i���H���!��":$����1Zj8`k��v�v��L���&K�$5?�*�
��*f��D"����� �}�K���Lj���*��q6X���~K�z.D�;�.����K�kq��L4�����~j���UjE���Q�����������cq��^b�V2�z����Zu�*V������N��;=`���LU]��y>��U'zbo�"��z��*���B{�����@������O8b�.|�W�p��S+QS���Et���yA��_5I ���t*#�>��� �WFM�R�trj�p8K���F��� ���9��/���7�G�|�P�~�|�P��)��~�G��Tj@T:�+fi�Cc���h6�J0��t3���1���d�S�u3���-`�6n�fVY��AfgW7����l���:�,(T����~:'�F,�����JX+f��yT��+x[���8����'������G���x�.V����`o�K@�LE�\j�A�9C��s���~��
������p&������np@�t�O��9UL������p�tcn-��>;��H�&�='�#.Vc��X�{$��[i�L9�*����F����U��`q��J�P���n,����#����m�{F���<��o�p�AG�� ��_<�������Lb���������|��%BDc��Fh���Xr�A/�T��4���)��$5�U��4�NV�m���y�=�b����-���TF�Slq�2.%����+@c�����W�0��H4�.N����.����k(�(;�?6�=���� D�!�L)�W�%:��
#4����5����A�[<�6�l��k����tH�g�Tz�T��Ec1��G��I���������B�6>g&� �4����x�:��Dn���D}��,�-
<Va����������&��Z~��<�1P� �T������z(3����(bQ�a��g#��U��oytg����_q��Ho�d�_������U�x�WO�Wm� �S�����;���z��z&��eR~!�e��+U �~�
�{�*So
|x>��-��2|o���Dx5�>B������#�P���BG]��x�L��mco�����MH �������cg+�����h`�a�~b����AL�GX�������~��pb�����Q��(�o8����;��2�O~��w�F� ���f H�����)���H��<��J�?J��6��DH��=����+�:��7��+=����7!l�/�*`M�c���eH1gt4h�2��to<�z-��W�)?2p��g�8�o
��Zev�8���O-�E!�2O@�`h�� s8�������}���T`6��3z8�b��Lw�G��Gwv!"���<��y# y���I�@��X����>�;�O��+��%�����&{����^GX]\i��@��� m���'K
KL��(�9���>7�:CXY\b�� ��E��[�?������R�?�Lw�!��
����iW�'L��_����F?����4vevd���Y~�|��.� m}`���K�G/�����"����Vo�Q'�#+[B��h-+�A_�_�� L�5v�i/�>�w���/�&��6]�iie�Y�l%�������|d��K?)��X������v{���sW���>J�����
�G������|s�u����N��K���)��p�����9Xi\��!!"���WN�S[CzR��� 9�����Z��� vH����8�JSZ�Wj�-��s�W�"r�B�3S/�}�q�kC�p�����[��_�\`��U����a�b'���q��?���f�ba� �S�����vIZa��ag���*���pZ\\_�;�\�k2��/��l���jZ]�����O������r����a���������,�����|v$���2�-,��Y���a�N���C����������;=��;m�������[�o��v�|��S���'��!�����~�X����is >���?����}��V��f@>������j�����v��� ~Dg�\����V]�t;)}���Ai�������o��[�e�|����_~�W�����,���T�����C�l�R��`*�����|��pU��e_����|�����(U��������`�� �/�_�#�? 3����k#�A{�����N@~��u����v��NGh�S�����7����;w���'������J������������W�x}����W��^������(�s�����d��>k(*,)ef���+�m4��u"������}�)}��*���R��>�/�����!|d��~���������.�H;R��'���o,��f_���Rf�FC"��O�goD?����%�����Z���~z,��?���a��q}uy�����o�w�����o@����gE������vt�_Z8d]b��7�l���so$�^~W����+/��a%���/h\j�L��'�/�$����_�?���^�b�����k�3?w<X_�L����vp��t��><��?���S/��}���a�����������".{������\�����;��u�|�i\l���*_[�.����]O�^;&�]9�1�����qr���x")����4����|��G��9��6�I
�P�F���4J<��v�C�R���4[(2�d`��+��hk��"R- ��]�6�)��tj����5:��A��<t��!�jmO�n���{����Zf@��G�0��A�/���N�,�������� ��'fj�K���
M��NDPN<��K�a{���t%��F�li���pLAZ%%�u���ey�^����$�a���Us`&�� ��1# �Z�=q'�I9���%����^���o�I+�� @����?n?�>! :D�h������#&��B\�%�0�!� ������7�'��A�e1�����K�(2t��Mj�X�MasU^4 �vZ��I�p *����"��1����pO%�<���D����Y��gx�����8�x *���-�����S7��q�P<t��x`�F���t��~��G�:��������3�{��%�{�#uy}Zv]�V���j;� ���Y=�V���Xo
�mZeb��rg���
e�kCF��n��O#W���:���7s�
�]b[���YS�Or���q� >p��.�r��]����\Z�6(�������.��Dt�*�>+�$�e�����da��@���Y�!R����M�#8����a��kzm��a������^DJ���H�5w�N�P��z��������p�G��?��c�{\��0�r���I�]L@,���&����
�����C�'�9"8����ql�1w%��>=���c�_�i=|z��:C%D�����-�`POmV9oO%���������pC��W.}_g�}#M��~����s�R��?��y�I����8j
����������bP�( b���e���@�����$]����j�y����W�j5��o�l�@��P���_Q�G����?�A��|��_8��{WGp:�
m���^��
�]h������� D4�m�
A�A����l�2�k���
K<�0�e�~8 �����fV�t`��:W�F��U=lR2$l]V]�S�m���-���u�<������Q|M���P�H�?])��nSUWw4��V��k�f�,�7����w�y@���Nz ���S/�NI��~?� ���|\���`?l��|����v~6g�����H�|��=T����G������1������*�P�����n�����}��|��{���W�z?9e�?���������������%��S���T��1wi����>�r���Y_��7�"ol����[�����������qW��?\ ����g��1�d XY�@���><
�������1�� �w/��WV��� �?�������Y�?�U��������"���������?��������T� |����v��w�-202�����?���`F*�Y R�9� X�l�c�0�.�l��9^80�\{j$��6��i��Y������
�!����Z"&�h �Q�/�~P�q�� �/@ ��\��`���G�|]}����"C��cVelg�M�2��{�v``rL��G3+�������.+w�}�������{������*�m���Xk0��sy�������5*5f�me� W���@x��+{��46C���N^�Gb������m�Ve-�n�8&������n5dn�����Cv^��<
_�������x���26���l[�7(:�z�����!��K���/����i�e/��V�k3��u��)��*5t���<��j�6��q:����8u[����]~�E�J�w 5��SW����@}.����U�U��D���qP
��3cC9����I���^���S�w�#jM4p]�V�14�s"z�b�"����L+; \�@��,�7����{����� ��O�B%��%`����<��^&�;B����A��A[;a-�D�6c��*u�Cp�K��4ze�!$�(�~�8B��,�NlJV�#%�a���}<2B�G���S�l�c�N���Ni=]m��K����t�6���Tl�Al"�b�6�_Z>�{����P������+�!�Yoi�������(P��hi����?cDknXL\�D� ������p�b�Ws����-~�/h@Z�7����,�v
��I���8�?M1��� �W�A����,$Q����WC� �%�[r����b):���a`��`<���
��y$
z�|�Q�Q�q]�sN
o��� -���x*L,���q�gg�����L9DB������Z���������3HX�z�f5�i`�9�����v��V,���`�>G��y��:���q4k<�%#i�����9E��A����k���:&��Ka�T>a�[�P��K��r�A��i�Jf��9)����x|��~w� ?��[���*��/�����&z�Y��e���j"�*\_m�PI�U����������m�#�7�=�Gi�/Lo���B�%5R�����O?D,bd��>����c��L���b���[�[�[wzZ�PqRE�&����;�^����<&(����m���'4�r"�8e2�s�e��`iV?=��H�CmLM�J.j?qj��f�9�j$*$|����G TD�*0������ e��>\����d�z!ctAN������]�C��$�w���������"l�`�����O�/q��c
l�v��x�y�����b�tP��}�#�r"'�)�k����v���K��k�::���X���
�%�1�0���M������H��k-K����O
4�j���<t�0�p��`����S�oS�V�Y'v�'���;��4^���3h������v��6%��%?;�?�!$:-����R�dJ�sK��h��(�@*���.
���.4�D�(UX�T����Cda*��7����*�'Sct����g����Xi���$����l�Gk��Bm���kWP� �z7H6����{��I�����~ay�����(���_\[G�z���!�'�����|�
V"�:H���K��r5�9z�X��mYC�H]8X�_p�w����`� �%����R�[��f��}�����AV���������a��.Q����V���Y����#��<�������cl}����;^�V|�|�Zl���a����F��5Z��jvbX!$�
����SRi;`����%�t��4c���g$����GUo��eW7ho�����������P�������M=��ne�W�hx�z�� ��B*�'����$�����7�z��u�U���hMv+���Ug�9��>^'�'4{(gwF������H�c+X���UuN3XU+�����-�I29d4
������=�E~*R%�,��GVR?��V������A�{�\
��$7����UZ�2@���A�o����S�/Q��.&�s�0���)9��$�)����If�(�d���*��2T��Z�0n,u��R�"�]��0�{��4�3���
��:���a���@��l��CH|�����_lXN$D���x���mU���^�4�~+��4�gr|����k����SN{�
7�?&���K�[������D.H4!���.'����92�t��pY��3��3xr��u�knu������&j����D��f!:i�+1�����!8 �~w�1\Y����$�w{7\��Li���������L���]�R;����\�'�*p@r��F-���03���X��;�W�y���J�X�1�-+�.��S,���_���p%a,��� <���0���iY�rkqm�����Nv������W0OP� ��=���1��w��k,����o\��`�_�$&� k��]e*���z4M��{K��Z�r*,�[�6���J���cE?sW�����q0W(F�o
����B��Z������=�>������h`�\��'�+9�����oRc]<)�=a:���>�y��.f�+��f�V�;�^����+T�����?��������l�a�t�N��K������+��=����Qr�`����s�w��Hz�F�����-��r��_^��d��/���}Z���;HHu�\��,%d"����gs��@IJ3�K`�N�e��E^$��d6��Y<�7��������#��n/%27���{O+U��R��P�(,2�������
��P/�>L4�n^�w�Z�_p���"�O���d�6��Y��t������'�V�,���#SZ^<
Y;a'`�D��h���C��f
�4�)����r(�y���d���@�ih�M�$�*Wk���6�,�:-�US3)�1�_R6��2+��g��k�;~���F�o��g�ty�tZ6���r@���������1�-�������i9�9��Hm�]�S���x����� d~��9��t,H[�s�$�K_�J��Jh�f���|��O����(n�9}.�.�j�b1mM��t�
6����/2aT�ZQ�����I_r�{�]a�Z!`�������[��^����m�l[#U�����n��7�������-��`�j�
��u^~u��#^P.$��Am������3�:��Ud6�6���"��Z3$�}�5��P
~lO;�]�>Db0�IS��%�hr���V��:[��-yd��m��i�n]����}n��m����I�~�����������f��POZ#���������k��1"�7�
l�c�D�7����Vm]=v�� gK)uh������,S`�'8�V���Cc��!�i��}����W=M�d�M����K
+��
kn%�_^��dP��������uEF�H1�E�q�D_�o���w�8�!�w[�������#{-*}�����#a�u:��]�L�xd�h#�h��.G0p��m+9��H��]����2a��,x�l��k.!��X8��P�~���#�)#�1/>���]h�����O�����+Z���j��eRDY
��� �`��`��Y�H����]�������#�M���p��v�% D?@�������P�Qd�$W�|�t6���4�T��)E^ �����ByN��0f�Q�7��H�W��Clt�*�m�h�d�������=n���xo3��*����Y��[h
:(���7��'�/W�����w,����z i{������O���(T$U�y����\Wg�� ���6 �j���A1�l�V��i`�����)S0�������P�)�X-U4���p��0w�"���`z#8Es5V�����0� 0I��De���gHl��z�E�A1��G����(X���ip����9_�J��0�,����#�&�4�&
:�l���W9f���q0�Y �GLi�<�����E�M�~F�'�2���:n�v�NWF�/��l������.�0��$*��}�t �X+�-�-Imu`����2{'+����V"c��x����7��s�f�����C��K��-��|�x�1d� ]�����]�c�N�����������<WC
����������+�s,�#�j7;�@\����.�
�+Oo���slm�O��5T��e
�E���H�
�u��z����4�QpozC 7+F4���~��l��g�����������'�Y���-`�]&,�O�Qn���#z0��
f��3^�M���x��#�V�����z'�qM��gw��q��.~����N������-:B�7C�!]�~����e���S��r�&�C
�-��Bx�<��
����"V����Pd���p�y:��6�u�;C���cw=���G�U�n{O�b�`��V��Z3'S��o?��"��^�I*3M��B%�<����KA�V�������8�CfI�$�.���hC��]�#DLXj+�?9�]0��6�� @x �1#�I�b��iddr� �(_�;�(��`�<��.>���*iN!yV����(6����;���N(Zm��&������������`*$2n���R
��$@�mLx`�Xn< ^J��Q5��h��o�,�##�W�u���5���F��y��&I��g��4P�����hM�w����N,}H�7������~��EY����g�_A�WX$���(�`�S1�.%N��F�0x��elxT����vH�Qi�)c��id�����b�_M=J�H��W�
�N^G.�FY
��sy����W�W��0,^1In���Q���W#o�7���Et���7�|E��W\(�cUT6��t����(�G���(��R����'
5?����O��qHwHxD���mNj����i�{� ���x`u���{h�� ����A:<