Does Type Have = Operator?

Started by David E. Wheelerover 9 years ago27 messages
#1David E. Wheeler
david@justatheory.com
1 attachment(s)

Hackers,

pgTAP has a function that compares two values of a given type, which it uses for comparing column defaults. It looks like this:

CREATE OR REPLACE FUNCTION _def_is( TEXT, TEXT, anyelement, TEXT )
RETURNS TEXT AS $$
DECLARE
thing text;
BEGIN
IF $1 ~ '^[^'']+[(]' THEN
-- It's a functional default.
RETURN is( $1, $3, $4 );
END IF;

EXECUTE 'SELECT is('
|| COALESCE($1, 'NULL' || '::' || $2) || '::' || $2 || ', '
|| COALESCE(quote_literal($3), 'NULL') || '::' || $2 || ', '
|| COALESCE(quote_literal($4), 'NULL')
|| ')' INTO thing;
RETURN thing;
END;
$$ LANGUAGE plpgsql;

The is() function does an IS DISTINCT FROM to compare the two values passed to it. This has been working pretty well for years, but one place it doesn’t work is with JSON values. I get:

LINE 1: SELECT NOT $1 IS DISTINCT FROM $2
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
QUERY: SELECT NOT $1 IS DISTINCT FROM $2

This makes sense, of course, and I could fix it by comparing text values instead of json values when the values are JSON. But of course the lack of a = operator is not limited to JSON. So I’m wondering if there’s an interface at the SQL level to tell me whether a type has an = operator? That way I could always use text values in those situations.

Thanks,

David

Attachments:

smime.p7sapplication/pkcs7-signature; name=smime.p7sDownload
0�	*�H��
��0�10	+0�	*�H��
��i0�-0��Q�0
	*�H��
0��10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1806U/StartCom Class 1 Primary Intermediate Client CA0
150909050437Z
160909073817Z0F10Udavid@justatheory.com1$0"	*�H��
	david@justatheory.com0�"0
	*�H��
�0�
��zg���P����������:�BV��h/�a�UcTD��L������V�9
��&��2��O*@@�g����E�����!�Ta��G�����R�B�����RI�\g��K��.7��������8��,dr��B��}���F��)�y��n��38�]$D) ��g�'
Hz�"�������`EVl�{<���q�h��A�-���=��:�m���nlxsN~�����jo���s�FV������1IB8p�1���0��0	U00U�0U%0++0U���D�!���<�rV6
���0U#0�Sr������\|~�5N���Q�0 U0�david@justatheory.com0�LU �C0�?0�;+��70�*0.+"http://www.startssl.com/policy.pdf0��+0��0' StartCom Certification Authority0��This certificate was issued according to the Class 1 Validation requirements of the StartCom CA policy, reliance only for the intended purpose in compliance of the relying party obligations.06U/0-0+�)�'�%http://crl.startssl.com/crtu1-crl.crl0��+��009+0�-http://ocsp.startssl.com/sub/class1/client/ca0B+0�6http://aia.startssl.com/certs/sub.class1.client.ca.crt0#U0�http://www.startssl.com/0
	*�H��
�r��������.��;�-a�����������L��O��4���}��F�,^��Y�,�'�d���7:�LR|��s=�9v|\K	��C�@�Y����VW�h Ev����M6��I�oIJ!y����l_����������3������V	[�\�nsD����|�~u����P��Tn�	C��_V!�{A�>��;g���^��,�a�d�X�T��vlO7��L��S>���N*i]m���R�tn����/k0�40��0
	*�H��
0}10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1)0'U StartCom Certification Authority0
071024210155Z
171024210155Z0��10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1806U/StartCom Class 1 Primary Intermediate Client CA0�"0
	*�H��
�0�
��	���-��)�.����2����A�UG��o���#G�
��B|N�D�����Rp�M-��B��=o���-�we�5��J�Qpa>O��.�#������.���_�<���V��
[~�*��*�p�z��~�3�W�G�.�������Ml�r[�<C�e�6���f����q������O���"��u��xf�WN�#�u����i���c�gk��v$����Lb�%�������y��`�����_�{`���xK'G�N������0��0U�0�0U�0USr������\|~�5N���Q�0U#0�N��@[�i�0�4hC�A��0f+Z0X0'+0�http://ocsp.startssl.com/ca0-+0�!http://www.startssl.com/sfsca.crt0[UT0R0'�%�#�!http://www.startssl.com/sfsca.crl0'�%�#�!http://crl.startssl.com/sfsca.crl0��U y0w0u+��70f0.+"http://www.startssl.com/policy.pdf04+(http://www.startssl.com/intermediate.pdf0
	*�H��
�
�}x�,\�c�^��#wM�q�}��>UK/��^y��X��y	�����f�rMI���B6�1ymQ���������Z���0���&��;�@��#13q����&	����������o�	6�r��_��;�GO>*I�(	7�4����XS1r3��)!����y��6Ko����t��#
_�w�S�r����
�;�B
A�Dp�(f��s����������6%�����.W0J3�:b�C�<�8t X����1�<��C��n�=�����t==�wS���T������~���\�wkB�f�|1���5���zU��P)��(���I��j��VB��!����OfI=b��b�\4�-*em��/��SJm�7���N�����[�]'��@����D9�Kr>���R��7/����|�o���^I@���'��Pa$ z��9�a'L�)��(�
�I��}v��c�H]����D����*��W�}
m�>Q����|�C.�(,�l��Q�1�o0�k0��0��10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1806U/StartCom Class 1 Primary Intermediate Client CAQ�0	+���0	*�H��
	1	*�H��
0	*�H��
	1
160511001238Z0#	*�H��
	1�m�|h<�� �d)��g�,�0��	+�71��0��0��10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1806U/StartCom Class 1 Primary Intermediate Client CAQ�0��*�H��
	1�����0��10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1806U/StartCom Class 1 Primary Intermediate Client CAQ�0
	*�H��
�S++���o�K�s)[:�;�>��]I������mR�nRZ�D��~��,�s���������_��0�tV��������0.�@�#l��2��."�a�A(�K��~W2�?��
0�wj��p��F��UR}�(�j��R5��fZB��r�x>�E�7r��o�CD"I��{&7b���P���!�F��w�|��n���q�t�KR���R��1�����m��9�ZS��
�;��K��&����5q���Ar�S��%���,����
#2Fabrízio de Royes Mello
fabriziomello@gmail.com
In reply to: David E. Wheeler (#1)
Re: Does Type Have = Operator?

Em terça-feira, 10 de maio de 2016, David E. Wheeler <david@justatheory.com>
escreveu:

Hackers,

pgTAP has a function that compares two values of a given type, which it
uses for comparing column defaults. It looks like this:

CREATE OR REPLACE FUNCTION _def_is( TEXT, TEXT, anyelement, TEXT )
RETURNS TEXT AS $$
DECLARE
thing text;
BEGIN
IF $1 ~ '^[^'']+[(]' THEN
-- It's a functional default.
RETURN is( $1, $3, $4 );
END IF;

EXECUTE 'SELECT is('
|| COALESCE($1, 'NULL' || '::' || $2) || '::' || $2 || ',
'
|| COALESCE(quote_literal($3), 'NULL') || '::' || $2 ||
', '
|| COALESCE(quote_literal($4), 'NULL')
|| ')' INTO thing;
RETURN thing;
END;
$$ LANGUAGE plpgsql;

The is() function does an IS DISTINCT FROM to compare the two values
passed to it. This has been working pretty well for years, but one place it
doesn’t work is with JSON values. I get:

LINE 1: SELECT NOT $1 IS DISTINCT FROM $2
^
HINT: No operator matches the given name and argument type(s). You
might need to add explicit type casts.
QUERY: SELECT NOT $1 IS DISTINCT FROM $2

This makes sense, of course, and I could fix it by comparing text values
instead of json values when the values are JSON. But of course the lack of
a = operator is not limited to JSON. So I’m wondering if there’s an
interface at the SQL level to tell me whether a type has an = operator?
That way I could always use text values in those situations.

Searching for the operator in pg_operator catalog isn't enought?

Regards,

--
Fabrízio de Royes Mello
Consultoria/Coaching PostgreSQL

Show quoted text

Timbira: http://www.timbira.com.br
Blog: http://fabriziomello.github.io
Linkedin: http://br.linkedin.com/in/fabriziomello
Twitter: http://twitter.com/fabriziomello
Github: http://github.com/fabriziomello

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: David E. Wheeler (#1)
Re: Does Type Have = Operator?

"David E. Wheeler" <david@justatheory.com> writes:

pgTAP has a function that compares two values of a given type, which it uses for comparing column defaults. It looks like this:

CREATE OR REPLACE FUNCTION _def_is( TEXT, TEXT, anyelement, TEXT )
RETURNS TEXT AS $$

Given that you're coercing both one input value and the result to text,
I don't understand why you don't just compare the text representations.

I'm also not very clear on what you mean by "comparing column defaults".
A column default is an expression (in the general case anyway), not just
a value of the type.

Maybe if you'd shown us the is() function, as well as a typical usage
of _def_is(), this would be less opaque.

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

#4David G. Johnston
david.g.johnston@gmail.com
In reply to: David E. Wheeler (#1)
Re: Does Type Have = Operator?

On Tuesday, May 10, 2016, David E. Wheeler <david@justatheory.com> wrote:

This makes sense, of course, and I could fix it by comparing text values
instead of json values when the values are JSON. But of course the lack of
a = operator is not limited to JSON. So I’m wondering if there’s an
interface at the SQL level to tell me whether a type has an = operator?
That way I could always use text values in those situations.

http://www.postgresql.org/docs/9.5/interactive/catalog-pg-amop.html
http://www.postgresql.org/docs/9.5/interactive/xindex.html

Brute force: you'd have to query pg_amop and note the absence of a row with
a btree (maybe hash too...) family strategy 3 (1 for hash)
[equality] where the left and right types are the same and match the type
in question.

There is likely more to it - though absence is pretty much a given I'd be
concerned about false negatives due to ignoring other factors like
"amoppurpose".

In theory you should be able to trade off convenience for correctness by
calling:

to_regoperator('=(type,type)')

But I've never tried it and it assumes that = is the equality operator and
that its presence is sufficient. I'm also guessing on the text type name
syntax.

http://www.postgresql.org/docs/9.5/interactive/functions-info.html

This option is a young one from what I remember.

David J.

#5Euler Taveira
euler@timbira.com.br
In reply to: David E. Wheeler (#1)
Re: Does Type Have = Operator?

On 10-05-2016 21:12, David E. Wheeler wrote:

This makes sense, of course, and I could fix it by comparing text
values instead of json values when the values are JSON. But of course
the lack of a = operator is not limited to JSON. So I’m wondering if
there’s an interface at the SQL level to tell me whether a type has
an = operator? That way I could always use text values in those
situations.

There isn't an equality notation at catalogs. You could try "SELECT
oprname FROM pg_operator WHERE oprcode::text ~ 'eq'" but it is too
fragile. You could also try oprname, oprrest or oprjoin but the result
is worse than the former solution. You definitely need a hack.

Also, IS DISTINCT FROM is an alias for = operator per standard IIRC.

--
Euler Taveira Timbira - http://www.timbira.com.br/
PostgreSQL: Consultoria, Desenvolvimento, Suporte 24x7 e Treinamento

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#6David G. Johnston
david.g.johnston@gmail.com
In reply to: Euler Taveira (#5)
Re: Does Type Have = Operator?

On Tuesday, May 10, 2016, Euler Taveira <euler@timbira.com.br> wrote:

Also, IS DISTINCT FROM is an alias for = operator per standard IIRC.

Technically "is not distinct from" would be more correct. Alias implies
exact while in the presence of nulls the two behave differently.

"is distinct from" ~ "<>" which is the canonical form (alias) for "!="

http://www.postgresql.org/docs/9.5/interactive/functions-comparison.html

David J.

#7Euler Taveira
euler@timbira.com.br
In reply to: David G. Johnston (#6)
Re: Does Type Have = Operator?

On 10-05-2016 22:28, David G. Johnston wrote:

Technically "is not distinct from" would be more correct.

Ooops. Fat fingered the statement. Also, forgot to consider null case.

euler=# \pset null 'NULL'
Null display is "NULL".
euler=# select x.a, y.b, x.a IS NOT DISTINCT FROM y.b AS "INDF", x.a =
y.b AS "=" FROM (VALUES (3), (6), (NULL)) AS x (a), (VALUES (3), (6),
(NULL)) AS y (b);
a | b | INDF | =
------+------+------+------
3 | 3 | t | t
3 | 6 | f | f
3 | NULL | f | NULL
6 | 3 | f | f
6 | 6 | t | t
6 | NULL | f | NULL
NULL | 3 | f | NULL
NULL | 6 | f | NULL
NULL | NULL | t | NULL
(9 rows)

--
Euler Taveira Timbira - http://www.timbira.com.br/
PostgreSQL: Consultoria, Desenvolvimento, Suporte 24x7 e Treinamento

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#8Peter Eisentraut
peter.eisentraut@2ndquadrant.com
In reply to: David G. Johnston (#4)
Re: Does Type Have = Operator?

On 5/10/16 9:16 PM, David G. Johnston wrote:

Brute force: you'd have to query pg_amop and note the absence of a row
with a btree (maybe hash too...) family strategy 3 (1 for hash)
[equality] where the left and right types are the same and match the
type in question.

While these are good thoughts, the implementation of DISTINCT actually
looks for an operator that is literally named "=".

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#9David E. Wheeler
david@justatheory.com
In reply to: Tom Lane (#3)
1 attachment(s)
Re: Does Type Have = Operator?

On May 10, 2016, at 6:14 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Given that you're coercing both one input value and the result to text,
I don't understand why you don't just compare the text representations.

Because sometimes the text is not equal when the casted text is. Consider

'foo'::citext = 'FOO':citext

I'm also not very clear on what you mean by "comparing column defaults".
A column default is an expression (in the general case anyway), not just
a value of the type.

Yeah, the pgTAP column_default_is() function takes a string representation of an expression.

Maybe if you'd shown us the is() function, as well as a typical usage
of _def_is(), this would be less opaque.

Here’s is():

CREATE OR REPLACE FUNCTION is (anyelement, anyelement, text)
RETURNS TEXT AS $$
DECLARE
result BOOLEAN;
output TEXT;
BEGIN
-- Would prefer $1 IS NOT DISTINCT FROM, but that's not supported by 8.1.
result := NOT $1 IS DISTINCT FROM $2;
output := ok( result, $3 );
RETURN output || CASE result WHEN TRUE THEN '' ELSE E'\n' || diag(
' have: ' || CASE WHEN $1 IS NULL THEN 'NULL' ELSE $1::text END ||
E'\n want: ' || CASE WHEN $2 IS NULL THEN 'NULL' ELSE $2::text END
) END;
END;
$$ LANGUAGE plpgsql;

_def_is() is called by another function, which effectively is:

CREATE OR REPLACE FUNCTION _cdi ( NAME, NAME, NAME, anyelement, TEXT )
RETURNS TEXT AS $$
BEGIN

RETURN _def_is(
pg_catalog.pg_get_expr(d.adbin, d.adrelid),
pg_catalog.format_type(a.atttypid, a.atttypmod),
$4, $5
)
FROM pg_catalog.pg_namespace n, pg_catalog.pg_class c, pg_catalog.pg_attribute a,
pg_catalog.pg_attrdef d
WHERE n.oid = c.relnamespace
AND c.oid = a.attrelid
AND a.atthasdef
AND a.attrelid = d.adrelid
AND a.attnum = d.adnum
AND n.nspname = $1
AND c.relname = $2
AND a.attnum > 0
AND NOT a.attisdropped
AND a.attname = $3;
END;
$$ LANGUAGE plpgsql;

That function si called like this:

_cdi( :schema, :table, :column, :default, :description );

Best,

David

Attachments:

smime.p7sapplication/pkcs7-signature; name=smime.p7sDownload
0�	*�H��
��0�10	+0�	*�H��
��i0�-0��Q�0
	*�H��
0��10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1806U/StartCom Class 1 Primary Intermediate Client CA0
150909050437Z
160909073817Z0F10Udavid@justatheory.com1$0"	*�H��
	david@justatheory.com0�"0
	*�H��
�0�
��zg���P����������:�BV��h/�a�UcTD��L������V�9
��&��2��O*@@�g����E�����!�Ta��G�����R�B�����RI�\g��K��.7��������8��,dr��B��}���F��)�y��n��38�]$D) ��g�'
Hz�"�������`EVl�{<���q�h��A�-���=��:�m���nlxsN~�����jo���s�FV������1IB8p�1���0��0	U00U�0U%0++0U���D�!���<�rV6
���0U#0�Sr������\|~�5N���Q�0 U0�david@justatheory.com0�LU �C0�?0�;+��70�*0.+"http://www.startssl.com/policy.pdf0��+0��0' StartCom Certification Authority0��This certificate was issued according to the Class 1 Validation requirements of the StartCom CA policy, reliance only for the intended purpose in compliance of the relying party obligations.06U/0-0+�)�'�%http://crl.startssl.com/crtu1-crl.crl0��+��009+0�-http://ocsp.startssl.com/sub/class1/client/ca0B+0�6http://aia.startssl.com/certs/sub.class1.client.ca.crt0#U0�http://www.startssl.com/0
	*�H��
�r��������.��;�-a�����������L��O��4���}��F�,^��Y�,�'�d���7:�LR|��s=�9v|\K	��C�@�Y����VW�h Ev����M6��I�oIJ!y����l_����������3������V	[�\�nsD����|�~u����P��Tn�	C��_V!�{A�>��;g���^��,�a�d�X�T��vlO7��L��S>���N*i]m���R�tn����/k0�40��0
	*�H��
0}10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1)0'U StartCom Certification Authority0
071024210155Z
171024210155Z0��10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1806U/StartCom Class 1 Primary Intermediate Client CA0�"0
	*�H��
�0�
��	���-��)�.����2����A�UG��o���#G�
��B|N�D�����Rp�M-��B��=o���-�we�5��J�Qpa>O��.�#������.���_�<���V��
[~�*��*�p�z��~�3�W�G�.�������Ml�r[�<C�e�6���f����q������O���"��u��xf�WN�#�u����i���c�gk��v$����Lb�%�������y��`�����_�{`���xK'G�N������0��0U�0�0U�0USr������\|~�5N���Q�0U#0�N��@[�i�0�4hC�A��0f+Z0X0'+0�http://ocsp.startssl.com/ca0-+0�!http://www.startssl.com/sfsca.crt0[UT0R0'�%�#�!http://www.startssl.com/sfsca.crl0'�%�#�!http://crl.startssl.com/sfsca.crl0��U y0w0u+��70f0.+"http://www.startssl.com/policy.pdf04+(http://www.startssl.com/intermediate.pdf0
	*�H��
�
�}x�,\�c�^��#wM�q�}��>UK/��^y��X��y	�����f�rMI���B6�1ymQ���������Z���0���&��;�@��#13q����&	����������o�	6�r��_��;�GO>*I�(	7�4����XS1r3��)!����y��6Ko����t��#
_�w�S�r����
�;�B
A�Dp�(f��s����������6%�����.W0J3�:b�C�<�8t X����1�<��C��n�=�����t==�wS���T������~���\�wkB�f�|1���5���zU��P)��(���I��j��VB��!����OfI=b��b�\4�-*em��/��SJm�7���N�����[�]'��@����D9�Kr>���R��7/����|�o���^I@���'��Pa$ z��9�a'L�)��(�
�I��}v��c�H]����D����*��W�}
m�>Q����|�C.�(,�l��Q�1�o0�k0��0��10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1806U/StartCom Class 1 Primary Intermediate Client CAQ�0	+���0	*�H��
	1	*�H��
0	*�H��
	1
160511050611Z0#	*�H��
	1f<W�(�9G���$F`��(0��	+�71��0��0��10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1806U/StartCom Class 1 Primary Intermediate Client CAQ�0��*�H��
	1�����0��10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1806U/StartCom Class 1 Primary Intermediate Client CAQ�0
	*�H��
�K��o��<B��a���gS&������sE:O����~2@BY����=�5��\���	�	�b������W��Q���������;�����aqMz�����`����)_xkD�6�pNX
����>w��m%�����\^S��u!�J�4 ����9o�Xg*�����L���{���:8�9����K�c2n��cS�(������_��V�J-y
���(r��E��:�sw����gj_�0��e��{�?B��
#10David E. Wheeler
david@justatheory.com
In reply to: Fabrízio de Royes Mello (#2)
1 attachment(s)
Re: Does Type Have = Operator?

On May 10, 2016, at 5:56 PM, Fabrízio de Royes Mello <fabriziomello@gmail.com> wrote:

Searching for the operator in pg_operator catalog isn't enought?

Seems like overkill, but will do if there’s nothing else.

Best,

David

Attachments:

smime.p7sapplication/pkcs7-signature; name=smime.p7sDownload
0�	*�H��
��0�10	+0�	*�H��
��i0�-0��Q�0
	*�H��
0��10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1806U/StartCom Class 1 Primary Intermediate Client CA0
150909050437Z
160909073817Z0F10Udavid@justatheory.com1$0"	*�H��
	david@justatheory.com0�"0
	*�H��
�0�
��zg���P����������:�BV��h/�a�UcTD��L������V�9
��&��2��O*@@�g����E�����!�Ta��G�����R�B�����RI�\g��K��.7��������8��,dr��B��}���F��)�y��n��38�]$D) ��g�'
Hz�"�������`EVl�{<���q�h��A�-���=��:�m���nlxsN~�����jo���s�FV������1IB8p�1���0��0	U00U�0U%0++0U���D�!���<�rV6
���0U#0�Sr������\|~�5N���Q�0 U0�david@justatheory.com0�LU �C0�?0�;+��70�*0.+"http://www.startssl.com/policy.pdf0��+0��0' StartCom Certification Authority0��This certificate was issued according to the Class 1 Validation requirements of the StartCom CA policy, reliance only for the intended purpose in compliance of the relying party obligations.06U/0-0+�)�'�%http://crl.startssl.com/crtu1-crl.crl0��+��009+0�-http://ocsp.startssl.com/sub/class1/client/ca0B+0�6http://aia.startssl.com/certs/sub.class1.client.ca.crt0#U0�http://www.startssl.com/0
	*�H��
�r��������.��;�-a�����������L��O��4���}��F�,^��Y�,�'�d���7:�LR|��s=�9v|\K	��C�@�Y����VW�h Ev����M6��I�oIJ!y����l_����������3������V	[�\�nsD����|�~u����P��Tn�	C��_V!�{A�>��;g���^��,�a�d�X�T��vlO7��L��S>���N*i]m���R�tn����/k0�40��0
	*�H��
0}10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1)0'U StartCom Certification Authority0
071024210155Z
171024210155Z0��10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1806U/StartCom Class 1 Primary Intermediate Client CA0�"0
	*�H��
�0�
��	���-��)�.����2����A�UG��o���#G�
��B|N�D�����Rp�M-��B��=o���-�we�5��J�Qpa>O��.�#������.���_�<���V��
[~�*��*�p�z��~�3�W�G�.�������Ml�r[�<C�e�6���f����q������O���"��u��xf�WN�#�u����i���c�gk��v$����Lb�%�������y��`�����_�{`���xK'G�N������0��0U�0�0U�0USr������\|~�5N���Q�0U#0�N��@[�i�0�4hC�A��0f+Z0X0'+0�http://ocsp.startssl.com/ca0-+0�!http://www.startssl.com/sfsca.crt0[UT0R0'�%�#�!http://www.startssl.com/sfsca.crl0'�%�#�!http://crl.startssl.com/sfsca.crl0��U y0w0u+��70f0.+"http://www.startssl.com/policy.pdf04+(http://www.startssl.com/intermediate.pdf0
	*�H��
�
�}x�,\�c�^��#wM�q�}��>UK/��^y��X��y	�����f�rMI���B6�1ymQ���������Z���0���&��;�@��#13q����&	����������o�	6�r��_��;�GO>*I�(	7�4����XS1r3��)!����y��6Ko����t��#
_�w�S�r����
�;�B
A�Dp�(f��s����������6%�����.W0J3�:b�C�<�8t X����1�<��C��n�=�����t==�wS���T������~���\�wkB�f�|1���5���zU��P)��(���I��j��VB��!����OfI=b��b�\4�-*em��/��SJm�7���N�����[�]'��@����D9�Kr>���R��7/����|�o���^I@���'��Pa$ z��9�a'L�)��(�
�I��}v��c�H]����D����*��W�}
m�>Q����|�C.�(,�l��Q�1�o0�k0��0��10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1806U/StartCom Class 1 Primary Intermediate Client CAQ�0	+���0	*�H��
	1	*�H��
0	*�H��
	1
160511050709Z0#	*�H��
	1
�S3���Z��*9Y�'��=�0��	+�71��0��0��10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1806U/StartCom Class 1 Primary Intermediate Client CAQ�0��*�H��
	1�����0��10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1806U/StartCom Class 1 Primary Intermediate Client CAQ�0
	*�H��
�D����Eo��V�k�m��������,U���#K�b��'������d}�2������#(���x����������uu�T��nMF���6
!@������F��-��q>�0�j�m���z��$�Mh�z$ATB
���	9�L�R+������n�/K}N_��G����tK�*����L�1���]{h
8�T�41?�m���5���<���P4�j������5F��|{��>p���6L[�nHH2Fd��05���
#11Robert Haas
robertmhaas@gmail.com
In reply to: David G. Johnston (#4)
Re: Does Type Have = Operator?

On Tue, May 10, 2016 at 9:16 PM, David G. Johnston
<david.g.johnston@gmail.com> wrote:

Brute force: you'd have to query pg_amop and note the absence of a row with
a btree (maybe hash too...) family strategy 3 (1 for hash) [equality] where
the left and right types are the same and match the type in question.

The core system uses this kind of thing to find equality operators in
a number of cases.

We often assume that the operator which implements equality for the
type's default btree operator class is the canonical one for some
purpose. Ditto for the default hash operator class.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#12David G. Johnston
david.g.johnston@gmail.com
In reply to: Robert Haas (#11)
Re: Does Type Have = Operator?

On Wed, May 11, 2016 at 9:54 AM, Robert Haas <robertmhaas@gmail.com> wrote:

On Tue, May 10, 2016 at 9:16 PM, David G. Johnston
<david.g.johnston@gmail.com> wrote:

Brute force: you'd have to query pg_amop and note the absence of a row

with

a btree (maybe hash too...) family strategy 3 (1 for hash) [equality]

where

the left and right types are the same and match the type in question.

The core system uses this kind of thing to find equality operators in
a number of cases.

We often assume that the operator which implements equality for the
type's default btree operator class is the canonical one for some
purpose. Ditto for the default hash operator class.

​Yeah, the user-facing documentation covers it pretty deeply if not in one
central location.

But apparently the core system also uses the fact that "=", if present, is
an equality operator and, less so, that no other operator is expected​

​to be used for equality.

I suspect that such an expectation is not enforced though - e.g., someone
could define "==" to mean equality ​if they so choose (the lesser
property). Its hard to imagine defining "=" to mean something different in
logic, though, without intentionally trying to be cryptic.

David J.

#13Kevin Grittner
kgrittn@gmail.com
In reply to: David G. Johnston (#12)
Re: Does Type Have = Operator?

On Wed, May 11, 2016 at 12:01 PM, David G. Johnston
<david.g.johnston@gmail.com> wrote:

Its hard to imagine defining "=" to mean something different in logic,
though, without intentionally trying to be cryptic.

As long as you don't assume too much about *what* is equal.

test=# select '(1,1)(2,2)'::box = '(-4.5,1000)(-2.5,1000.5)'::box;
?column?
----------
t
(1 row)

--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#14David E. Wheeler
david@justatheory.com
In reply to: Kevin Grittner (#13)
1 attachment(s)
Re: Does Type Have = Operator?

On May 11, 2016, at 10:19 AM, Kevin Grittner <kgrittn@gmail.com> wrote:

As long as you don't assume too much about *what* is equal.

test=# select '(1,1)(2,2)'::box = '(-4.5,1000)(-2.5,1000.5)'::box;
?column?
----------
t
(1 row)

Oh, well crap. Maybe I’d be better off just comparing the plain text of the expressions as Tom suggested.

David

Attachments:

smime.p7sapplication/pkcs7-signature; name=smime.p7sDownload
0�	*�H��
��0�10	+0�	*�H��
��i0�-0��Q�0
	*�H��
0��10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1806U/StartCom Class 1 Primary Intermediate Client CA0
150909050437Z
160909073817Z0F10Udavid@justatheory.com1$0"	*�H��
	david@justatheory.com0�"0
	*�H��
�0�
��zg���P����������:�BV��h/�a�UcTD��L������V�9
��&��2��O*@@�g����E�����!�Ta��G�����R�B�����RI�\g��K��.7��������8��,dr��B��}���F��)�y��n��38�]$D) ��g�'
Hz�"�������`EVl�{<���q�h��A�-���=��:�m���nlxsN~�����jo���s�FV������1IB8p�1���0��0	U00U�0U%0++0U���D�!���<�rV6
���0U#0�Sr������\|~�5N���Q�0 U0�david@justatheory.com0�LU �C0�?0�;+��70�*0.+"http://www.startssl.com/policy.pdf0��+0��0' StartCom Certification Authority0��This certificate was issued according to the Class 1 Validation requirements of the StartCom CA policy, reliance only for the intended purpose in compliance of the relying party obligations.06U/0-0+�)�'�%http://crl.startssl.com/crtu1-crl.crl0��+��009+0�-http://ocsp.startssl.com/sub/class1/client/ca0B+0�6http://aia.startssl.com/certs/sub.class1.client.ca.crt0#U0�http://www.startssl.com/0
	*�H��
�r��������.��;�-a�����������L��O��4���}��F�,^��Y�,�'�d���7:�LR|��s=�9v|\K	��C�@�Y����VW�h Ev����M6��I�oIJ!y����l_����������3������V	[�\�nsD����|�~u����P��Tn�	C��_V!�{A�>��;g���^��,�a�d�X�T��vlO7��L��S>���N*i]m���R�tn����/k0�40��0
	*�H��
0}10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1)0'U StartCom Certification Authority0
071024210155Z
171024210155Z0��10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1806U/StartCom Class 1 Primary Intermediate Client CA0�"0
	*�H��
�0�
��	���-��)�.����2����A�UG��o���#G�
��B|N�D�����Rp�M-��B��=o���-�we�5��J�Qpa>O��.�#������.���_�<���V��
[~�*��*�p�z��~�3�W�G�.�������Ml�r[�<C�e�6���f����q������O���"��u��xf�WN�#�u����i���c�gk��v$����Lb�%�������y��`�����_�{`���xK'G�N������0��0U�0�0U�0USr������\|~�5N���Q�0U#0�N��@[�i�0�4hC�A��0f+Z0X0'+0�http://ocsp.startssl.com/ca0-+0�!http://www.startssl.com/sfsca.crt0[UT0R0'�%�#�!http://www.startssl.com/sfsca.crl0'�%�#�!http://crl.startssl.com/sfsca.crl0��U y0w0u+��70f0.+"http://www.startssl.com/policy.pdf04+(http://www.startssl.com/intermediate.pdf0
	*�H��
�
�}x�,\�c�^��#wM�q�}��>UK/��^y��X��y	�����f�rMI���B6�1ymQ���������Z���0���&��;�@��#13q����&	����������o�	6�r��_��;�GO>*I�(	7�4����XS1r3��)!����y��6Ko����t��#
_�w�S�r����
�;�B
A�Dp�(f��s����������6%�����.W0J3�:b�C�<�8t X����1�<��C��n�=�����t==�wS���T������~���\�wkB�f�|1���5���zU��P)��(���I��j��VB��!����OfI=b��b�\4�-*em��/��SJm�7���N�����[�]'��@����D9�Kr>���R��7/����|�o���^I@���'��Pa$ z��9�a'L�)��(�
�I��}v��c�H]����D����*��W�}
m�>Q����|�C.�(,�l��Q�1�o0�k0��0��10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1806U/StartCom Class 1 Primary Intermediate Client CAQ�0	+���0	*�H��
	1	*�H��
0	*�H��
	1
160511172306Z0#	*�H��
	1���G�hYIKWnX����4�!0��	+�71��0��0��10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1806U/StartCom Class 1 Primary Intermediate Client CAQ�0��*�H��
	1�����0��10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1806U/StartCom Class 1 Primary Intermediate Client CAQ�0
	*�H��
�L�C
�2$�C<�x2'����OW�BAfR���s�&*���l�������Ag7�l6�5&a=71:�HQ<����<�Cm�����"(_!.���j?T�|���
���N���a�[35���jq�VI<��LC��tC^l��6	GB�zJ��o�cG�)�o[��+�$ f#K"#pf
�F7�E�F��������=�z�t��h*���8<��>�9�L"��q������]����9�oB1\������-��
#15Kevin Grittner
kgrittn@gmail.com
In reply to: David E. Wheeler (#14)
Re: Does Type Have = Operator?

On Wed, May 11, 2016 at 12:23 PM, David E. Wheeler
<david@justatheory.com> wrote:

Oh, well crap. Maybe I’d be better off just comparing the plain
text of the expressions as Tom suggested.

At the other extreme are the row comparison operators that only
consider values equal if they have the same storage value. See the
last paragraph of:

http://www.postgresql.org/docs/9.5/static/functions-comparisons.html#COMPOSITE-TYPE-COMPARISON

| To support matching of rows which include elements without a
| default B-tree operator class, the following operators are
| defined for composite type comparison: *=, *<>, *<, *<=, *>, and
| *>=. These operators compare the internal binary representation
| of the two rows. Two rows might have a different binary
| representation even though comparisons of the two rows with the
| equality operator is true. The ordering of rows under these
| comparison operators is deterministic but not otherwise
| meaningful. These operators are used internally for materialized
| views and might be useful for other specialized purposes such as
| replication but are not intended to be generally useful for
| writing queries.

I'm not clear enough on your intended usage to know whether these
operators are a good fit, but they are sitting there waiting to be
used if they do fit.

--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#16Fabrízio de Royes Mello
fabriziomello@gmail.com
In reply to: David E. Wheeler (#10)
Re: Does Type Have = Operator?

On Wed, May 11, 2016 at 2:07 AM, David E. Wheeler <david@justatheory.com>
wrote:

On May 10, 2016, at 5:56 PM, Fabrízio de Royes Mello <

fabriziomello@gmail.com> wrote:

Searching for the operator in pg_operator catalog isn't enought?

Seems like overkill, but will do if there’s nothing else.

I know... but you can do that just in case the current behaviour fail by
cathing it with "begin...exception...", so you'll minimize the looking for
process on catalog.

Regards,

--
Fabrízio de Royes Mello
Consultoria/Coaching PostgreSQL

Show quoted text

Timbira: http://www.timbira.com.br
Blog: http://fabriziomello.github.io
Linkedin: http://br.linkedin.com/in/fabriziomello
Twitter: http://twitter.com/fabriziomello
Github: http://github.com/fabriziomello

#17David E. Wheeler
david@justatheory.com
In reply to: Kevin Grittner (#15)
1 attachment(s)
Re: Does Type Have = Operator?

On May 11, 2016, at 10:34 AM, Kevin Grittner <kgrittn@gmail.com> wrote:

I'm not clear enough on your intended usage to know whether these
operators are a good fit, but they are sitting there waiting to be
used if they do fit.

Huh. I haven’t had any problems with IS DISTINCT FROM for rows, except for the situation in which a failure is thrown because the types vary, say between TEXT and CITEXT. That can drive the tester crazy, since it says something like:

Results differ beginning at row 3:
have: (44,Anna)
want: (44,Anna)

But overall I think that’s okay; the tester really does want to make sure the type is correct.

Thanks,

David

Attachments:

smime.p7sapplication/pkcs7-signature; name=smime.p7sDownload
0�	*�H��
��0�10	+0�	*�H��
��i0�-0��Q�0
	*�H��
0��10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1806U/StartCom Class 1 Primary Intermediate Client CA0
150909050437Z
160909073817Z0F10Udavid@justatheory.com1$0"	*�H��
	david@justatheory.com0�"0
	*�H��
�0�
��zg���P����������:�BV��h/�a�UcTD��L������V�9
��&��2��O*@@�g����E�����!�Ta��G�����R�B�����RI�\g��K��.7��������8��,dr��B��}���F��)�y��n��38�]$D) ��g�'
Hz�"�������`EVl�{<���q�h��A�-���=��:�m���nlxsN~�����jo���s�FV������1IB8p�1���0��0	U00U�0U%0++0U���D�!���<�rV6
���0U#0�Sr������\|~�5N���Q�0 U0�david@justatheory.com0�LU �C0�?0�;+��70�*0.+"http://www.startssl.com/policy.pdf0��+0��0' StartCom Certification Authority0��This certificate was issued according to the Class 1 Validation requirements of the StartCom CA policy, reliance only for the intended purpose in compliance of the relying party obligations.06U/0-0+�)�'�%http://crl.startssl.com/crtu1-crl.crl0��+��009+0�-http://ocsp.startssl.com/sub/class1/client/ca0B+0�6http://aia.startssl.com/certs/sub.class1.client.ca.crt0#U0�http://www.startssl.com/0
	*�H��
�r��������.��;�-a�����������L��O��4���}��F�,^��Y�,�'�d���7:�LR|��s=�9v|\K	��C�@�Y����VW�h Ev����M6��I�oIJ!y����l_����������3������V	[�\�nsD����|�~u����P��Tn�	C��_V!�{A�>��;g���^��,�a�d�X�T��vlO7��L��S>���N*i]m���R�tn����/k0�40��0
	*�H��
0}10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1)0'U StartCom Certification Authority0
071024210155Z
171024210155Z0��10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1806U/StartCom Class 1 Primary Intermediate Client CA0�"0
	*�H��
�0�
��	���-��)�.����2����A�UG��o���#G�
��B|N�D�����Rp�M-��B��=o���-�we�5��J�Qpa>O��.�#������.���_�<���V��
[~�*��*�p�z��~�3�W�G�.�������Ml�r[�<C�e�6���f����q������O���"��u��xf�WN�#�u����i���c�gk��v$����Lb�%�������y��`�����_�{`���xK'G�N������0��0U�0�0U�0USr������\|~�5N���Q�0U#0�N��@[�i�0�4hC�A��0f+Z0X0'+0�http://ocsp.startssl.com/ca0-+0�!http://www.startssl.com/sfsca.crt0[UT0R0'�%�#�!http://www.startssl.com/sfsca.crl0'�%�#�!http://crl.startssl.com/sfsca.crl0��U y0w0u+��70f0.+"http://www.startssl.com/policy.pdf04+(http://www.startssl.com/intermediate.pdf0
	*�H��
�
�}x�,\�c�^��#wM�q�}��>UK/��^y��X��y	�����f�rMI���B6�1ymQ���������Z���0���&��;�@��#13q����&	����������o�	6�r��_��;�GO>*I�(	7�4����XS1r3��)!����y��6Ko����t��#
_�w�S�r����
�;�B
A�Dp�(f��s����������6%�����.W0J3�:b�C�<�8t X����1�<��C��n�=�����t==�wS���T������~���\�wkB�f�|1���5���zU��P)��(���I��j��VB��!����OfI=b��b�\4�-*em��/��SJm�7���N�����[�]'��@����D9�Kr>���R��7/����|�o���^I@���'��Pa$ z��9�a'L�)��(�
�I��}v��c�H]����D����*��W�}
m�>Q����|�C.�(,�l��Q�1�o0�k0��0��10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1806U/StartCom Class 1 Primary Intermediate Client CAQ�0	+���0	*�H��
	1	*�H��
0	*�H��
	1
160512000548Z0#	*�H��
	1�f����mV��@T����&0��	+�71��0��0��10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1806U/StartCom Class 1 Primary Intermediate Client CAQ�0��*�H��
	1�����0��10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1806U/StartCom Class 1 Primary Intermediate Client CAQ�0
	*�H��
�C�#�����	s�PE��^���l���
������,�#�����������29���eu��\fc|^���>������K@;M{�.�i�m�D$�%��^{��������K�('��� �g$����`Q�����
���4��>i��N���� U�M���J�>u���/�[8'��-�Q��N[�����gP���l���@Vy��GvM2>u@�6rU,R��E��T�^ ������������L>,4ht
#18David E. Wheeler
david@justatheory.com
In reply to: Fabrízio de Royes Mello (#16)
1 attachment(s)
Re: Does Type Have = Operator?

On May 11, 2016, at 11:01 AM, Fabrízio de Royes Mello <fabriziomello@gmail.com> wrote:

I know... but you can do that just in case the current behaviour fail by cathing it with "begin...exception...", so you'll minimize the looking for process on catalog.

Yeah, I guess. Honestly 90% of this issue would go away for me if there was a `json = json` operator. I know there are a couple different ways to interpret JSON equality, though.

David

Attachments:

smime.p7sapplication/pkcs7-signature; name=smime.p7sDownload
0�	*�H��
��0�10	+0�	*�H��
��i0�-0��Q�0
	*�H��
0��10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1806U/StartCom Class 1 Primary Intermediate Client CA0
150909050437Z
160909073817Z0F10Udavid@justatheory.com1$0"	*�H��
	david@justatheory.com0�"0
	*�H��
�0�
��zg���P����������:�BV��h/�a�UcTD��L������V�9
��&��2��O*@@�g����E�����!�Ta��G�����R�B�����RI�\g��K��.7��������8��,dr��B��}���F��)�y��n��38�]$D) ��g�'
Hz�"�������`EVl�{<���q�h��A�-���=��:�m���nlxsN~�����jo���s�FV������1IB8p�1���0��0	U00U�0U%0++0U���D�!���<�rV6
���0U#0�Sr������\|~�5N���Q�0 U0�david@justatheory.com0�LU �C0�?0�;+��70�*0.+"http://www.startssl.com/policy.pdf0��+0��0' StartCom Certification Authority0��This certificate was issued according to the Class 1 Validation requirements of the StartCom CA policy, reliance only for the intended purpose in compliance of the relying party obligations.06U/0-0+�)�'�%http://crl.startssl.com/crtu1-crl.crl0��+��009+0�-http://ocsp.startssl.com/sub/class1/client/ca0B+0�6http://aia.startssl.com/certs/sub.class1.client.ca.crt0#U0�http://www.startssl.com/0
	*�H��
�r��������.��;�-a�����������L��O��4���}��F�,^��Y�,�'�d���7:�LR|��s=�9v|\K	��C�@�Y����VW�h Ev����M6��I�oIJ!y����l_����������3������V	[�\�nsD����|�~u����P��Tn�	C��_V!�{A�>��;g���^��,�a�d�X�T��vlO7��L��S>���N*i]m���R�tn����/k0�40��0
	*�H��
0}10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1)0'U StartCom Certification Authority0
071024210155Z
171024210155Z0��10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1806U/StartCom Class 1 Primary Intermediate Client CA0�"0
	*�H��
�0�
��	���-��)�.����2����A�UG��o���#G�
��B|N�D�����Rp�M-��B��=o���-�we�5��J�Qpa>O��.�#������.���_�<���V��
[~�*��*�p�z��~�3�W�G�.�������Ml�r[�<C�e�6���f����q������O���"��u��xf�WN�#�u����i���c�gk��v$����Lb�%�������y��`�����_�{`���xK'G�N������0��0U�0�0U�0USr������\|~�5N���Q�0U#0�N��@[�i�0�4hC�A��0f+Z0X0'+0�http://ocsp.startssl.com/ca0-+0�!http://www.startssl.com/sfsca.crt0[UT0R0'�%�#�!http://www.startssl.com/sfsca.crl0'�%�#�!http://crl.startssl.com/sfsca.crl0��U y0w0u+��70f0.+"http://www.startssl.com/policy.pdf04+(http://www.startssl.com/intermediate.pdf0
	*�H��
�
�}x�,\�c�^��#wM�q�}��>UK/��^y��X��y	�����f�rMI���B6�1ymQ���������Z���0���&��;�@��#13q����&	����������o�	6�r��_��;�GO>*I�(	7�4����XS1r3��)!����y��6Ko����t��#
_�w�S�r����
�;�B
A�Dp�(f��s����������6%�����.W0J3�:b�C�<�8t X����1�<��C��n�=�����t==�wS���T������~���\�wkB�f�|1���5���zU��P)��(���I��j��VB��!����OfI=b��b�\4�-*em��/��SJm�7���N�����[�]'��@����D9�Kr>���R��7/����|�o���^I@���'��Pa$ z��9�a'L�)��(�
�I��}v��c�H]����D����*��W�}
m�>Q����|�C.�(,�l��Q�1�o0�k0��0��10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1806U/StartCom Class 1 Primary Intermediate Client CAQ�0	+���0	*�H��
	1	*�H��
0	*�H��
	1
160512000921Z0#	*�H��
	1LJu�cH�\������(-�0��	+�71��0��0��10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1806U/StartCom Class 1 Primary Intermediate Client CAQ�0��*�H��
	1�����0��10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1806U/StartCom Class 1 Primary Intermediate Client CAQ�0
	*�H��
�6'������N�e�,*t������fPbf��

����l����7�I�����f�����f<�k�AAm��0$�����-���)S2��6����]��)Ep�W;��u3p�<|[J�&�" �Hd.�Q{�����H�3����� k1�k��YK���Iu��U���J�3���Ese*|�_FQ�v���n��
!�6����S�%&���n_M(�Q�v�5���<yY����n�e�F��:*�f�>
#19Fabrízio de Royes Mello
fabriziomello@gmail.com
In reply to: David E. Wheeler (#18)
Re: Does Type Have = Operator?

On Wed, May 11, 2016 at 9:09 PM, David E. Wheeler <david@justatheory.com>
wrote:

On May 11, 2016, at 11:01 AM, Fabrízio de Royes Mello <

fabriziomello@gmail.com> wrote:

I know... but you can do that just in case the current behaviour fail

by cathing it with "begin...exception...", so you'll minimize the looking
for process on catalog.

Yeah, I guess. Honestly 90% of this issue would go away for me if there

was a `json = json` operator. I know there are a couple different ways to
interpret JSON equality, though.

Yeah.. it's ugly but you can do something like that:

CREATE OR REPLACE FUNCTION json_equals_to_json(first JSON, second JSON)
RETURNS boolean AS
$$
BEGIN
RETURN first::TEXT IS NOT DISTINCT FROM second::TEXT;
END
$$
LANGUAGE plpgsql IMMUTABLE;

CREATE OPERATOR = (
LEFTARG = json,
RIGHTARG = json,
PROCEDURE = json_equals_to_json
);

Regards,

--
Fabrízio de Royes Mello
Consultoria/Coaching PostgreSQL

Show quoted text

Timbira: http://www.timbira.com.br
Blog: http://fabriziomello.github.io
Linkedin: http://br.linkedin.com/in/fabriziomello
Twitter: http://twitter.com/fabriziomello
Github: http://github.com/fabriziomello

#20David E. Wheeler
david@justatheory.com
In reply to: Fabrízio de Royes Mello (#19)
1 attachment(s)
Re: Does Type Have = Operator?

On May 12, 2016, at 11:19 AM, Fabrízio de Royes Mello <fabriziomello@gmail.com> wrote:

Yeah.. it's ugly but you can do something like that:

I could, but I won’t, since this is pgTAP and users of the library might have defined their own json operators.

Andrew Dunstan has done the yeoman’s work of creating such operators, BTW:

https://bitbucket.org/adunstan/jsoncmp

Some might argue that it ought to compare JSON objects, effectively be the equivalent of ::jsonb = ::jsonb, rather than ::text = ::text. But as Andrew points out to me offlist, “if that's what they want why aren't they using jsonb in the first place?”

So I think that, up to the introduction of JSONB, it was important not to side one way or the other and put a JSON = operator in core. But now what we have JSONB, perhaps it makes sense to finally take sides and intoduce JSON = that does plain text comparison. Thoughts?

Best,

David

Attachments:

smime.p7sapplication/pkcs7-signature; name=smime.p7sDownload
0�	*�H��
��0�10	+0�	*�H��
��i0�-0��Q�0
	*�H��
0��10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1806U/StartCom Class 1 Primary Intermediate Client CA0
150909050437Z
160909073817Z0F10Udavid@justatheory.com1$0"	*�H��
	david@justatheory.com0�"0
	*�H��
�0�
��zg���P����������:�BV��h/�a�UcTD��L������V�9
��&��2��O*@@�g����E�����!�Ta��G�����R�B�����RI�\g��K��.7��������8��,dr��B��}���F��)�y��n��38�]$D) ��g�'
Hz�"�������`EVl�{<���q�h��A�-���=��:�m���nlxsN~�����jo���s�FV������1IB8p�1���0��0	U00U�0U%0++0U���D�!���<�rV6
���0U#0�Sr������\|~�5N���Q�0 U0�david@justatheory.com0�LU �C0�?0�;+��70�*0.+"http://www.startssl.com/policy.pdf0��+0��0' StartCom Certification Authority0��This certificate was issued according to the Class 1 Validation requirements of the StartCom CA policy, reliance only for the intended purpose in compliance of the relying party obligations.06U/0-0+�)�'�%http://crl.startssl.com/crtu1-crl.crl0��+��009+0�-http://ocsp.startssl.com/sub/class1/client/ca0B+0�6http://aia.startssl.com/certs/sub.class1.client.ca.crt0#U0�http://www.startssl.com/0
	*�H��
�r��������.��;�-a�����������L��O��4���}��F�,^��Y�,�'�d���7:�LR|��s=�9v|\K	��C�@�Y����VW�h Ev����M6��I�oIJ!y����l_����������3������V	[�\�nsD����|�~u����P��Tn�	C��_V!�{A�>��;g���^��,�a�d�X�T��vlO7��L��S>���N*i]m���R�tn����/k0�40��0
	*�H��
0}10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1)0'U StartCom Certification Authority0
071024210155Z
171024210155Z0��10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1806U/StartCom Class 1 Primary Intermediate Client CA0�"0
	*�H��
�0�
��	���-��)�.����2����A�UG��o���#G�
��B|N�D�����Rp�M-��B��=o���-�we�5��J�Qpa>O��.�#������.���_�<���V��
[~�*��*�p�z��~�3�W�G�.�������Ml�r[�<C�e�6���f����q������O���"��u��xf�WN�#�u����i���c�gk��v$����Lb�%�������y��`�����_�{`���xK'G�N������0��0U�0�0U�0USr������\|~�5N���Q�0U#0�N��@[�i�0�4hC�A��0f+Z0X0'+0�http://ocsp.startssl.com/ca0-+0�!http://www.startssl.com/sfsca.crt0[UT0R0'�%�#�!http://www.startssl.com/sfsca.crl0'�%�#�!http://crl.startssl.com/sfsca.crl0��U y0w0u+��70f0.+"http://www.startssl.com/policy.pdf04+(http://www.startssl.com/intermediate.pdf0
	*�H��
�
�}x�,\�c�^��#wM�q�}��>UK/��^y��X��y	�����f�rMI���B6�1ymQ���������Z���0���&��;�@��#13q����&	����������o�	6�r��_��;�GO>*I�(	7�4����XS1r3��)!����y��6Ko����t��#
_�w�S�r����
�;�B
A�Dp�(f��s����������6%�����.W0J3�:b�C�<�8t X����1�<��C��n�=�����t==�wS���T������~���\�wkB�f�|1���5���zU��P)��(���I��j��VB��!����OfI=b��b�\4�-*em��/��SJm�7���N�����[�]'��@����D9�Kr>���R��7/����|�o���^I@���'��Pa$ z��9�a'L�)��(�
�I��}v��c�H]����D����*��W�}
m�>Q����|�C.�(,�l��Q�1�o0�k0��0��10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1806U/StartCom Class 1 Primary Intermediate Client CAQ�0	+���0	*�H��
	1	*�H��
0	*�H��
	1
160512182836Z0#	*�H��
	1�+V�bKTV\�����u��+x0��	+�71��0��0��10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1806U/StartCom Class 1 Primary Intermediate Client CAQ�0��*�H��
	1�����0��10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1806U/StartCom Class 1 Primary Intermediate Client CAQ�0
	*�H��
�q����a�/`'���~H(l��s������y]8)�����v@�Xr�|�y]n4��>�k����5m�K0u�A��*!p|l���h�����q4K��j������-X]��)����h8��'W�z����;���
� �[��y��T�G�������{#hW�S��19:��]_�z�B=[E�A����2W��\��o�)��X�Xi;
��L���+������Y�//���M'���=�9k�v��X��W�U���8�vo��iK�
#21Tom Lane
tgl@sss.pgh.pa.us
In reply to: David E. Wheeler (#20)
Re: Does Type Have = Operator?

"David E. Wheeler" <david@justatheory.com> writes:

Some might argue that it ought to compare JSON objects, effectively be the equivalent of ::jsonb = ::jsonb, rather than ::text = ::text. But as Andrew points out to me offlist, “if that's what they want why aren't they using jsonb in the first place?”

So I think that, up to the introduction of JSONB, it was important not to side one way or the other and put a JSON = operator in core. But now what we have JSONB, perhaps it makes sense to finally take sides and intoduce JSON = that does plain text comparison. Thoughts?

Meh. Right now, if you want to compare values of type JSON, you have to
either cast them to text or to jsonb, and that effectively declares which
comparison semantics you want. I'm not sure that prejudging that is a
good thing for us to do, especially when the argument that text semantics
are what you would probably want is so weak.

Andrew mentions in the extension you pointed to that providing a default
comparison operator would enable people to do UNION, DISTINCT, etc on JSON
columns without thinking about it. I'm not convinced that "without
thinking about it" is a good thing here. But if we were going to enable
that, I'd feel better about making it default to jsonb semantics ...

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

#22David E. Wheeler
david@justatheory.com
In reply to: Tom Lane (#21)
1 attachment(s)
Re: Does Type Have = Operator?

On May 12, 2016, at 12:02 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Andrew mentions in the extension you pointed to that providing a default
comparison operator would enable people to do UNION, DISTINCT, etc on JSON
columns without thinking about it. I'm not convinced that "without
thinking about it" is a good thing here. But if we were going to enable
that, I'd feel better about making it default to jsonb semantics ...

If you want the JSONB semantics, why wouldn’t you use JSONB instead of JSON?

Best,

David

Attachments:

smime.p7sapplication/pkcs7-signature; name=smime.p7sDownload
0�	*�H��
��0�10	+0�	*�H��
��i0�-0��Q�0
	*�H��
0��10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1806U/StartCom Class 1 Primary Intermediate Client CA0
150909050437Z
160909073817Z0F10Udavid@justatheory.com1$0"	*�H��
	david@justatheory.com0�"0
	*�H��
�0�
��zg���P����������:�BV��h/�a�UcTD��L������V�9
��&��2��O*@@�g����E�����!�Ta��G�����R�B�����RI�\g��K��.7��������8��,dr��B��}���F��)�y��n��38�]$D) ��g�'
Hz�"�������`EVl�{<���q�h��A�-���=��:�m���nlxsN~�����jo���s�FV������1IB8p�1���0��0	U00U�0U%0++0U���D�!���<�rV6
���0U#0�Sr������\|~�5N���Q�0 U0�david@justatheory.com0�LU �C0�?0�;+��70�*0.+"http://www.startssl.com/policy.pdf0��+0��0' StartCom Certification Authority0��This certificate was issued according to the Class 1 Validation requirements of the StartCom CA policy, reliance only for the intended purpose in compliance of the relying party obligations.06U/0-0+�)�'�%http://crl.startssl.com/crtu1-crl.crl0��+��009+0�-http://ocsp.startssl.com/sub/class1/client/ca0B+0�6http://aia.startssl.com/certs/sub.class1.client.ca.crt0#U0�http://www.startssl.com/0
	*�H��
�r��������.��;�-a�����������L��O��4���}��F�,^��Y�,�'�d���7:�LR|��s=�9v|\K	��C�@�Y����VW�h Ev����M6��I�oIJ!y����l_����������3������V	[�\�nsD����|�~u����P��Tn�	C��_V!�{A�>��;g���^��,�a�d�X�T��vlO7��L��S>���N*i]m���R�tn����/k0�40��0
	*�H��
0}10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1)0'U StartCom Certification Authority0
071024210155Z
171024210155Z0��10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1806U/StartCom Class 1 Primary Intermediate Client CA0�"0
	*�H��
�0�
��	���-��)�.����2����A�UG��o���#G�
��B|N�D�����Rp�M-��B��=o���-�we�5��J�Qpa>O��.�#������.���_�<���V��
[~�*��*�p�z��~�3�W�G�.�������Ml�r[�<C�e�6���f����q������O���"��u��xf�WN�#�u����i���c�gk��v$����Lb�%�������y��`�����_�{`���xK'G�N������0��0U�0�0U�0USr������\|~�5N���Q�0U#0�N��@[�i�0�4hC�A��0f+Z0X0'+0�http://ocsp.startssl.com/ca0-+0�!http://www.startssl.com/sfsca.crt0[UT0R0'�%�#�!http://www.startssl.com/sfsca.crl0'�%�#�!http://crl.startssl.com/sfsca.crl0��U y0w0u+��70f0.+"http://www.startssl.com/policy.pdf04+(http://www.startssl.com/intermediate.pdf0
	*�H��
�
�}x�,\�c�^��#wM�q�}��>UK/��^y��X��y	�����f�rMI���B6�1ymQ���������Z���0���&��;�@��#13q����&	����������o�	6�r��_��;�GO>*I�(	7�4����XS1r3��)!����y��6Ko����t��#
_�w�S�r����
�;�B
A�Dp�(f��s����������6%�����.W0J3�:b�C�<�8t X����1�<��C��n�=�����t==�wS���T������~���\�wkB�f�|1���5���zU��P)��(���I��j��VB��!����OfI=b��b�\4�-*em��/��SJm�7���N�����[�]'��@����D9�Kr>���R��7/����|�o���^I@���'��Pa$ z��9�a'L�)��(�
�I��}v��c�H]����D����*��W�}
m�>Q����|�C.�(,�l��Q�1�o0�k0��0��10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1806U/StartCom Class 1 Primary Intermediate Client CAQ�0	+���0	*�H��
	1	*�H��
0	*�H��
	1
160512212556Z0#	*�H��
	1�I?EJ��������M�pb�0��	+�71��0��0��10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1806U/StartCom Class 1 Primary Intermediate Client CAQ�0��*�H��
	1�����0��10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1806U/StartCom Class 1 Primary Intermediate Client CAQ�0
	*�H��
��r(����P�m4�f��	�f�7y]e;�K
���6��k�������}��Z���Xr��U /�����eR:L;�����I&Z��jW�����@6~�`���R7����N����9��T6����g�	C
9Vt����NZ����@)�v��x�
4���{��?��2����]����s1��������5�Pn�
����C��q�y�$��	���M@v�{����; ����/~��+6)�i'����p���Oo��
#23Andrew Dunstan
andrew@dunslane.net
In reply to: Tom Lane (#21)
Re: Does Type Have = Operator?

On 05/12/2016 03:02 PM, Tom Lane wrote:

"David E. Wheeler" <david@justatheory.com> writes:

Some might argue that it ought to compare JSON objects, effectively be the equivalent of ::jsonb = ::jsonb, rather than ::text = ::text. But as Andrew points out to me offlist, “if that's what they want why aren't they using jsonb in the first place?�
So I think that, up to the introduction of JSONB, it was important not to side one way or the other and put a JSON = operator in core. But now what we have JSONB, perhaps it makes sense to finally take sides and intoduce JSON = that does plain text comparison. Thoughts?

Meh. Right now, if you want to compare values of type JSON, you have to
either cast them to text or to jsonb, and that effectively declares which
comparison semantics you want. I'm not sure that prejudging that is a
good thing for us to do, especially when the argument that text semantics
are what you would probably want is so weak.

Andrew mentions in the extension you pointed to that providing a default
comparison operator would enable people to do UNION, DISTINCT, etc on JSON
columns without thinking about it. I'm not convinced that "without
thinking about it" is a good thing here. But if we were going to enable
that, I'd feel better about making it default to jsonb semantics ...

I think you've been a little liberal with quoting the docs ;-) The
reason I made it an extension is precisely because it's not
unambiguously clear what json equality should mean.

cheers

andrew

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#24Jim Nasby
Jim.Nasby@BlueTreble.com
In reply to: David E. Wheeler (#22)
Re: Does Type Have = Operator?

On 5/12/16 4:25 PM, David E. Wheeler wrote:

On May 12, 2016, at 12:02 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Andrew mentions in the extension you pointed to that providing a default
comparison operator would enable people to do UNION, DISTINCT, etc on JSON
columns without thinking about it. I'm not convinced that "without
thinking about it" is a good thing here. But if we were going to enable
that, I'd feel better about making it default to jsonb semantics ...

If you want the JSONB semantics, why wouldn’t you use JSONB instead of JSON?

Probably in an attempt to bypass parse overhead on ingestion.

Possibly because JSONB silently eats duplicated keys while JSON doesn't
(though in that case even casting to JSONB is probably not what you want).
--
Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX
Experts in Analytics, Data Architecture and PostgreSQL
Data in Trouble? Get it in Treble! http://BlueTreble.com
855-TREBLE2 (855-873-2532) mobile: 512-569-9461

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#25Jim Nasby
Jim.Nasby@BlueTreble.com
In reply to: David E. Wheeler (#17)
Re: Does Type Have = Operator?

On 5/11/16 7:05 PM, David E. Wheeler wrote:

On May 11, 2016, at 10:34 AM, Kevin Grittner <kgrittn@gmail.com> wrote:

I'm not clear enough on your intended usage to know whether these
operators are a good fit, but they are sitting there waiting to be
used if they do fit.

Huh. I haven’t had any problems with IS DISTINCT FROM for rows, except for the situation in which a failure is thrown because the types vary, say between TEXT and CITEXT. That can drive the tester crazy, since it says something like:

Results differ beginning at row 3:
have: (44,Anna)
want: (44,Anna)

But overall I think that’s okay; the tester really does want to make sure the type is correct.

Speaking specifically to is(), what I'd find most useful is if it at
least hinted that there might be some type shenanigans going on, because
I've run across something like your example more than once and it always
takes a lot to finally figure out WTF is going on.

I think it'd also be useful to be able to specify an equality operator
to is(), though that means not using IS DISTINCT.

Something else to keep in mind here is that is() is defined as
is(anyelement, anyelement, text), which means you've lost your original
type information when you use it. I don't think you could actually do
anything useful here because of that.
--
Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX
Experts in Analytics, Data Architecture and PostgreSQL
Data in Trouble? Get it in Treble! http://BlueTreble.com
855-TREBLE2 (855-873-2532) mobile: 512-569-9461

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#26David E. Wheeler
david@justatheory.com
In reply to: Jim Nasby (#24)
1 attachment(s)
Re: Does Type Have = Operator?

On May 17, 2016, at 7:58 AM, Jim Nasby <Jim.Nasby@BlueTreble.com> wrote:

Probably in an attempt to bypass parse overhead on ingestion.

Possibly because JSONB silently eats duplicated keys while JSON doesn't (though in that case even casting to JSONB is probably not what you want).

It’s also when you’d want text equivalent semantics.

Best,

David

Attachments:

smime.p7sapplication/pkcs7-signature; name=smime.p7sDownload
0�	*�H��
��0�10	+0�	*�H��
��i0�-0��Q�0
	*�H��
0��10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1806U/StartCom Class 1 Primary Intermediate Client CA0
150909050437Z
160909073817Z0F10Udavid@justatheory.com1$0"	*�H��
	david@justatheory.com0�"0
	*�H��
�0�
��zg���P����������:�BV��h/�a�UcTD��L������V�9
��&��2��O*@@�g����E�����!�Ta��G�����R�B�����RI�\g��K��.7��������8��,dr��B��}���F��)�y��n��38�]$D) ��g�'
Hz�"�������`EVl�{<���q�h��A�-���=��:�m���nlxsN~�����jo���s�FV������1IB8p�1���0��0	U00U�0U%0++0U���D�!���<�rV6
���0U#0�Sr������\|~�5N���Q�0 U0�david@justatheory.com0�LU �C0�?0�;+��70�*0.+"http://www.startssl.com/policy.pdf0��+0��0' StartCom Certification Authority0��This certificate was issued according to the Class 1 Validation requirements of the StartCom CA policy, reliance only for the intended purpose in compliance of the relying party obligations.06U/0-0+�)�'�%http://crl.startssl.com/crtu1-crl.crl0��+��009+0�-http://ocsp.startssl.com/sub/class1/client/ca0B+0�6http://aia.startssl.com/certs/sub.class1.client.ca.crt0#U0�http://www.startssl.com/0
	*�H��
�r��������.��;�-a�����������L��O��4���}��F�,^��Y�,�'�d���7:�LR|��s=�9v|\K	��C�@�Y����VW�h Ev����M6��I�oIJ!y����l_����������3������V	[�\�nsD����|�~u����P��Tn�	C��_V!�{A�>��;g���^��,�a�d�X�T��vlO7��L��S>���N*i]m���R�tn����/k0�40��0
	*�H��
0}10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1)0'U StartCom Certification Authority0
071024210155Z
171024210155Z0��10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1806U/StartCom Class 1 Primary Intermediate Client CA0�"0
	*�H��
�0�
��	���-��)�.����2����A�UG��o���#G�
��B|N�D�����Rp�M-��B��=o���-�we�5��J�Qpa>O��.�#������.���_�<���V��
[~�*��*�p�z��~�3�W�G�.�������Ml�r[�<C�e�6���f����q������O���"��u��xf�WN�#�u����i���c�gk��v$����Lb�%�������y��`�����_�{`���xK'G�N������0��0U�0�0U�0USr������\|~�5N���Q�0U#0�N��@[�i�0�4hC�A��0f+Z0X0'+0�http://ocsp.startssl.com/ca0-+0�!http://www.startssl.com/sfsca.crt0[UT0R0'�%�#�!http://www.startssl.com/sfsca.crl0'�%�#�!http://crl.startssl.com/sfsca.crl0��U y0w0u+��70f0.+"http://www.startssl.com/policy.pdf04+(http://www.startssl.com/intermediate.pdf0
	*�H��
�
�}x�,\�c�^��#wM�q�}��>UK/��^y��X��y	�����f�rMI���B6�1ymQ���������Z���0���&��;�@��#13q����&	����������o�	6�r��_��;�GO>*I�(	7�4����XS1r3��)!����y��6Ko����t��#
_�w�S�r����
�;�B
A�Dp�(f��s����������6%�����.W0J3�:b�C�<�8t X����1�<��C��n�=�����t==�wS���T������~���\�wkB�f�|1���5���zU��P)��(���I��j��VB��!����OfI=b��b�\4�-*em��/��SJm�7���N�����[�]'��@����D9�Kr>���R��7/����|�o���^I@���'��Pa$ z��9�a'L�)��(�
�I��}v��c�H]����D����*��W�}
m�>Q����|�C.�(,�l��Q�1�o0�k0��0��10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1806U/StartCom Class 1 Primary Intermediate Client CAQ�0	+���0	*�H��
	1	*�H��
0	*�H��
	1
160517160302Z0#	*�H��
	14O
#�����xwt/����
0��	+�71��0��0��10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1806U/StartCom Class 1 Primary Intermediate Client CAQ�0��*�H��
	1�����0��10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1806U/StartCom Class 1 Primary Intermediate Client CAQ�0
	*�H��
�Y�8���|,����]�Q��b�@��q���q�y�#����T1AE��
�L.E���n����E�;�n$PN
k�+���l��5od�Z���U,���������q���"h]d���J���7�A�K��c(@�@���dL
d�o��z��]����7���Mq��non����H)*��S�����
1 y�Efe@��$^g���|�f���48����MZ�=�<�7�C�Nl��&0�Pf�&�����!c*��X
#27David E. Wheeler
david@justatheory.com
In reply to: Jim Nasby (#25)
1 attachment(s)
Re: Does Type Have = Operator?

Sorry for the pgTAP off-topicness here, hackers. Please feel free to ignore.

On May 17, 2016, at 8:10 AM, Jim Nasby <Jim.Nasby@BlueTreble.com> wrote:

Speaking specifically to is(), what I'd find most useful is if it at least hinted that there might be some type shenanigans going on, because I've run across something like your example more than once and it always takes a lot to finally figure out WTF is going on.

Agreed. Same for the relation testing functions. Maybe some additional diagnostics could be added in the event of failure.

I think it'd also be useful to be able to specify an equality operator to is(), though that means not using IS DISTINCT.

You can use cmp_ok().

http://pgxn.org/dist/pgtap/doc/pgtap.html#cmp_ok.

Something else to keep in mind here is that is() is defined as is(anyelement, anyelement, text), which means you've lost your original type information when you use it. I don't think you could actually do anything useful here because of that.

pg_typeof() will give it to you.

Best,

David

Attachments:

smime.p7sapplication/pkcs7-signature; name=smime.p7sDownload
0�	*�H��
��0�10	+0�	*�H��
��i0�-0��Q�0
	*�H��
0��10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1806U/StartCom Class 1 Primary Intermediate Client CA0
150909050437Z
160909073817Z0F10Udavid@justatheory.com1$0"	*�H��
	david@justatheory.com0�"0
	*�H��
�0�
��zg���P����������:�BV��h/�a�UcTD��L������V�9
��&��2��O*@@�g����E�����!�Ta��G�����R�B�����RI�\g��K��.7��������8��,dr��B��}���F��)�y��n��38�]$D) ��g�'
Hz�"�������`EVl�{<���q�h��A�-���=��:�m���nlxsN~�����jo���s�FV������1IB8p�1���0��0	U00U�0U%0++0U���D�!���<�rV6
���0U#0�Sr������\|~�5N���Q�0 U0�david@justatheory.com0�LU �C0�?0�;+��70�*0.+"http://www.startssl.com/policy.pdf0��+0��0' StartCom Certification Authority0��This certificate was issued according to the Class 1 Validation requirements of the StartCom CA policy, reliance only for the intended purpose in compliance of the relying party obligations.06U/0-0+�)�'�%http://crl.startssl.com/crtu1-crl.crl0��+��009+0�-http://ocsp.startssl.com/sub/class1/client/ca0B+0�6http://aia.startssl.com/certs/sub.class1.client.ca.crt0#U0�http://www.startssl.com/0
	*�H��
�r��������.��;�-a�����������L��O��4���}��F�,^��Y�,�'�d���7:�LR|��s=�9v|\K	��C�@�Y����VW�h Ev����M6��I�oIJ!y����l_����������3������V	[�\�nsD����|�~u����P��Tn�	C��_V!�{A�>��;g���^��,�a�d�X�T��vlO7��L��S>���N*i]m���R�tn����/k0�40��0
	*�H��
0}10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1)0'U StartCom Certification Authority0
071024210155Z
171024210155Z0��10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1806U/StartCom Class 1 Primary Intermediate Client CA0�"0
	*�H��
�0�
��	���-��)�.����2����A�UG��o���#G�
��B|N�D�����Rp�M-��B��=o���-�we�5��J�Qpa>O��.�#������.���_�<���V��
[~�*��*�p�z��~�3�W�G�.�������Ml�r[�<C�e�6���f����q������O���"��u��xf�WN�#�u����i���c�gk��v$����Lb�%�������y��`�����_�{`���xK'G�N������0��0U�0�0U�0USr������\|~�5N���Q�0U#0�N��@[�i�0�4hC�A��0f+Z0X0'+0�http://ocsp.startssl.com/ca0-+0�!http://www.startssl.com/sfsca.crt0[UT0R0'�%�#�!http://www.startssl.com/sfsca.crl0'�%�#�!http://crl.startssl.com/sfsca.crl0��U y0w0u+��70f0.+"http://www.startssl.com/policy.pdf04+(http://www.startssl.com/intermediate.pdf0
	*�H��
�
�}x�,\�c�^��#wM�q�}��>UK/��^y��X��y	�����f�rMI���B6�1ymQ���������Z���0���&��;�@��#13q����&	����������o�	6�r��_��;�GO>*I�(	7�4����XS1r3��)!����y��6Ko����t��#
_�w�S�r����
�;�B
A�Dp�(f��s����������6%�����.W0J3�:b�C�<�8t X����1�<��C��n�=�����t==�wS���T������~���\�wkB�f�|1���5���zU��P)��(���I��j��VB��!����OfI=b��b�\4�-*em��/��SJm�7���N�����[�]'��@����D9�Kr>���R��7/����|�o���^I@���'��Pa$ z��9�a'L�)��(�
�I��}v��c�H]����D����*��W�}
m�>Q����|�C.�(,�l��Q�1�o0�k0��0��10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1806U/StartCom Class 1 Primary Intermediate Client CAQ�0	+���0	*�H��
	1	*�H��
0	*�H��
	1
160517160616Z0#	*�H��
	1j&�L�P$�����R�x���
p0��	+�71��0��0��10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1806U/StartCom Class 1 Primary Intermediate Client CAQ�0��*�H��
	1�����0��10	UIL10U

StartCom Ltd.1+0)U"Secure Digital Certificate Signing1806U/StartCom Class 1 Primary Intermediate Client CAQ�0
	*�H��
��!��%����
3�����l ������nRe��L�#Dt"�"K�I���Wrh���!-����7l��r�U%�-��m�	$\��H/?*s*��
�g�]���[#�X�,�v�U~�"Ph%"Tk�>�XL]���>����f��
%W!������7����P����J���c�k�u�w��xe������nA�LP���h���P�����q�� �o��q�$8�BS�
c�����5O|�l���>���