unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#19452: 24.4; sql-connect fails in first invocation: "Attempt to set a constant symbol: nil"
@ 2014-12-27  6:45 JuanLeon Lahoz
  2016-07-25 20:12 ` Nikolay Kudryavtsev
  2016-11-29 21:01 ` bug#19452: status? root
  0 siblings, 2 replies; 11+ messages in thread
From: JuanLeon Lahoz @ 2014-12-27  6:45 UTC (permalink / raw)
  To: 19452

[-- Attachment #1: Type: text/plain, Size: 1778 bytes --]

First time in an emacs session I call interactively to sql-connect,
after I am prompted with the "Connection: " to use, emacs fails to
process the request with:

    eval: Attempt to set a constant symbol: nil

Subsequent invocations of the comman works fine

I can reproduce with emacs -Q, evalling this:

    (setq sql-connection-alist
           '(("foo"
              (sql-product  'mysql)
              (sql-database "foo")
              (sql-server   "localhost")
              (sql-user     "foo")
              (sql-password ""))))

And doing M-x sql-connect, then typing "foo" at the prompt.

I tried to use foo, instead of "foo" in the variable definition.  It is
the same.

If this is a bug, I would be happy to test a patch.

Thanks
juanleon


In GNU Emacs 24.4.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.4.2)
 of 2014-12-26 on malaz
Windowing system distributor `The X.Org Foundation', version 11.0.11406000
System Description:    Ubuntu 12.04.5 LTS

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: SQLi[MySQL]

Minor modes in effect:
  popwin-mode: t
  yas-global-mode: t
  yas-minor-mode: t
  global-auto-complete-mode: t
  shell-dirtrack-mode: t
  projectile-global-mode: t
  projectile-mode: t
  back-button-mode: t
  flx-ido-mode: t
  ido-everywhere: t
  global-yascroll-bar-mode: t
  yascroll-bar-mode: t
  winner-mode: t
  show-paren-mode: t
  auto-image-file-mode: t
  recentf-mode: t
  tooltip-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  temp-buffer-resize-mode: t
  size-indication-mode: t
  column-number-mode: t
  line-number-mode: t

[-- Attachment #2: Type: text/html, Size: 2231 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#19452: 24.4; sql-connect fails in first invocation: "Attempt to set a constant symbol: nil"
  2014-12-27  6:45 bug#19452: 24.4; sql-connect fails in first invocation: "Attempt to set a constant symbol: nil" JuanLeon Lahoz
@ 2016-07-25 20:12 ` Nikolay Kudryavtsev
  2016-07-25 20:56   ` Nicolas Petton
  2016-11-29 21:01 ` bug#19452: status? root
  1 sibling, 1 reply; 11+ messages in thread
From: Nikolay Kudryavtsev @ 2016-07-25 20:12 UTC (permalink / raw)
  To: 19452

[-- Attachment #1: Type: text/plain, Size: 830 bytes --]

Ok, this bug has been bugging me long enough.

What happens is that there's a dynamic let block that looks like this:

(eval `(let ((,param-var ',rem-params))
                          (sql-product-interactive ',sql-product 
',new-name))))

Here's the code that sets param-var:

(setq param-var
           (sql-get-product-feature sql-product :sqli-login nil t))

It uses global variable sql-product. The default sql-product is ansi and 
running the above for it results in nil. Running "(let ((nil ..." leads 
to this error. In the same function there is a block that sets it to a 
proper value based on the current connection, but it is executed after 
param-var is already set. That's why the second time works.


I've attached a simple patch that just reorders code within sql-connect.

-- 
Best Regards,
Nikolay Kudryavtsev


[-- Attachment #2: 19452.patch --]
[-- Type: text/plain, Size: 1386 bytes --]

diff --git lisp/progmodes/sql.el lisp/progmodes/sql.el
index fd59f46..a6e7ec4 100644
--- lisp/progmodes/sql.el
+++ lisp/progmodes/sql.el
@@ -4040,6 +4040,12 @@ sql-connect
           (if connect-set
               ;; Set the desired parameters
               (let (param-var login-params set-params rem-params)
+                ;; Set the parameters and start the interactive session
+                (mapc
+                 #'(lambda (vv)
+                     (set-default (car vv) (eval (cadr vv))))
+                 (cdr connect-set))
+                (setq-default sql-connection connection)

                 ;; :sqli-login params variable
                 (setq param-var
@@ -4069,13 +4075,6 @@ sql-connect
                            (unless (member token set-params)
                              (if plist (cons token plist) token)))))

-                ;; Set the parameters and start the interactive session
-                (mapc
-                 #'(lambda (vv)
-                     (set-default (car vv) (eval (cadr vv))))
-                 (cdr connect-set))
-                (setq-default sql-connection connection)
-
                 ;; Start the SQLi session with revised list of login parameters
                 (eval `(let ((,param-var ',rem-params))
                          (sql-product-interactive ',sql-product ',new-name))))

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* bug#19452: 24.4; sql-connect fails in first invocation: "Attempt to set a constant symbol: nil"
  2016-07-25 20:12 ` Nikolay Kudryavtsev
@ 2016-07-25 20:56   ` Nicolas Petton
  2016-07-26 13:19     ` Nikolay Kudryavtsev
  0 siblings, 1 reply; 11+ messages in thread
From: Nicolas Petton @ 2016-07-25 20:56 UTC (permalink / raw)
  To: Nikolay Kudryavtsev, 19452

[-- Attachment #1: Type: text/plain, Size: 254 bytes --]

Nikolay Kudryavtsev <nikolay.kudryavtsev@gmail.com> writes:

Hi Nikolay,


> +                (mapc
> +                 #'(lambda (vv)
> +                     (set-default (car vv) (eval (cadr vv))))

You don't need to sharp-quote lambdas.

Cheers,
Nico

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 512 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#19452: 24.4; sql-connect fails in first invocation: "Attempt to set a constant symbol: nil"
  2016-07-25 20:56   ` Nicolas Petton
@ 2016-07-26 13:19     ` Nikolay Kudryavtsev
  2016-07-26 15:11       ` Nicolas Petton
  0 siblings, 1 reply; 11+ messages in thread
From: Nikolay Kudryavtsev @ 2016-07-26 13:19 UTC (permalink / raw)
  To: Nicolas Petton, 19452

Yeah, thanks. I just didn't bother to change what was there originally. 
There's a lot more of them there too.

Looking at vc history, sql.el got infested by those sharp-quoted lambdas 
relatively recently, in 2013, at e18e61cf276880f658ab8cdf1f242a675b58cd71.

And I honestly can't blame the author for that. Even the current Elisp 
reference is a bit unclear on the use of sharp-quotes.

-- 
Best Regards,
Nikolay Kudryavtsev






^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#19452: 24.4; sql-connect fails in first invocation: "Attempt to set a constant symbol: nil"
  2016-07-26 13:19     ` Nikolay Kudryavtsev
@ 2016-07-26 15:11       ` Nicolas Petton
  2016-07-26 15:38         ` Eli Zaretskii
  2016-07-31 12:50         ` Nikolay Kudryavtsev
  0 siblings, 2 replies; 11+ messages in thread
From: Nicolas Petton @ 2016-07-26 15:11 UTC (permalink / raw)
  To: Nikolay Kudryavtsev, 19452

[-- Attachment #1: Type: text/plain, Size: 259 bytes --]

Nikolay Kudryavtsev <nikolay.kudryavtsev@gmail.com> writes:

> Yeah, thanks. I just didn't bother to change what was there originally. 
> There's a lot more of them there too.

I fixed them in master (you'll need to update your patch).

Cheers,
Nico

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 512 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#19452: 24.4; sql-connect fails in first invocation: "Attempt to set a constant symbol: nil"
  2016-07-26 15:11       ` Nicolas Petton
@ 2016-07-26 15:38         ` Eli Zaretskii
  2016-07-26 16:41           ` Nicolas Petton
  2016-07-31 12:50         ` Nikolay Kudryavtsev
  1 sibling, 1 reply; 11+ messages in thread
From: Eli Zaretskii @ 2016-07-26 15:38 UTC (permalink / raw)
  To: Nicolas Petton; +Cc: 19452, nikolay.kudryavtsev

> From: Nicolas Petton <nicolas@petton.fr>
> Date: Tue, 26 Jul 2016 17:11:41 +0200
> 
> > Yeah, thanks. I just didn't bother to change what was there originally. 
> > There's a lot more of them there too.
> 
> I fixed them in master (you'll need to update your patch).

Thanks.  When you compiled sql.el, did you see the warning below?

  In sql-end-of-statement:
  progmodes/sql.el:2781:31:Warning: looking-back called with 1 argument, but
      requires 2-3





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#19452: 24.4; sql-connect fails in first invocation: "Attempt to set a constant symbol: nil"
  2016-07-26 15:38         ` Eli Zaretskii
@ 2016-07-26 16:41           ` Nicolas Petton
  0 siblings, 0 replies; 11+ messages in thread
From: Nicolas Petton @ 2016-07-26 16:41 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 19452, nikolay.kudryavtsev

[-- Attachment #1: Type: text/plain, Size: 309 bytes --]

Eli Zaretskii <eliz@gnu.org> writes:

> Thanks.  When you compiled sql.el, did you see the warning below?
>
>   In sql-end-of-statement:
>   progmodes/sql.el:2781:31:Warning: looking-back called with 1 argument, but
>       requires 2-3

Yes, but I haven't changed anything related to this, or?

Cheers,
Nico

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 512 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#19452: 24.4; sql-connect fails in first invocation: "Attempt to set a constant symbol: nil"
  2016-07-26 15:11       ` Nicolas Petton
  2016-07-26 15:38         ` Eli Zaretskii
@ 2016-07-31 12:50         ` Nikolay Kudryavtsev
  1 sibling, 0 replies; 11+ messages in thread
From: Nikolay Kudryavtsev @ 2016-07-31 12:50 UTC (permalink / raw)
  To: Nicolas Petton, 19452

[-- Attachment #1: Type: text/plain, Size: 92 bytes --]

Here's the same patch made from the current master.

-- 
Best Regards,
Nikolay Kudryavtsev


[-- Attachment #2: 19452.patch --]
[-- Type: text/plain, Size: 1444 bytes --]

diff --git lisp/progmodes/sql.el lisp/progmodes/sql.el
index a11d456..9a7b746 100644
*** lisp/progmodes/sql.el
--- lisp/progmodes/sql.el
***************
*** 4040,4045 ****
--- 4040,4051 ----
            (if connect-set
                ;; Set the desired parameters
                (let (param-var login-params set-params rem-params)
+                 ;; Set the parameters and start the interactive session
+                 (mapc
+                  (lambda (vv)
+                    (set-default (car vv) (eval (cadr vv))))
+                  (cdr connect-set))
+                 (setq-default sql-connection connection)

                  ;; :sqli-login params variable
                  (setq param-var
***************
*** 4069,4081 ****
                             (unless (member token set-params)
                               (if plist (cons token plist) token)))))

-                 ;; Set the parameters and start the interactive session
-                 (mapc
-                  (lambda (vv)
-                      (set-default (car vv) (eval (cadr vv))))
-                  (cdr connect-set))
-                 (setq-default sql-connection connection)
-
                  ;; Start the SQLi session with revised list of login parameters
                  (eval `(let ((,param-var ',rem-params))
                           (sql-product-interactive ',sql-product ',new-name))))
--- 4075,4080 ----

^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#19452: status?
  2014-12-27  6:45 bug#19452: 24.4; sql-connect fails in first invocation: "Attempt to set a constant symbol: nil" JuanLeon Lahoz
  2016-07-25 20:12 ` Nikolay Kudryavtsev
@ 2016-11-29 21:01 ` root
  2016-12-02  9:55   ` Eli Zaretskii
  1 sibling, 1 reply; 11+ messages in thread
From: root @ 2016-11-29 21:01 UTC (permalink / raw)
  To: 19452

Hello

Just wondering why it's still not fixed.
Incorrect patch?





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#19452: status?
  2016-11-29 21:01 ` bug#19452: status? root
@ 2016-12-02  9:55   ` Eli Zaretskii
  2016-12-13 11:06     ` root
  0 siblings, 1 reply; 11+ messages in thread
From: Eli Zaretskii @ 2016-12-02  9:55 UTC (permalink / raw)
  To: root; +Cc: 19452-done

> Date: Tue, 29 Nov 2016 22:01:42 +0100
> From: root@opow.pw
> 
> Just wondering why it's still not fixed.
> Incorrect patch?

Thanks for the reminder, I pushed the patch to the master branch.





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#19452: status?
  2016-12-02  9:55   ` Eli Zaretskii
@ 2016-12-13 11:06     ` root
  0 siblings, 0 replies; 11+ messages in thread
From: root @ 2016-12-13 11:06 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 19452-done

On Fri, Dec 02, 2016 at 11:55:01AM +0200, Eli Zaretskii wrote:
> > Date: Tue, 29 Nov 2016 22:01:42 +0100
> > From: root@opow.pw
> > 
> > Just wondering why it's still not fixed.
> > Incorrect patch?
> 
> Thanks for the reminder, I pushed the patch to the master branch.

Thanks!





^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2016-12-13 11:06 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-27  6:45 bug#19452: 24.4; sql-connect fails in first invocation: "Attempt to set a constant symbol: nil" JuanLeon Lahoz
2016-07-25 20:12 ` Nikolay Kudryavtsev
2016-07-25 20:56   ` Nicolas Petton
2016-07-26 13:19     ` Nikolay Kudryavtsev
2016-07-26 15:11       ` Nicolas Petton
2016-07-26 15:38         ` Eli Zaretskii
2016-07-26 16:41           ` Nicolas Petton
2016-07-31 12:50         ` Nikolay Kudryavtsev
2016-11-29 21:01 ` bug#19452: status? root
2016-12-02  9:55   ` Eli Zaretskii
2016-12-13 11:06     ` root

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).